怎样在vi打开的多个文件中全部搜索和替换?
例如,我用vi同时编辑3个文件:vim 1.cpp 2.cpp 3.cpp
(1)我想搜索这3个文件当中叫做"main"的字符串。我不想用:vimgrep,因为这会搜索当前目录下面所有的文件。我只想搜索我打开的这个3个文件,并且在Quickfix窗口显示结果。如何做到?
(2)我想把这3个文件当中所有叫做"hello"的文本都替换成"world"。能否一个命令做到?
回复 1# cdsfiui
1.
:vimgrep main ## | :copen | :cc
http://vim.wikia.com/wiki/Search ... to_list_occurrences
http://vimcasts.org/episodes/search-multiple-files-with-vimgrep/
2.
:argdo %s/main/world/g | update
http://vim.wikia.com/wiki/Run_a_command_in_multiple_buffers
页:
[1]