How do you prettify / align / format code in vi? What is the command?
I have pasted in a hunk of code and I need to have it all formatted/aligned... obviously I am a vi neophyte.
x
How do you prettify / align / format code in vi? What is the command?
I have pasted in a hunk of code and I need to have it all formatted/aligned... obviously I am a vi neophyte.
x
If manually adjusting indents I will open a visual block with V
on the first or last line I want to re-indent, move to the brace containing the block, goto the other brace with %
then shift the line with >
or <
If indents are off by a lot I will shift everything all the way left with <
and repeat it with .
and then re-indent everything.
Another solution is to use the unix fmt
command as described in Your problem with Vim is that you don't grok vi., {!}fmt