When I press * on a variable name such as hello, vim will highlight names like this->hello or this.hello, but not _hello.

It is a very strange behavior because I can highlight all hello's by /hello. But for some reason, * behaves differently from /.

Is there any way to make * to highlight all hello's?


When you use the * key it effectively searches for


The surrounding \<...\> means that it only looks for whole words. So bhello would not be found, in your example.

You can modify the characters that are counted as non-keyword values by set iskeyword

The default (in my version) is


So we can ensure _ is not part of this:

set iskeyword=@,48-57,192-255,^_

This can be put in your .vimrc file or run with a :set inside vim

  • 3
    iskeyword is normally set from fptlugins, and some syntax files also mess with it. This is obvious if you think about it for a moment, since it has to be in synch with the current filetype. Consequently, (1) there is no "one true iskeyword" but many, and (2) if you ever want to override it you have to do it from an after/ftplugin, otherwise your override will be ignored. – Satō Katsura Sep 10 '16 at 20:51
  • 1
    Or run :set isk-=_ – Stéphane Chazelas Sep 12 '16 at 13:53

You can use the g* command instead of *:

g*          Like "*", but don't put "\<" and "\>" around the word.
            This makes the search also find matches that are not a
            whole word.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.