Created
March 23, 2023 22:51
-
-
Save shmup/44a5093508dffb488bac8e658f1db7f9 to your computer and use it in GitHub Desktop.
cycle through your personal colorschemes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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