我可以用vim“ star”搜索PHP类成员和方法吗?搜索? [英] Can I search for PHP class members and methods with vim "star" search?
问题描述
vim *星号/星号搜索(:help star)是一项很棒的功能,可让您找到光标移到该词下的下一个匹配项。不幸的是,它将美元前缀视为字符串的一部分,因此,如果在类名称中的 SearchTerm上方按*时,它将在注释中找到 SearchTerm,并在 $ this-> SearchTerm中找到,但不会在 $ SearchTerm中找到:
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;
}
}
有没有办法告诉恒星搜索忽略$ -prefix?
Is there a way of telling star search to ignore the $-prefix?
只需在上扩展即可答案:
Just to expand on Haes answer:
我需要从iskeyword中删除$
I needed to remove $ from iskeyword
:set iskeyword # iskeyword=@,48-57,_,192-255,$
:set iskeyword-=$ # remove the $ as an acceptable word character
推荐答案
实际上在Mac上使用vim 7.2,星号搜索完全可以正常工作
Actually using vim 7.2 on Mac, star search exactly works as you would like it to do.
编辑:检查您的'iskeyword'(:set iskeyword)设置为什么,因为星号搜索基于此选项来查找单词搜索词。
Check what your 'iskeyword' (:set iskeyword) is set to because star search is based on this option to find the word search term.
或者,您可以使用'g *'(:help gstar)来部分搜索光标位于上方的单词。
Alternatively, you could could use 'g*' (:help gstar) to get a partial search for the word the cursor is over.
希望这会有所帮助。
这篇关于我可以用vim“ star”搜索PHP类成员和方法吗?搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!