我可以使用 vim “star” 搜索 PHP 类成员和方法吗? 搜索?
vim * 星号/星号搜索 (:help star) 是一个很棒的功能,它可以让您找到光标所在单词的下一个出现位置。 不幸的是,它将美元前缀视为字符串的一部分,因此,如果我在类名中的“SearchTerm”上方按 *,它会在注释中找到“SearchTerm”,以及“$this->SearchTerm”,但不会找到“$ SearchTerm”:
class SearchTerm
{
/* do something with SearchTerm */
var $SearchTerm;
function DoStuff()
{
return $this->SearchTerm;
}
}
有没有办法告诉明星搜索忽略 $ 前缀?
只是为了扩展Haes答案:
我需要从iskeyword中删除$
:set iskeyword # iskeyword=@,48-57,_,192-255,$
:set iskeyword-=$ # remove the $ as an acceptable word character
The vim * star / asterisk search (:help star) is a great feature which lets you find the next occurrence of the word the cursor is over. Unfortunately it treats dollar-prefixes as part of the string, so if I press * while over the "SearchTerm" in the class name it finds "SearchTerm" in the comment, and "$this->SearchTerm", but not "$SearchTerm":
class SearchTerm
{
/* do something with SearchTerm */
var $SearchTerm;
function DoStuff()
{
return $this->SearchTerm;
}
}
Is there a way of telling star search to ignore the $-prefix?
Just to expand on Haes answer:
I needed to remove $ from iskeyword
:set iskeyword # iskeyword=@,48-57,_,192-255,$
:set iskeyword-=$ # remove the $ as an acceptable word character
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,在 Mac 上使用 vim 7.2,星号搜索完全按照您希望的方式工作。
编辑:检查您的“iskeyword”(:set iskeyword)设置为什么,因为星级搜索基于此选项来查找单词搜索词。
或者,您可以使用 'g*' (:help gstar) 来部分搜索光标所在的单词。
希望这能有所帮助。
Actually using vim 7.2 on Mac, star search exactly works as you would like it to do.
EDIT: Check what your 'iskeyword' (:set iskeyword) is set to because star search is based on this option to find the word search term.
Alternatively, you could could use 'g*' (:help gstar) to get a partial search for the word the cursor is over.
Hope this helps somehow.
您应该能够通过在 $ 前面放置反斜杠来转义它: \$
You should be able to escape the $ by placing a backslash before it: \$