Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
465 views
in Technique[技术] by (71.8m points)

search - 如何在Vim中进行不区分大小写的搜索(How to do case insensitive search in Vim)

I'd like to search for an upper case word, for example COPYRIGHT in a file.

(我想搜索大写单词,例如文件中的COPYRIGHT。)

I tried performing a search like:

(我尝试过执行搜索:)

/copyright/i    # Doesn't work

but it doesn't work.

(但它不起作用。)

I know that in Perl, if I give the i flag into a regex it will turn the regex into a case-insensitive regex.

(我知道在Perl中,如果我将i标志放入正则表达式,它会将正则表达式转换为不区分大小写的正则表达式。)

It seems that Vim has its own way to indicate a case-insensitive regex.

(似乎Vim有自己的方式来表示不区分大小写的正则表达式。)

  ask by Haiyuan Zhang translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to use the \c escape sequence.

(您需要使用\c转义序列。)

So:

(所以:)

/\ccopyright

To do the inverse (case sensitive matching), use \C instead.

(要进行反向(区分大小写的匹配),请使用\C代替。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...