Skip to content

Instantly share code, notes, and snippets.

@kuuote
Last active January 29, 2020 08:34
Show Gist options
  • Save kuuote/63b2e701cd3a274fe4b1127050daee28 to your computer and use it in GitHub Desktop.
Save kuuote/63b2e701cd3a274fe4b1127050daee28 to your computer and use it in GitHub Desktop.
虹色に染め上げるやつ :source して:MyRainbowで有効になります
"Wikipediaの色相環の項目の虹色
const s:colors = ['FF0000', 'FF4000', 'FF8000', 'FFBF00', 'FFFF00', 'BFFF00', '80FF00', '40FF00', '00FF00', '00FF40', '00FF80', '00FFBF', '00FFFF', '00BFFF', '0080FF', '0040FF', '0000FF', '4000FF', '8000FF', 'BF00FF', 'FF00FF', 'FF00BF', 'FF0080', 'FF0040']
const s:looper = range(1, 300)
"色付けされた行
let s:painted = 0
function! s:paintline(line) abort
for i in s:looper
call matchaddpos(s:colors[(a:line + i) % len(s:colors)], [[a:line, i]])
endfor
endfunction
function! s:paint() abort
while s:painted < line('$')
call s:paintline(s:painted + 1)
let s:painted += 1
endwhile
endfunction
function! s:init() abort
setf text
for c in s:colors
execute printf('hi %s guifg=#%s', c, c)
endfor
call s:paint()
autocmd TextChanged * call <SID>paint()
autocmd TextChangedI * call <SID>paint()
endfunction
command! MyRainbow call <SID>init()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment