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

查看:325
本文介绍了如何在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 / copyright\c 甚至 / copyri\cght

要做反演(区分大小写 匹配),请改用 \C (大写C)。

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

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

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