vim * star/asterisk search (: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
最佳答案
实际上在 Mac 上使用 vim 7.2,星号搜索完全可以按照您的意愿工作。
编辑:检查你的 'iskeyword' (:set iskeyword) 设置的是什么,因为星号搜索是基于这个选项来查找单词搜索词的。
或者,您可以使用 'g*' (:help gstar) 来部分搜索光标所在的单词。
希望这能有所帮助。
关于php - 我可以使用 vim "star"搜索来搜索 PHP 类成员和方法吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/299114/