How to block (column?) paste in vim
how can i paste something on multiple lines?
i'm trying to achieve the same as: In an existing text, I can <C-v>jjjjj<S-I>HelloWorld<CR> to have HelloWorld inserted in 5-rows
but instead of typing HelloWorld I'd like to get the text from a register. 开发者_StackOverflowi want to first yank HelloWorld then insert it in 5 lines.
When you are in insert mode, you can press Ctrl-R
followed by the letter for the buffer you wish to paste. Then just press Escape as usual and it will be block inserted as normal.
Let's say you have the following in a vim buffer:
1| Do the dishes
2| Get milk
3| Take out the trash
and you want to insert [ ]
at the start of each line, so that it becomes:
1| [ ] Do the dishes
2| [ ] Get milk
3| [ ] Take out the trash
- go to column one of row one
- press
CTRL + V
(block select) - press
j
two times (to row three). now the first column of lines one, two, and three are selected - press
I
(shift + i - capital "i") - this is "block insert mode" - type
[ ]
- press
esc
(escape) - text will be inserted on each row
You could use a macro to do this, like qq0Pjq4@q
qq
starts a macro with the name q
0
goes to the beginning of the line and P
pastes the yanked content before the cursor
j
goes down one line and q
ends the macro
4@q
repeats the q
macro 4 times
精彩评论