本文介绍了我可以在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 ,您会看到有四个级别(非常魔术,魔术,魔术和非常魔术),但是只能在全局设置两个中心的级别(默认设置是魔术,并使用:set 命令)您只能在魔术和魔法之间切换);以 \v 开始您的RE,以使其其余所有内容非常神奇(除'0'-'9','a'-'以外的所有ASCII字符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中打开扩展的正则表达式支持吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-17 00:05