How to tell which colorscheme a Vim session currently uses
Solution 1
There's no guaranteed way (as a colour scheme is essentially a load of vim commands that are sourced). However, by convention there should be a variable g:colors_name
that is set to the name of the colour scheme.
Therefore, try this:
echo g:colors_name
If you get E121, it's either a poorly made colour scheme or it's the default one.
A shinier way of doing this is (for recent versions of vim):
function! ShowColourSchemeName()
try
echo g:colors_name
catch /^Vim:E121/
echo "default"
endtry
endfunction
Then do:
:call ShowColourSchemeName()
If it says "default", do :colorscheme default
and see if the colours change. If they do, you're using a malformed colour scheme and there's not a lot you can do about it other than manually switching themes until you recognise it.
The variable g:colors_name
is documented here:
:help colorscheme
Solution 2
Best option is to use :colo
or :colorscheme
in current vim and the actual colorscheme text is shown. Please see,
:help colorscheme
for more details.
Solution 3
A one-line version of DrAl's answer:
let current_scheme = get(g:, 'colors_name', 'default')
The get()
function will fall back to 'default'
if the variable has not yet been set.
Related videos on Youtube
gotgenes
My name is Chris Lasher. I use computers to help other people study biology and improve human health. I enjoy TDD, pair programming and mobbing, and improving design and code organization one decision at a time.
Updated on July 08, 2022Comments
-
gotgenes almost 2 years
You can set the Vim color scheme by issuing
:colorscheme SCHEME_NAME
but, oddly enough, you can't get the currently used scheme by issuing
:colorscheme
as this results in "
E471: Argument required
". I also don't see the color scheme listed in the output of:set
.So how do you go about figuring out the current color scheme in use (other than manually switching the themes until you recognize it)?
-
daVe over 7 yearsIt doesn't work to me. It says
default
. And the color scheme I get when I execute:colo default
it's another one. -
piotao over 3 yearsThe first time this function is run VIM drops and error. However, when I loaded :colorscheme default, it worked well because there IS colors/default.vim colorscheme.
-
VimNing almost 2 yearshow to do the same for neovim?