RanRag
RanRag

Reputation: 49577

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.

Upvotes: 3

Views: 4009

Answers (3)

MetalElf0
MetalElf0

Reputation: 1107

It's not exactly what you want, but this tab page color scheme vim plugin lets you assign a different colorscheme for each tab with :Tcolorscheme.

Upvotes: 2

Conner
Conner

Reputation: 31070

This is really more of a frowned upon, non-vim workaround, but you could use tmux or screen panes to separate two instances of vim with differing colorschemes.

Upvotes: 1

romainl
romainl

Reputation: 196751

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.

Upvotes: 3

Related Questions