Something changed on my system and now VIM screws up syntax highlighting of commented lines.

This makes having 'debug' lines very difficult as it looks like the line is still active based on the coloring!

Behold: Screenshot of Improper VIM python comment highlighting

In particular, look at the second print statement. From a quick glance at the color of that line, you'd think it wasn't commented out at all!

Does anyone know how to fix this?

Output of vim -Nu NONE -c 'filetype on|set filetype=python|syntax on' hello_world.py followed by :scriptnames

  1: /usr/share/vim/vim74/filetype.vim
  2: /usr/share/vim/vimfiles/ftdetect/stp.vim
  3: /usr/share/vim/vim74/syntax/syntax.vim
  4: /usr/share/vim/vim74/syntax/synload.vim
  5: /usr/share/vim/vim74/syntax/syncolor.vim
  6: ~/.vim/syntax/python.vim
  7: /usr/share/vim/vim74/syntax/python.vim
  • 2
    What plugins do you have installed? What happens if you run vim -Nu NONE -c 'filetype on|set filetype=python|syntax on' hello_world.py? – muru Nov 22 '15 at 21:31
  • BTW, vim's default of dark-blue on black for comments can be unreadable. try changing it to cyan instead with hi Comment term=bold ctermfg=DarkCyan guifg=Blue in your ~/.vimrc – cas Nov 22 '15 at 23:03
  • @muru, no change running the command you suggest. – Emiller Nov 23 '15 at 3:52
  • 1
    Ok, still using that command, after starting, run :scriptnames, and add the list of files to your question. – muru Nov 23 '15 at 3:54
  • 2
    Try removing your ~/.vim/syntax/python.vim and load file again. – cuonglm Nov 23 '15 at 8:56

I think your file-type setting have gone some how wrong. At least in my VIM, python is in minor letter.

what happen when you set the file type manually?

:setf python
| improve this answer | |
  • No change it looks like. – Emiller Nov 23 '15 at 3:48

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.