Search code examples
vimcopy-pasteneovim

Neovim block paste


I've read some posts about copying and inserting via block/visual selection but I think something is wrong on my side. If I copy the word hello, then move the cursor onto the second " of the next line, block select all " and press shift+p in order to paste hello between the ", it pasts hello on each line but removes the second ".

origin:

"hello"
""
""
""

result:

"hello"
"hello
"hello
"hello

Solution

  • I think you are doing it the wrong way in visual block mode. If I understand you correctly, you want to insert here inside the quotes in line 2, 3, 4, right?

    This is the correct way:

    1. Copy the word here.
    2. Go to first " in line 2 and press Ctrl-V to start visual block mode.
    3. Press 2j to also select line 3 and line 4.
    4. Press A (note, this is capital A!)
    5. Now we are in insert mode, press Ctrl-R, followed by ", then press <ESC> to leave insert mode.

    After these steps, you should get what you want. For more info, open neovim and try read :h v_b_A.