티스토리 뷰

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
gvim을 사용하다가 몇가지 맘에는 컬러 스키마중에서 고민이 되더라구요.
그러다가 random colors vim 으로 검색을 했더니 짠 하고 나오는게 있더군요.

아래 코드를 vimrc 에 등록하고 gvim 을 다시 켜보면! 랜덤하게 색상이 변경되는 것을 볼 수 있습니다.

" Create the comma-separated list of colorscheme files
let s:colors = substitute(globpath(&runtimepath, 'colors/*.vim'), '\n', ',', 'g')
if strlen(s:colors)
  " Count the number of color schemes
  let s:num = strlen(substitute(s:colors, '[^,]\+', '', 'g')) + 1
  if s:num > 1
    let s:loop = localtime() % s:num
    " Rotate the list s:loop times
    while s:loop
      let s:colors = substitute(s:colors, '^\([^,]\+\),\(.*\)$', '\2,\1', '')
      let s:loop = s:loop - 1
    endwhile
  endif
  let s:color = matchstr(s:colors, '^[^,]\+')
  unlet! g:colors_name
  execute 'source' s:color
  " Prevent the message from disappearing
  redraw
  " 스킨이름을 보고 싶으면 아래 주석을 푸세요~
  "echomsg 'Color applied: '.(exists('g:colors_name') ? g:colors_name : '').' ('.s:color.')'
endif
unlet! s:colors s:color s:num s:loop
[edit] - [startup settings] 에 등록하시고 :wq! 하고 실행하면 짠~ 하고 계속 바뀝니다 ^^

출처 : http://vim.wikia.com/wiki/Set_a_random_color_scheme_at_startup

댓글