Let's say I'd like to indent the current line 4 times. (Not 4 spaces, 4 indent commands). As far as I can tell, the shortest way to do this is


(Indent once, repeat three times) This seems really inefficient to me. I'd rather do something like this:


But instead of repeatedly indenting the current line, this indents the next 4 lines 1 time. In my mind, this is a total waste, because if the count before the operator was "indent level", and the count after is for a repeated motion, this doesn't lose any ability. If I wanted to indent the next four lines one time, I could just do


or even


If the first count were to work this way, you could even do a command like this:


And this would mean "Two times, indent the following four lines". Instead it means "One time, indent eight lines".

Can I configure vim to behave this way?


2 Answers 2


You can do:


to shift the current line 4 times.

So you could write a custom normal mode mapping that shifts the current line {count} times:

nnoremap <expr> <F5> ":\<C-u>" . repeat(">", v:count1) . "\<CR>"
nnoremap <expr> <F6> ":\<C-u>" . repeat("<", v:count1) . "\<CR>"

and its visual mode counterpart:

xnoremap <expr> <F5> ":" . repeat(">", v:count1) . "\<CR>"
xnoremap <expr> <F6> ":" . repeat("<", v:count1) . "\<CR>"

Mixing {count} and {range} may be a bit more complicated.


alternate using visual mode:


Or just


as mentioned in the SO thread How do I indent a single line multiple times in vi or vim?

For multiple lines, for example - current line and 3 lines down, indent twice:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.