是否可以在 Vim 中以交互方式删除匹配的搜索模式? [英] Is it possible to interactively delete matching search pattern in Vim?

查看:20
本文介绍了是否可以在 Vim 中以交互方式删除匹配的搜索模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Vim 中查找一个短语.找到后,我想删除该短语的出现.循环遍历所有匹配项(通过 n)并逐个删除匹配项的最简单方法是什么(我不想一次删除所有匹配项).

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 n), and delete a match one by one (I do not want to delete all of them at once).

注意:我知道我可以删除一定数量的字符或一定数量的单词,但我想专门删除我搜索的匹配项.这可能吗?

Note: I know I can delete a certain number of characters or a number of words, but I want to specifically remove the match of my search. Is this possible?

推荐答案

http://vim.wikia.com/wiki/Search_and_replace

试试这个搜索和替换:

:%s/foo/bar/gc

将每个 'foo' 更改为 'bar',但首先要求确认.

按 y 或 n 更改或保留您的文本.

Press y or n to change or keep your text.

这篇关于是否可以在 Vim 中以交互方式删除匹配的搜索模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆