Can I search for PHP class members and methods using vim "star" search?

Search vim * star / asterisk (: help star) is a great feature that allows you to find the next occurrence of a word over which the cursor is over. Unfortunately, it treats dollar prefixes as part of the string, so if I press * and above "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 to tell star search to ignore $ -prefix?

Just to deploy Haes answer:

I needed to remove $ from iskeyword

 :set iskeyword # iskeyword=@ ,48-57,_,192-255,$ :set iskeyword-=$ # remove the $ as an acceptable word character 
+3
source share
2 answers

Actually, using vim 7.2 on a Mac, searching for stars exactly works the way you would like to do it.

EDIT: check what is installed in your "iskeyword" (: set iskeyword), because star search is based on this option to find the search word.

Alternatively, you could use "g *" (: help gstar) to get a partial search for the word over which the cursor ended.

Hope this helps somehow.

+4
source

You must get away from $ by preceding it with a backslash: \ $

-1
source

All Articles