I want to quickly see all colorschemes available in Vim, without having to click many places or run a lot of manual commands. Is there an automated way to do that?
1 Answer
for c in globpath(&rtp, 'colors/*.vim', 0, 1)->map({_, val -> fnamemodify(val, ':t:r')})->sort('i')->uniq('i')
try
exec 'colorscheme ' .. c
redraw
echo c
catch
echo 'ERROR loading colorscheme ' .. c
finally
sleep 2
endtry
endfor
colorscheme default
redraw
echo 'finished. back to default'
Save the file and run it with :so %
(thanks @romainl and @Jürgen Krämer for the improvements suggestions!)
-
-
You don't need an external file. Replace the
for c in
loop withfor c in uniq(sort(map(globpath(&rtp, 'colors/*.vim', 0, 1), {key, val -> fnamemodify(val, ':t:r')}), 'i'), 'i')
and Vim will give you a list of all available colorschemes, including the ones from the user themself and from 3rd party packages. Commented Mar 22 at 9:00 -
Great, thanks! Successfully tested on Linux and Windows, GVim and terminal Vim. Updated the code. I changed the chained function calls to become methods. Commented Mar 22 at 23:38
-
I found a plugin to switch between colorschemes. Haven't tested it, though. vimawesome.com/plugin/vim-colorscheme-switcher Commented Mar 23 at 11:16
-
I don't know why, it's very slow on Linux GVim. Tried replacing
redraw
withredraw!
, but it didn't work. Commented Mar 27 at 23:00