Tabbing visual selection in VIM

后端 未结 9 739
悲哀的现实
悲哀的现实 2020-12-02 18:35

In many GUIs when I select a section of text and then hit the Tab or Shift+Tab button the selected section will indent in or out.

I

相关标签:
9条回答
  • 2020-12-02 19:14

    Try >} for 'indent next paragraph one level'.

    0 讨论(0)
  • 2020-12-02 19:21

    With visual block selection

    Steps:
    Select the block(Ctrl + v)
    type c(change)
    type needed space
    type esc

    0 讨论(0)
  • 2020-12-02 19:25

    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.

    0 讨论(0)
  • 2020-12-02 19:25

    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.
    0 讨论(0)
  • 2020-12-02 19:27
    vmap <Tab> >gv
    vmap <S-Tab> <gv
    
    0 讨论(0)
  • 2020-12-02 19:32

    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.

    0 讨论(0)
提交回复
热议问题