Vim: How to insert in visual block mode?

前端 未结 4 1119
离开以前
离开以前 2020-12-12 11:58

How can you insert when you are in visual block mode (by pressing ctrl-V) in Vim?

相关标签:
4条回答
  • 2020-12-12 12:24

    You might also have a use case where you want to delete a block of text and replace it .

    Like this

    Hello World
    Hello World
    

    You can visual block select before "W" and hit Shift+i - Type "Cool" - Hit ESC and then delete "World" by visual block selection .

    Alternatively, the cooler way to do it is to just visual block select "World" in both lines. Type c for change. Now you are in the insert mode. Insert the stuff you want and hit ESC. Both gets reflected with lesser keystrokes.

    Hello Cool 
    Hello Cool
    
    0 讨论(0)
  • 2020-12-12 12:24

    if you want to add new text before or after the selected colum:

    • press ctrl+v
    • select columns
    • press shift+i
    • write your text
    • press esc
    • press "jj"
    0 讨论(0)
  • 2020-12-12 12:33
    1. press ctrl and v // start select
    2. press shift and i // then type in any text
    3. press esc esc // press esc twice
    0 讨论(0)
  • 2020-12-12 12:40

    Try this

    After selecting a block of text, press Shift+i or capital I.

    Lowercase i will not work.

    Then type the things you want and finally to apply it to all lines, press Esc twice.




    If this doesn't work...

    Check if you have +visualextra enabled in your version of Vim.

    You can do this by typing in :ver and scrolling through the list of features. (You might want to copy and paste it into a buffer and do incremental search because the format is odd.)

    Enabling it is outside the scope of this question but I'm sure you can find it somewhere.

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