Quick Vim Tip: Indenting and Unindenting a Block of Text
08Dec06 Steven
I’ve gone years without knowing this. I can do pretty much what I need to do with Vim, but while hacking some Python recently I realized I’d really like to have the ability to select a block of text and repeatedly indent or unindent it. Visual Studio and PSPad make quick work of tasks like that.
You can, of course, do this in Vim. Here’s how:
First, to enter the visual select mode, type
V
Now, to select lines below that point, type
j
Repeatedly pressing j will move the cursor down line by line, selecting as it goes. You should see the block get highlighted. Finally, to indent the selected block, type
>
Or to unindent, type
<



This can also be accomplished in most any version of vim (non-visually of course
.
If you need to reposition the 6 lines below you present position, simply type:
6>> to indent or 6
thank you sooo much!