如何在VIM中递归使用Global? [英] How can I recursively use the Global in VIM?

查看:95
本文介绍了如何在VIM中递归使用Global?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

:g-2-g/3/"中是否有问题,或者全局中的递归丢失了?我不明白该错误的原因:

Is something wrong in ":g-2-g/3/" or is the recursion in the global just missing? I can not understand a reason for the error:

E147:无法执行:全局递归

E147: Cannot do :global recursive

如何在VIM中进行递归全局搜索?

How can I get a recursive global search in VIM?

[Neil与运营商的初步建议\ | ]

g/1.*2\|2.*1/

缺点是组合会扩展为n个数字.对于三个数字,组合数为3! (= 6)即是

A disadvantage is that the combinations expand with n numbers. For three numbers, the number of combinations is 3! (=6) that is

g/1.*2.*3\|2.*1.*3\|3.*1.*2\|1.*3.*2\|2.*3.*1\|3.*2.*1/ 

对于n个数字,组合数为n!.

For n numbers, the number of combinations is n!.

[与运营商的解决方案\&]

Brian Carper和Neil Butterworth提出了解决方案.非常感谢他们!

Brian Carper and Neil Butterworth figured out the solution. Great thanks for them!

g/.*1\&.*2\&.*3/

它是针对整行的:

g/.*1\&.*2\&.*3\&.*/

推荐答案

新信息:这就是您想要的-"\&"顺序是和"运算符:

New info: This does what you want - the "\&" sequence is the "and" operator:

g/.*1\&.*2\&.*3/

Brian Carper的解释(请参阅评论,再次感谢):

Brian Carper's (see comments, and thanks again) explanation:

/1\&2/无效,因为两者 分支机构必须同时匹配 位置"./.*1\&.*2/进行匹配 将自己锚定在生产线的最前面 然后根据需要扩展 查找号码

/1\&2/ wouldn't work because both branches need to match "at the same position". /.*1\&.*2/ let the match anchor itself at the front of the line and then expand however much it needs to to find the numbers

这篇关于如何在VIM中递归使用Global?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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