Reputation: 38420
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
Upvotes: 7
Views: 6132
Reputation: 127428
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.
Upvotes: 16