Friday, February 24, 2012

How to block indent code in vi or vim

The > command is to be used.

* To indent a block of 5 lines use 5>>

* To visually edit a block of lines use vjj> 
(v will start the visual mode, jj will select the lines to be indented, and > will result in the indent).

* To indent a curly-braces block, put your cursor on one of the curly braces and use >%

* If you’re copying blocks of text around and need to align the indent of a block in its new location, use ]p instead of just p. This aligns the pasted block with the surrounding text.

0 comments:

Post a Comment