On 11/11/08 00:05, Sashan Govender wrote:
> Hi
>
> I'd like to add something to my .vimrc to change the colorscheme
> applied depending on the whether I'm running a gvim instance or vim in
> a terminal.
>
> Thanks
>
>

Method I (for Windows, or for Unix users who never use the ":gui" 
command manually to start the GUI from an already-running Console Vim):

        if has('gui_running')
                colorscheme foo
        else
                colorscheme bar
        endif

or (equivalent but using a different construct)

        exe "colorscheme" (has('gui_running')?"foo":"bar")

Method II (for Unix users who sometimes start the GUI by using the :gui 
command after using Console Vim for some time):

Variant IIa
        colorscheme bar
        au GUIEnter * colorscheme foo
Variant IIb
        " in .vimrc
        colorscheme bar
        " in .gvimrc
        colorscheme foo

You may want to add additional if wrappers:
- "if has('autocmd') ... endif" to avoid creating an autocommand if the 
current Vim version hasn't got +autocmd compiled-in
- "if has('syntax') ... endif" to avoid setting a colorscheme in 
versions without +syntax
- "if has('gui') ... endif" to avoid using the GUIEnter autocommand in a 
version which cannot be used as a GUI.


Best regards,
Tony.
-- 
MAN:     You don't frighten us, English pig-dog!  Go and boil your bottoms,
          son of a silly person.  I blow my nose on you, so-called 
Arthur-king,
          you and your silly English K...kaniggets.
    He puts hands to his ears and blows a raspberry.
          "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to