I know this is not new information at all, but every time I have to insert some text at some specific index for a group of consecutive strings I have to google something like “column insert VIM” (surprisingly, the title of this post) and search through the first 5 results for the correct solution. Well, the one I happen to understand, anyway…
So, here’s how it’s done:
- move the cursor to the uppermost character (if you’re selecting lines the way down, bottom if you’re going up)Β before which you want to insert text
- enter Visual Block Mode by pressing
Ctrl+v
(unless you mapped the paste action to it, in which case you probably already know how to column insert) - select the column using the arrow keys
- press
Shift+i
(switching into Insert Mode) - type the text you want to insert (will be displayed only on the first line)
- press
esc
two times - ?????
- Profit!
In case you want to deleteΒ text, follow steps 1 through 3 and simply select all text you wish to delete, then press x
and you’re done!
thank you.
LikeLike
you’re welcome! π
LikeLike
Thank you! Learnt about shift+i in visual block mode!
I would encourage the use of hjkl keys for basic navigation using Vim to really start reaping the benefits of Vim.
Nonetheless, nice post!
LikeLike
you’re welcome π
… about using the hjkl keys, yeah, I know true Vim users use them all the time, but I never got to make the big jump from arrow keys… I’ll try again!
LikeLike
Nice little write up. Always nice to learn a new Vim trick. Thank you.
LikeLike
thanks, glad you found it interesting π
LikeLike
SHIFT! That’s what I was missing!
LikeLike
Thanks a lot.
LikeLike
Thanks a lot
LikeLike
Great, still works! Thank you. π
LikeLike