5

Can anyone tell me how to change the Python colors in Vim. I've seen the following syntax but I'm not sure how to make it permanent.

:hi pythonComment ctermfg=2 gui=italic guifg=#408010
ib.
  • 27,830
  • 11
  • 80
  • 100
felix001
  • 15,341
  • 32
  • 94
  • 121

3 Answers3

3

You can just put it in your .vimrc file. (Without the leading :, as favoretti mentioned.)

JAB
  • 20,783
  • 6
  • 71
  • 80
  • 1
    Without the leading ":" then. – favoretti Aug 08 '12 at 11:32
  • Yeah, I haven't actually used vim much myself so I was double-checking the format just now (using http://stackoverflow.com/questions/164847/what-is-in-your-vimrc, in fact) and noticed that. – JAB Aug 08 '12 at 11:34
  • 1
    Does this work? I would expect this vimrc setting to be overwritten once the colour scheme is set. – Prince Goulash Aug 08 '12 at 11:49
3

The vimrc file is loaded before any plugins, so I would expect it to be overwritten later in the initialisation process, or at least when the colourscheme is changed. The best approach would be to associate the new hi command with the ColorScheme event, so that it is triggered automatically when the colour scheme is changed.

To do so, put this in your vimrc:

autocmd ColorScheme * hi pythonComment ctermfg=2 gui=italic guifg=#408010
Prince Goulash
  • 15,295
  • 2
  • 46
  • 47
0

Syntax highlighting really belongs in the colorscheme file, not in .vimrc or .gvimrc. Find your current colorscheme under ~/.vim/colors and add your statement to that file without the leading :.

Jonathan
  • 123
  • 2
  • 9