You are not logged in.

#1 2013-01-19 13:36:44

starfry
Member
From: Surrey, UK
Registered: 2010-08-18
Posts: 170

[SOLVED] how to check current colorscheme in vimrc?

I am trying to write a function in vimrc that behaves differently based on colorscheme but I can't work out how to test the value of :colorscheme in vimrc. I'm trying to do this:

    if (&colorscheme == 'myscheme')
        ...something...
    else
        ...something else...
    endif

But colorscheme is isn't a variable so the usual way of checking &variable doesn't work. Thanks for heping...

Last edited by starfry (2013-01-19 20:12:21)

Offline

#2 2013-01-19 13:47:56

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,794
Website

Re: [SOLVED] how to check current colorscheme in vimrc?

The help page says (correctly) that "color[scheme]" outputs the name of the current color scheme.  That should work in the conditional - or if you want you can set it's output to a variable.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Online

#3 2013-01-19 13:49:00

Vain
Member
Registered: 2008-10-19
Posts: 177
Website

Re: [SOLVED] how to check current colorscheme in vimrc?

Hi,

color schemes will set the variable “g:colors_name“. Thus:

if g:colors_name == 'myscheme'
    ... foo ...
else
    ... bar ...
endif

Offline

#4 2013-01-19 20:12:07

starfry
Member
From: Surrey, UK
Registered: 2010-08-18
Posts: 170

Re: [SOLVED] how to check current colorscheme in vimrc?

Thank you Vain, that is the answer I was looking for. "color[scheme]"  does indeed output the name of the current color scheme but I cound not get it to work in the conditional. Using the g:colors_name variable works a treat. Very much appreciated smile

Offline

Board footer

Powered by FluxBB