How to edit multiple locations simultaneously in Vim

后端 未结 6 804
悲&欢浪女
悲&欢浪女 2021-02-04 14:06

In certain text editors, like E, I can select multiple locations and, as I type, all the selected locations get replaced with the characters I am typing.

For example i

6条回答
  •  死守一世寂寞
    2021-02-04 14:48

    Here's how I would probably edit those particular lines (there are many ways):

    /""
    aText to replace...
    n
    .
    

    First, search for the empty quotes to put the cursor on the first one. Using the "a" (append) command, type the new text to put inside the quotes. When you're done, use "n" (next) to go to the next instance, and "." (repeat last command) to insert the same text again. Repeat the "n ." as many times as necessary.

    This method takes less up-front preparation and lets you get started right away without identifying ahead of time all the locations where you might want to add the text.

提交回复
热议问题