gpt4 book ai didi

vim - 如何在 VIM 中递归使用 Global?

转载 作者:行者123 更新时间:2023-12-04 21:15:17 24 4
gpt4 key购买 nike

":g-2-g/3/"有问题还是全局递归丢失了?我无法理解错误的原因:

E147: Cannot do :global recursive

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

[尼尔对运营商的初步建议\| ]

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

缺点是组合扩展了 n 个数字。三个数,组合数为3! (=6) 即

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

对于n个数,组合数为n!。

[运算符\&的解决方案]

Brian Carper 和 Neil Butterworth 找到了解决方案。非常感谢他们!

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

它是针对整行的:

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

最佳答案

新信息:这就是您想要的 - “\&”序列是“和”运算符:

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

Brian Carper(查看评论,再次感谢)的解释:

/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 - 如何在 VIM 中递归使用 Global?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/737078/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com