Skip to content
Advertisement

vim: how to copy a word in vim visual mode, but paste it in visual block mode?

I want to copy a simple text using visual mode of vim, but then paste it into multiple lines using block mode. How can I achieve this.

example:

JavaScript

I want to acheive:

JavaScript

I tried by highlighting the comment section (using v right_arrow combination), and yanked . Now I want this yanked result to be pasted infront of all intended lines. This need not be at beginning of the line, I cant use I option to manually type the comment.

Advertisement

Answer

I would yank the first line, then go in block visual mode on the first column <C-V> and select several lines, Insert before, and paste the default register from insert mode (<c-r>"). In other words:

JavaScript

should do the trick.

Advertisement