如何使用vim中的文件中搜索字符串`**`的所有出现?
如何使用vim sike ** kwargs
在文件中搜索**
,当我使用/**
时,它突出显示了整个文件。
How to search for **
in a file using vim like **kwargs
, when I use a /**
it highlights the entire file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
*
是一个元字符,需要逃脱成为常规角色:VIM将其称为“魔术”:如果模式为“魔术”,则需要逃脱元观念,如果它是“ nomagic”,您没有(这有点过分简化,请参见
:help Magic
)。因此,您可以用
\ m
甚至“非常名义”将VIM强制将模式视为“ nomagic”,并使用\ v
:它无济于事,此处,但是……
关于为什么
/**
突出显示了整个缓冲区,可以在下找到提示:help/star/star
:*
匹配缓冲区中的星星,*
匹配零或以上原子的零或更多原子,因此,本质上是每个字符。*
is a meta-character that needs to be escaped to become a regular character:Vim refers to this as "magic": if the pattern is "magic", you need to escape meta-characters, if it is "nomagic", you don't (this is a bit over-simplified, see
:help magic
).Therefore, you can force Vim to treat the pattern as "nomagic" with
\M
or even "very nomagic", with\V
:Which doesn't help much, here, but well…
As for why
/**
highlights the whole buffer, a hint can be found under:help /star
:*
matches (at least some of) the stars in your buffer,*
matches zero or more of the preceding atom, as many as possible, so, essentially, every character.您必须逃脱 *符号,尝试
在下面的文本上,我添加了额外的空间,以便更易于阅读
You have to escape the * symbol, try
On the text below I added extra spaces to be easier to read