Pasting inside delimiters without using visual selection

前端 未结 5 917
轻奢々
轻奢々 2020-12-21 18:09

In Vim, let\'s say I want to replace the contents of one String with the content of another.

Original input

var1 = \"January\"
var2          


        
5条回答
  •  独厮守ぢ
    2020-12-21 18:40

    There are many ways of doing this however using visual mode is the easiest.

    • Use the black hole register to delete the content then paste. e.g. "_di"P
    • Do ci"0. inserts the contents of a register
    • Simply paste and then move over a character and delete the old text. e.g pldt"

    However visual mode still has my vote. I find that the concerns most people have is that using visual mode + paste is that the default register is swap with the selected text and it doesn't repeat well. Good news everybody! The 0 register always stores the last yank. The bad news is visual mode still doesn't repeat well. Take a look at this vimcast episode, Pasting from Visual mode, for more information. It mentions a few plugin that help with this.

提交回复
热议问题