vim搜索 不区分大小写
By default, Vim/Vi’s search is case sensitive. However, if I want to search case insensitively, is there any method?
默认情况下 ,Vim / Vi的搜索区分大小写。 但是,如果我不区分大小写地搜索,有什么方法吗?
For example, I search fordot
, instead ofdog
, I also want to find out phases containingDog
,DOg
, etc.
例如,我搜索dot
而不是dog
,我还想找出包含Dog
,DOg
等的阶段。
There are several methods:
有几种方法:
1. Setting the search to be case insensitive in Vim
1.在Vim中将搜索设置为不区分大小写
:set ignorecase
To unset it:
要取消设置:
:set noignorecase
You can also put it to your .vimrc if you want the behavior to be the default one.
如果您希望将行为设为默认行为,也可以将其放入.vimrc。
2. You can also force a patten to be case insensitive or sensitive byc
orC
regardless the setting ofignorecase
.
2.您也可以强制patten不区分大小写,或者由c
或C
强制区分大小写,无论ignorecase
的设置如何。
For example, the search/dogc
is always case insensitive. And/dog/C
is always case sensitive.
例如,搜索/dogc
始终不区分大小写。 并且/dog/C
始终区分大小写。
3. Usesmartcase
3.使用smartcase
To enable it:
要启用它:
:set smartcase
If your search pattern is purely lowercase, it will search case insensitively.
If your search pattern contains uppercase characters, it will search case sensitively.
如果您的搜索模式是完全小写的,它将不区分大小写地搜索。
如果您的搜索模式包含大写字符,它将区分大小写。
Answered by anonymous.匿名回答。
翻译自: /how-to-make-case-insensitive-search-in-vim-vi/
vim搜索 不区分大小写