views:

232

answers:

2

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
A: 

You should be able to escape the $ by placing a backslash before it: \$

localshred
thanks, but I'm not typing a search string. I'm trying to use the star search - ie just step to the next occurrence by typing *
Ken
Sorry, guess I misunderstood
localshred
+2  A: 

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.

Haes
Can you show me your working iskeyword settings?
Ken
mine is set to iskeyword=@,48-57,_,192-225
Haes
sweet. Thank you!
Ken