Search code examples
vimsyntax-highlightingvivim-syntax-highlighting

prevent vi from partially highlighting variable names that contain python keywords


I'm having trouble with vi's lexical highlighting on variables that contain builtins or keywords. For instance, a python variable like missions_in_window will have partial highlighting on the word "in" while the rest of the variable stays a default color. See the example image below.

Is it possible to prevent this highlighting? This is just a pet peeve, but it's distracting to the point that I'll change a variable's name to avoid the issue. My .vimrc is here if that is helpful.

vi partial keyword highlighting


Solution

  • When you've :set iskeyword-=_, Vim will treat missions_in_window as three separate keywords: missions, in, window, and the in is highlighted by the Python syntax script.

    The solution is simple: Don't do that. To navigate through and edit fragments of those variables, you can use my camelcasemotion plugin.