Vim Tips Wiki
Advertisement
Tip 224 Printable Monobook Previous Next

created March 13, 2002 · complexity basic · author niboan · version 5.7


I use the < and > commands on blocks a lot, and it has always annoyed me that if you want to shift more than one 'shiftwidth', you have count how many 'shiftwidth's you want to enter the [count]>, or restore the selection with gv. So I've cooked up two mappings that come in very handy:

:vnoremap < <gv
:vnoremap > >gv

These mappings will reselect the block after shifting, so you'll just have to select a block, press < or > as many times as you like, and press <Esc> when you're done to unselect the block.

Comments

I use "." (repeat previous command) to shift the block again.


Using "." is nice, but it only moves in the same direction. It's not the same thing as the tip.


Ah, but 'u' will undo the last action. So do the shift, '.' to repeat in the same direction, 'u' to essentially shift back in the other if you go too far.

I actually prefer '=' after setting indentprg and options appropriately.


Advertisement