问题
For example, to convert this
$example = array(
'First' => 'This,
'Second' => 'is',
'Third' => 'an',
'Fourth'=> 'example',
'Fifth' => '.',
);
into this
$example = array(
'First' => 'This',
'Second' => 'is',
'Third' => 'an',
'Fourth' => 'example',
'Fifth' => '.',
);
without having to indent each => 'whatever',
each time.
Is this possible to do in vi?
回答1:
There are two Vim plugins for that, Align and Tabular. With Align, select the lines and execute
:'<,'>Align =>
Tabular is a more recent alternative to the venerable Align, but both offer similar functionality. Pick according to your preferences.
回答2:
As a complement to Ingo's answer, here is how you do it with Tabular:
:'<,'>Tabularize /=>
来源:https://stackoverflow.com/questions/13174568/how-to-indent-multiple-lines-starting-from-the-middle-in-vi