Showing posts with label format. Show all posts
Showing posts with label format. Show all posts

Monday, August 13, 2007

VIM - format lines to certain width

First,
:set textwidth=80 (or :set tw=80)
Then,
gqqFormat a single line
{Visual}gqFormat visual selection. (ctrl+v to get to visual mode then use hjkl to navigate)

For more help,
:help gq

Wednesday, April 18, 2007

VIM - Shifting and code formatting

You can shift (indent) code right or left by typing >> or <<, respectively, with your cursor on the line you want to shift.

You can use VIM automatic formating by typing == on the line you want to format.

You can also set the amount of spaces to shift.

You can also shift and format in visual mode (To get into visual mode: SHIFT+V, then j and k to select rows) by selecting the lines you want, then typing >, <, or =.