Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get different colorschemes in Vim split window?

I prefer having different colorscheme for python and different for rest of the files.

So, what I did is added the below two lines in my vimrc:

"for python file
autocmd! BufEnter,BufNewFile *.py colo badwolf
autocmd! BufLeave *.py colo badwolf

"for rest of the files
colo molokai

Everything works fine when I open a new/pre-exixting file in vim using vim test.py but problem occur when I split my vim window into two using :split .scripts/test.sh.

What happens is after splitting the window when my cursor moves to the new-split window(.sh) I get molokai colorscheme for my python file and when I shift my cursor to my old window(.py) I get badwolf colorscheme in my .sh window. So, as you can see eventually I have the same colorscheme in my windows depending upon which file-type is in focus.

In case of Vim-Tab as soon as I open a file which has it's pre-defined colorscheme(via autocmd) all the tabs apply that colorscheme.

So, is there any way I can have different colorschemes in vim split windows and tabs.

like image 408
RanRag Avatar asked Dec 01 '25 09:12

RanRag


1 Answers

I don't think that it's possible to reliably have different colorschemes active at the same time.

In fact, I'm very surprised that you are able to load different colorschemes for different windows. :colorscheme molokai is a global command that works on every buffer.

like image 84
romainl Avatar answered Dec 04 '25 04:12

romainl