Reputation: 8616
How can you insert when you are in visual block mode (by pressing ctrl-V) in Vim?
Upvotes: 245
Views: 261745
Reputation: 699
if you want to add new text before or after the selected colum:
Upvotes: 26
Reputation: 21934
You might also have a use case where you want to delete a block of text and replace it:
Hello World
Hello World
to
Hello Cool
Hello Cool
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.
Upvotes: 40
Reputation: 121
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 03 2023 07:45:49)
CTRL + q - ENTER VISUAL MODE
j or k - SELECT LINES BELOW OR ABOVE
SHIFT + i - ADD CONTENT TO THE FIRST LINE
ESC - EXIT INSERT MODE
j - PROPAGATE CHANGES TO THE OTHER LINES
Upvotes: 10
Reputation: 8616
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.
Upvotes: 367
Reputation: 1235
Upvotes: 78