Last active
August 29, 2015 13:56
-
-
Save sooop/9326451 to your computer and use it in GitHub Desktop.
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
"SECTION: color change function {{{1 | |
"=============================================================================== | |
"TOPIC: Functions {{{2 | |
"FUNCTION: PrepareColorList | |
"--------------------------- | |
let s:colorindex = 0 | |
function! PrepareColorList() | |
let s:colorlist = [] | |
if !exists('s:colorlist[0]') | |
let s:colorlist = split(glob("$VIMRUNTIME/colors/*.vim"), "\n") | |
if has('win32') | |
" ??? glob() : get all filelist fron given path and pattern. | |
" ??? split() : split text into a list, using given saperator. | |
" ??? map() : | |
call extend(s:colorlist, split(glob("$HOME/vimfiles/colors/*.vim"), "\n")) | |
call map(s:colorlist, 'strpart(v:val, strridx(v:val, "\\")+1, strlen(v:val) - strridx(v:val, "\\") - 5)') | |
else | |
call extend(s:colorlist, split(glob("$HOME/.vim/colors/*.vim"), "\n")) | |
call map(s:colorlist, 'strpart(v:val, strridx(v:val, "/") +1, strlen(v:val) - strridx(v:val, "/") - 5)') | |
endif | |
endif | |
endfunction | |
"FUNCTION: NextColor | |
"-------------------- | |
function! NextColor() | |
call PrepareColorList() | |
if s:colorindex == len(s:colorlist) -1 | |
let s:colorindex = 0 | |
else | |
let s:colorindex += 1 | |
endif | |
let s:colorname = get(s:colorlist, s:colorindex) | |
execute "color ".s:colorname | |
endfunction | |
"FUNCTION: DispColorName | |
"------------------------- | |
function! DispColorName() | |
"call PrepareColorList() | |
echo s:colorname | |
endfunction | |
"FUNCTION: PrevColor | |
"--------------------- | |
function! PrevColor() | |
call PrepareColorList() | |
if s:colorindex == 0 | |
let s:colorindex = len(s:colorlist) - 1 | |
else | |
let s:colorindex -= 1 | |
endif | |
let s:colorname = get(s:colorlist, s:colorindex) | |
execute "color ".s:colorname | |
endfunction | |
"TOPIC: key maps for color change {{{2 | |
nnoremap <leader>ui :call DispColorName()<cr> | |
nnoremap <F10> :call NextColor()<cr>:call DispColorName()<cr> | |
nnoremap <s-F10> :call PrevColor()<cr>:call DispColorName()<cr> | |
nnoremap <leader>uu :call NextColor()<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
map()
v:val
로 표현한다.예시