Indent multiple lines above the cursor in Vim

Tag: vim , indentation Author: jayyjjfha Date: 2011-11-16

I know that 3>> will indent the current line and the two lines below the cursor. How do I indent the current line and the two lines above?

Best Answer

It should be working with




Or, select the line and the two above in visual mode and then just type >.

:he shift-left-right has more information about shifting.
:he :ranges tells you more about specifying ranges for a command.


Nice answer. Also, k could be any of hjkl to denote the direction of the command. For example: 4gUl would upper-case the next 4 characters while 4gUh would upper-case the previous 4.
The first command could be shortened a bit: :-2,>.

Other Answer1

2>k (or >2k)

Remember from the manual,

>>            Shift [count] lines one 'shiftwidth' rightwards.

But also,

>{motion}     Shift {motion} lines one 'shiftwidth' rightwards.