7

I am using mvim . I am trying to map keys so that I could visually select elements then I could indent the code inward or outward. However while doing outward work after every keystroke one more line at the bottom get selected. What is the fix.

" Ctrl-x - move the block of visually selected code one tab right and keep visual mode alive
" Ctrl-z moves the data in opposite direction
" Usage : shift v and select multiple lines. then Ctrl x multiple times and
" then Ctrl z multiple times
vmap <C-x> >gv  
vmap <C-z> <gv  
Nick Vanderbilt
  • 36,724
  • 29
  • 83
  • 106
  • 1
    You may want to check this related question as well: http://stackoverflow.com/questions/2332340/indenting-a-bunch-of-lines-in-vim – Brian Rasmussen Mar 02 '10 at 21:03

1 Answers1

16

Why would you go to the trouble when you already can do this?

>> - increase indent of selected block

<< - decrease indent of selected block

This will cause you to lose the focus. If you want to continue indenting just type . to repeat the last action. You can also type gv to re-select your last selection.

Another option is to select and type a number before indenting, which is the same as repeating the >> or << as many times as the number you typed.

Nathan Fellman
  • 122,701
  • 101
  • 260
  • 319