I have the following code:
a = 123
p.value 0.123
p.long.name = "abc"
How can I align each line like shown below in vim?
a = 123
p.value = 0.123
p.long.name = "abc"
Thanks for any hints.
To align the text left, press Ctrl+L. To align the text right, press Ctrl+R. To center the text, press Ctrl+E.
There are four types of paragraph alignment available in Microsoft Word — left-aligned, center-aligned, rightaligned, and justified.
Without plugin:
:%s/=/ &/
:%s/\%13c\s\+=/=
First command will insert spaces before first equal signs on all lines, second one will remove all spaces before an equal sign at 13th column. You could also use Visual block selection and <.....
to shift left as many times as necessary.
However this is really unclean. With the tabular plugin you just type :Tab /=/
and this will do the work and the range will be calculated automatically (greatest range around the cursor in which all lines match the pattern).
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