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
x
//this all lines are commented for debug --
int c = 10;
int a = 2;
uint8 d = 0;
uint8 n = 0;
I want to acheive:
JavaScript
//this all lines are commented for debug --
//this all lines are commented for debug -- int c = 10;
//this all lines are commented for debug -- int a = 2;
//this all lines are commented for debug -- uint8 d = 0;
uint8 n = 0;
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, I
nsert before, and paste the default register from insert mode (<c-r>"
). In other words:
JavaScript
y$<down><home><c-v>4<down>I<c-r>"<esc>
should do the trick.