Cut and paste multiple lines in vim

前端 未结 5 1335
旧时难觅i
旧时难觅i 2021-01-30 03:03

I\'m running vim 7.3 on a Mac 10.7.2 and I\'m having some trouble cutting and pasting several lines.

On my old Linux setup (which was stolen so I don\'t know versions)

5条回答
  •  悲&欢浪女
    2021-01-30 03:49

    I agree with @Ben S. that this is the preferred way to accomplish this but if you are just looking to replicate your old behavior you can remap dd to append to a specified register, and then map p to paste from that register and clear it.
    This will have the disadvantage of causing p to only work with things deleted using dd (using d} to delete to the end of the paragraph would not put the text in the correct register to be pasted later).

    Add the following to your vimrc

    noremap dd "Ddd             "Appends the contents of the current line into register d
    noremap p "dp:let @d="" "Pastes from register d and then clears it out
    

    if you don't want pasting to clear out the contents of the register

    noremap p "dp               "Paste from register d 
    

    but this will cause that register to grow without ever clearing it out

提交回复
热议问题