Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我最近切换到 vim,并了解到您可以使用 AG 执行搜索。
我经常做
:Ag foo
并且,在快速列表窗口中
:cdo s/foo/bar/g |update
但是,它会打开缓冲区中的所有文件。我怎样才能不让 Vim 打开缓冲区,而是让 vim 替换单词?
使用 :cfdo 并关闭您打开和修改的所有缓冲区:
:cfdo :bd
所以工作流程如下:
:Ag foo :cdo %s/bar/baz/g | update :cfdo :bd
:cdo 遍历 quickfix 列表中的每个条目, :cfdo 遍历列表中引用的每个文件。