Vim: How to insert in visual block mode?

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

+113
vim
Sep 13
source share
4 answers

Try

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

String i will not work.




If this does not work ...

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

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

The inclusion of this question is beyond the scope of this question, but I'm sure you can find it somewhere.

+154
Sep 13
source share
  • press ctrl and v // start select
  • press shift and i // then enter any text
  • press esc esc // press esc twice
+35
Mar 28 '17 at 17:42 on
source share

You may also have a use case in which you want to remove a block of text and replace it.

Like this

 Hello World Hello World 

You can select the visual block in front of β€œW” and press I. Type β€œCool” - press ESC and then delete β€œWorld” by selecting the visual block.

Alternatively, the cooler way to do this is to only select the "World" in both lines of the visual block . Type c for change . You are now in insert mode. Insert the desired material and press ESC . Both are reflected with less keystrokes.

 Hello Cool Hello Cool 
+28
Jul 03 '14 at 9:38
source share

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

  • press ctrl + v
  • select columns
  • press shift + i
  • write text
  • press esc
  • click "jj"
+5
Oct 26 '17 at 8:11
source share



All Articles