如何在 Vim 中进行不区分大小写的搜索 [英] How to do case insensitive search in Vim

查看:21
本文介绍了如何在 Vim 中进行不区分大小写的搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在文件中搜索大写单词,例如 COPYRIGHT.我尝试执行如下搜索:

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

/copyright/i    # Doesn't work

但它不起作用.我知道在 Perl 中,如果我将 i 标志放入正则表达式,它将把正则表达式变成不区分大小写的正则表达式.似乎 Vim 有自己的方式来表示不区分大小写的正则表达式.

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. It seems that Vim has its own way to indicate a case-insensitive regex.

推荐答案

您可以在模式中的任何位置使用 c 转义序列.例如:

You can use the c escape sequence anywhere in the pattern. For example:

/ccopyright/copyrightc 甚至 /copyricght

要进行相反的操作(大小写敏感匹配),请改用 C(大写 C).

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

这篇关于如何在 Vim 中进行不区分大小写的搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆