Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to indent multiple lines above the cursor in Vim?

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?

like image 570
Joe Mornin Avatar asked Dec 02 '11 13:12

Joe Mornin


2 Answers

It should be working with

:-2,.>

or

>2k

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.

like image 119
eckes Avatar answered Sep 29 '22 07:09

eckes


2>k (or >2k)

Remember from the manual,

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

But also,

                          *>*
>{motion}     Shift {motion} lines one 'shiftwidth' rightwards.
like image 33
Chris Morgan Avatar answered Sep 29 '22 07:09

Chris Morgan