1.Vim Search and replace
http://vim.wikia.com/wiki/Search_and_replace
- Find each occurrence of 'foo' (in all lines), and replace it with 'bar'.
:%s/foo/bar/g
- Find each occurrence of 'foo' (in the current line only), and replace it with 'bar'.
:s/foo/bar/g
- Change each 'foo' to 'bar', but ask for confirmation first.
:%s/foo/bar/gc
- Change only whole words exactly matching 'foo' to 'bar'; ask for confirmation.
:%s/\<foo\>/bar/gc
- Change each 'foo' (case insensitive) to 'bar'; ask for confirmation.
-
This may be wanted after using
:set noignorecaseto make searches case sensitive (the default).
:%s/foo/bar/gci
- Change each 'foo' (case sensitive) to 'bar'; ask for confirmation.
-
This may be wanted after using
:set ignorecaseto make searches case insensitive.
:%s/foo/bar/gcI
本文详细介绍了Vim编辑器中的搜索与替换功能,包括在整个文件和当前行中进行替换的操作命令,以及如何进行确认提示、全词匹配和大小写敏感等高级替换选项。
5万+

被折叠的 条评论
为什么被折叠?



