为什么 VIM 有自己的正则表达式语法? [英] Why does VIM have its own regex syntax?

查看:26
本文介绍了为什么 VIM 有自己的正则表达式语法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么你必须让你的正则表达式非常神奇",这样你就不必逃避捕获引号?如果您将环境设置为非常神奇,那么您就是非标准的并且可能存在合规性问题.我只是想知道为什么 vim 使用与 perl 不同的正则表达式语法?

Why do you have to make your regex "very magic" so that you don't have to escape your capture quotes? And if you set your environment to very magic, you are non-standard and may have compliance issues. I am just wondering why vim uses a different regex syntax than say, perl?

推荐答案

大多数 vi(以及因此的 vim)功能都源自 ed.vi 和 ed 都比 perl 早至少一两年.一个更好的问题可能是为什么 Perl 不使用与 vi 相同的正则表达式语法?".

Most vi (and therefore vim) features were derived from ed. vi and ed both predate perl by at least a decade or two. A better question might be "why doesn't Perl use the same regex syntax as vi?".

当然,人们也可能会争辩说,人们希望在文本编辑器中编写以执行常见任务的正则表达式类型可能与您希望在编程语言中编写的正则表达式类型大不相同.

Of course, one could also argue that the kinds of regular expressions that one would wish to write inside a text editor to perform common tasks are probably rather different to those you might wish to write inside a programming language.

这篇关于为什么 VIM 有自己的正则表达式语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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