我可以在 Vim 中打开扩展的正则表达式支持吗? [英] Can I turn on extended regular expressions support in Vim?

查看:29
本文介绍了我可以在 Vim 中打开扩展的正则表达式支持吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

扩展正则表达式的字符是无价的;有没有办法打开它们,这样我就不必在我的 Vim 正则表达式中转义它们,就像我可以传递给 grep(1) 的 -E 标志一样?

The characters for extended regular expressions are invaluable; is there a way to turn them on so that I don't have to escape them in my Vim regex, much like the -E flag I can pass to grep(1)?

推荐答案

在 vim 中执行 :help magic 你会看到有四个级别(very magic、magic、nomagic 和 very nomagic) 但只有两个中心的可以全局设置(默认是magic,使用:set 命令你只能在magic 和nomagic 之间切换);用 v 开始你的 RE,让它的其余部分非常神奇"(所有 ASCII 字符,除了 '0'-'9'、'a'-'z'、'A'-'Z' 和 '_' 具有特殊含义") -- 但这仅适用于那个特定的 RE!-)

Do :help magic in vim and you'll see there are four levels (very magic, magic, nomagic, and very nomagic) but only the two central ones can be set globally (the default is magic, and with :set commands you can only toggle between magic and nomagic); start your RE with v to make all the rest of it "very magic" ("all ASCII characters except '0'-'9', 'a'-'z', 'A'-'Z' and '_' have a special meaning") -- but that applies only to that one specific RE!-)

这篇关于我可以在 Vim 中打开扩展的正则表达式支持吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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