我不知道如何转换/相当于 Neovim 上的负向先行搜索。
&(?!(?:apos|quot|[gl]t|amp);|#)
当我尝试银色搜索时,它正在工作。我想搜索,但只能使用
/
搜索单个文件
你的问题很有趣,我实际上经常遇到麻烦 Vim 或其他工具中的正则表达式语法 使用 PCRE 或通用语法!
谷歌搜索一下,我发现了 这篇关于 Vim 中的环视的文章。
如您所见,这只是语法问题!
负向前瞻应写为
(?!amp;)
,例如 \(amp;\)\@!
。
这会导致这样的事情:
&\(\(\w\{2,6\}\|#\d\{1,6\}\|#[xX][0-9a-fA-F]\{1,6\}\);\)\@!
我将
&
、&apos
与 PCRE 中的 &\w{2,6};
相匹配,变成
&\w\{2,6\};
在 Vim 的语法中。
在此 XML 上进行了测试:
<note>
<author>Jani</author>
<heading>Reminder</heading>
<summary>Glasses & sunscreen</summary>
<body>
Don't forget to pack your glasses & sunscreen to go to
the beach tomorrow!
If you forget your glasses 😎 -> you'll damage your retina.
If you don't put some sunscreen on -> you'll probably get sun burnt 🌞.
Now, the problem is to match the ampersand in "H&M" 😬!
< = <
> = >
& = &
= non-breaking space
¡ = ¡
¢ = ¢
£ = £
¤ = ¤
¥ = ¥
¦ = ¦
§ = §
¨ = ¨
© = ©
ª = ª
« = «
¬ = ¬
­ =
® = ®
¯ = ¯
° = °
± = ±
² = ²
³ = ³
´ = ´
µ = µ
¶ = ¶
¸ = ¸
¹ = ¹
º = º
» = »
¼ = ¼
½ = ½
¾ = ¾
¿ = ¿
× = ×
÷ = ÷
</body>
</note>
在 Vim 中,你必须转义括号、大括号和竖线,但是 不是方括号!这显然不太可读。也许 有一些扩展使其更易于使用。刚刚用谷歌搜索 稍微了解了一下,发现Vim 中兼容 Perl 的正则表达式。