我可以让vim接受\b而不是\<和\&gt ;? [英] Can I make vim accept \b rather than just \< and \>?

查看:188
本文介绍了我可以让vim接受\b而不是\<和\&gt ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚读过这篇文章:

In Vim, how do you search for a word boundary character, like the \b in regexp?

,我想知道-我不能让vim也以某种方式识别 \b 吗?

and I was wondering - can't I make vim recognize \b also, somehow?

推荐答案

由于Vim的正则表达式将 \b 视为退格字符,因此没有机会重新定义该简写结构,您只能使其与可以在 Perl兼容的正则表达式 Vim Tips Wiki。

Since Vim's regex flavor treats \b as a backspace character, and there is no chance re-defining this shorthand construct, you can only make it work with a PCRE regex engine that can be used with Vim the way described at Perl compatible regular expressions Vim Tips Wiki.

这是该页面的描述:



  1. :ver 验证 + perl + perl / dyn 会被编译。

Ins高大的Perl(如有必要)。在Windows上,ActivePerl是标准配置,但如果不需要任何其他perl模块,则可以使用任何无依赖项的perl58.dll。如果您不想完整安装perl,请从 Strawberry Perl 5.8.x 中将perl58.dll复制到文件夹vim.exe可以使用,下面的命令将起作用。

Install Perl if necessary. On Windows, ActivePerl is standard but any dependency-free perl58.dll will work if you don't need any other perl modules. If you don't want a full install of perl, copy perl58.dll from Strawberry Perl 5.8.x into the folder vim.exe lives and the commands below will work.

键入:perldo s / searchme / replaceme / g

注意: + perl / dyn

Note: +perl/dyn doesn't seem to be necessary.

或者如果编译了Ruby,也可以使用Ruby的正则表达式来识别 \b 作为单词边界:

Or if Ruby is compiled in, Ruby's regex can be used, too to recognize \b as a word boundary:


或者如果您编译了ruby(请查找 +红宝石:ver 输出中)

等效于 s / pattern / replacement / g

:rubydo gsub / pattern /,'replacement'

这篇关于我可以让vim接受\b而不是\<和\&gt ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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