In Vim, I want to use a different colorscheme for each file type.
e.g. I want to use desert256
colorscheme for Python & JavaScript files, and use jellybeans
colorscheme for HTML & CSS files.
I've tried putting the following code in my .vimrc
, but the colorscheme change happens only when changing buffers for the first time.
i.e. If I open a new Python file, Python's colorscheme is used, and when I open a new CSS *buffer*, indeed the colorscheme changes to CSS's colorscheme. However, Changing back to Python's buffer does not change the colorscheme back.
I've used autocmd WinEnter
to try and make this rule happen when changing windows (and buffers), but it doesn't help:
autocmd WinEnter,FileType python,javascript colorscheme desert256
autocmd WinEnter,FileType *,html,css colorscheme jellybeans " This includes default filetype colorscheme.
How can I fix this? In addition, a bonus would be to not change a colorscheme when not needed - i.e. Changing from a Python to a JavaScript buffer won't change the colorscheme to "itself".
EDIT:
If anyone's interested, here is my .vimrc
repo in github.com. I'll update it with the solution I find here once given.
question from:
https://stackoverflow.com/questions/5171184/how-to-set-a-different-colorscheme-for-each-file-type-in-vim 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…