Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I usually use Textmate, which can do this by pressing option+command+right-bracket and it evenly spaces out a selection of declared variables with values. Same goes for arrays as well, it will space out the keys and their assigned values. For context check out #2 on the following page.

I have to use Notepad++ at work and was wondering how to do the same thing via shortcut key or menu option.

Before variables/array keys are spaced out evenly.

$var = 'value';
$my_var = 'value';
$data = array(
    'my_key' => 'value',
    'some_other_key' => 'value'
);

After variables/array keys are spaced out evenly.

$var    = 'value';
$my_var = 'value';
$data = array(
    'my_key'        => 'value',
    'some_other_key' => 'value'
);
share|improve this question

1 Answer 1

up vote 4 down vote accepted

I don't know of a shortcut, but this can be down through the TextFX menu.

Select the lines that you want to align, then select TextFX -> TextFX Edit -> Line up multiple lines by (=). In your case, you would select the var and my_var lines, align them, then do the same for the my_key and some_other_key lines. Note that TextFX will trim whitespace, but it's easy to re-add with a column select for spaces before the = and the typical behaviour for multiline indenting.

Edit: Apparently, TextFX doesn't like your array. Don't know why, but I'll look into possible solutions.

Edit 2: It's because a ' was missing for some_other_key.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.