3

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.

RanRag
  • 48,359
  • 38
  • 114
  • 167
  • 1
    Vim's colorscheme, generally speaking, is global. You cannot have different colorschemes for different splits and so on. The best you can do on the subject is maybe have custom matches for different parts of syntax, but that really seems more trouble than it's worth. – Rook Aug 21 '12 at 20:28
  • @idigas: But there should be a functionality to have different colorscheme for Tabs atleast. – RanRag Aug 21 '12 at 20:32
  • Personally, one of the things I like about Vim is that you cannot customize it too much (like emacs; different fonts, colors, images), so it always looks familiar. – Rook Aug 21 '12 at 22:25
  • @ldigas: Sorry about the lowercase L. Next time I will keep in mind :) – RanRag Aug 22 '12 at 07:35

3 Answers3

3

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.

romainl
  • 186,200
  • 21
  • 280
  • 313
  • It is possible to have different colorschemes [according to filetype in vim](http://stackoverflow.com/a/6517520/776084) but yeah its not possible to have different colorschemes as OP wants. I would love this feature if added to Vim. – RanRag Aug 21 '12 at 20:46
  • Did you actually try that answer? I just did with an HTML file in a vsplit and a JS file in another: switching from one window to the other changes the colorscheme, yes, but for both windows. Which is pointless. – romainl Aug 21 '12 at 20:55
2

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.

MetalElf0
  • 1,087
  • 1
  • 8
  • 11
  • Sounds interesting based on your description. Since the project doesn't even have a README, it's very unfriendly for getting started and I imagine a lot of people (like me) will skip it. – Dennis Apr 16 '14 at 15:38
1

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.

Conner
  • 30,144
  • 8
  • 52
  • 73
  • Having multiple files open within the same Vim instance has certain benefits, such as being able to easily copy-paste across the files with Vim commands. How is that handled when using tmux or screen? – Dennis Apr 16 '14 at 15:41
  • As stated, it is a non-vim workaround that loses many of the benefits of having files loaded in the same vim instance. I suggested it as a workaround to meet the OP's requests. However, if you must copy and paste between tmux panes then you can read my answer on [this question](http://stackoverflow.com/questions/11042920/how-to-copy-and-paste-between-different-tmux-panes-running-vim-instances/11233604#11233604). – Conner Apr 16 '14 at 15:49
  • 2
    @Dennis, you have have it such that yanks in vim always copy to the system clipboard too, and then yy p will work across tmux vim instances. Very convenient, I find. Somewhat mitigates the problems of multiple tmux vim instances. Unfortunately it seems only to work on Linux (Mac version of Vim I think is too old). put in your vimrc set clipboard=unnamed – Thomas Browne Jul 24 '16 at 19:19