Search code examples
vim

How do you get Separate Color-schemes for Gvim and Vim?


I have used vim for a while now, but after my friend introduced me to gvim, I'm trying to use it now. I have basic vimrc settings of :

set guifont=Monaco:h17
colorscheme zellner
set number
syntax on

I noticed that the settings were applied to my gvim. I want a different colorscheme for gvim and vim as I usually open the files I'll read quickly with vim or vi, and use gvim as my main code editor.

I heard people talk about the .gvimrc file, but I don't have it where my .bashrc, .zshrc, and .vimrc are.

How do I have separate colorschemes for gvim and vim?


Solution

  • Vim doesn't create either ~/.vimrc or ~/.gvimrc for you so you have to create them on your own.

    You can either create the missing file in your shell, then edit in Vim:

    $ touch ~/.gvimrc
    $ vim ~/.gvimrc
    <some editing>
    :wq
    

    or do everything from Vim:

    :e ~/.gvimrc
    <some editing>
    :wq
    

    Note: ~/.vimrc is still sourced whether you have a ~/.gvimrc or not so your gvimrc can be kept lightweight by only having GUI-specific options and overrides. In your case:

    " ~/.vimrc
    colorscheme zellner
    set number
    syntax on
    
    " ~/.gvimrc
    set guifont=Monaco:h17
    colorscheme slate