Skip to content

Instantly share code, notes, and snippets.

@dhruvasagar
Forked from vagmi/scheme_switcher.vim
Last active August 29, 2015 14:11
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 dhruvasagar/9e60045de274229135f7 to your computer and use it in GitHub Desktop.
Save dhruvasagar/9e60045de274229135f7 to your computer and use it in GitHub Desktop.
function! s:RandomNumber(limit)
let components = split(reltimestr(reltime()), '\.')
let microseconds = components[-1] + 0
return microseconds % a:limit
endfunction
function! s:RandomScheme()
let choices = []
for fname in globpath(&runtimepath, 'colors/*.vim', 1)
let choices += [fnamemodify(fname, ':t:r')]
endfor
let index = s:RandomNumber(len(choices))
execute 'colorscheme' fnameescape(choices[index])
endfunction
let s:total=1
function! functions#SwitchScheme()
call feedkeys("f\e")
if(s:total % 15 == 0)
" update time is usually set to 4 seconds
" So the scheme would be changed on 1 minute of inactivity
call s:RandomScheme()
endif
let s:total += 1
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment