Skip to content

Instantly share code, notes, and snippets.

@shmup
Created March 23, 2023 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shmup/44a5093508dffb488bac8e658f1db7f9 to your computer and use it in GitHub Desktop.
Save shmup/44a5093508dffb488bac8e658f1db7f9 to your computer and use it in GitHub Desktop.
cycle through your personal colorschemes
" cyclecolors.vim
" cycle through colorschemes
function! CycleColors(direction)
let colorschemes = split(globpath(expand("~/.vim/colors/"), "*.vim"), "\n")
let colorscheme_names = map(colorschemes, {_,v -> fnamemodify(v, ':t:r')})
let current_color_index = index(colorscheme_names, g:colors_name)
let next_colorscheme = a:direction == '→' ? current_color_index + 1 : current_color_index - 1
let next_colorscheme = (next_colorscheme + len(colorscheme_names)) % len(colorscheme_names)
execute 'colorscheme ' . colorscheme_names[next_colorscheme]
redraw
echo colorscheme_names[next_colorscheme]
endfunction
nnoremap <silent> <Right> :call CycleColors('→')<CR>
nnoremap <silent> <Left> :call CycleColors('←')<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment