Joe Mornin
Joe Mornin

Reputation: 9134

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?

Upvotes: 5

Views: 272

Answers (2)

Chris Morgan
Chris Morgan

Reputation: 90742

2>k (or >2k)

Remember from the manual,

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

But also,

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

Upvotes: 1

eckes
eckes

Reputation: 67047

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.

Upvotes: 5

Related Questions