Say I have PHP code which looks like this
$values = array(
'foo' => 'bar',
'longfoo' => 'otherbar',
'baz' => 'foobar,
);
Is there a way in Vim to align the array values and format it like following?
$values = array(
'foo' => 'bar',
'longfoo' => 'otherbar',
'baz' => 'foobar,
);
Minor note: I use spaces, not tabs for indenting.
The tabular plugin would make that easy. After installing that you could simply run
:Tabularize /=>/
while on any of the lines which are to be aligned. If you use that same pattern often, you could even setup a mapping to do that even faster.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With