Pasting inside delimiters without using visual selection

前端 未结 5 922
轻奢々
轻奢々 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:49

    It's not particularly pretty, but here goes:

    1. Go to line one and yi"
    2. Move to line two
    3. Type "_di"hp

    That deletes what's in the quotes, but sends the deleted text to a black hole register. Then it moves the cursor back one, and pastes what you yanked from line one.

    All in all, you can start on the first line and type yi"j"_di"hp. Why is it that people find vim intimidating? ;)

    Alternatively, yank the first line as normal, then drop to line two and type ci" and select the previously yanked text from the menu.

提交回复
热议问题