Is it possible to interactively delete matching search pattern in Vim?

前端 未结 4 1333
暗喜
暗喜 2021-01-30 04:01

There is a phrase that I want to look for in Vim. When found, I want to delete that occurrence of the phrase. What is the easiest way to cycle through all the occurrences (via <

4条回答
  •  有刺的猬
    2021-01-30 04:31

    The best way is probably to use:

    :%s/phrase//gc
    

    c asks for confirmation before each deletion. g allows multiple replacements to occur on the same line.

    You can also just search using /phrase, select the next match with gn, and delete it with d.

提交回复
热议问题