How to delete (not cut) in Vim?

前端 未结 6 514
别那么骄傲
别那么骄傲 2021-01-29 17:52

How can I delete a line without putting it into my default buffer?

Example:

line that will be copied.

line that I want to be substitued with the previou         


        
6条回答
  •  遥遥无期
    2021-01-29 18:44

    The black hole register "_ will do the trick, but there is a better solution:

    When you enter the line back with the p command you are pasting the contents of the (volatile) default register "", which has been overwritten by dd. But you still can paste from the (non volatile) yank register "0, which won't be overwritten by the delete command dd.

    So these are the commands you want to use as per your example:

    yy
    dd
    "0p
    

提交回复
热议问题