Tabbing visual selection

Try using "." to repeat the command. It remembers the range, and you can use "u" to undo one level if you go too far. No configuration needed.


Another way is to select a block and insert an indent at the beginning of the line using this sequence:

  1. ctrl+V + arrow keys to select the block.
  2. I to switch to insert mode such that the inserted text is inserted at the beginning of the selection in each line in the selected block.
  3. ctrl+T to increase the indent or ctrl+D to decrease the indent. You can add any number of indents like this. Note: The indentation will be seen only the first line of the block, but when insert mode is exited the indentation will be replicated on all the lines in the block.

You can prefix a number, ie. 2> to indent two tab stops. Or, you can use > to indent once, then . to indent again (this works even though the block is no longer highlighted). If you go too far, u will undo one step at a time.

Another useful command is gv to restore the last visual block if you need to apply a different command.


vmap <Tab> >gv
vmap <S-Tab> <gv

Tags:

Vim