Created
July 14, 2017 09:49
-
-
Save romainl/209d95033f622d1d913fe162221ad88c to your computer and use it in GitHub Desktop.
Colorize IRC nicks
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
hi u0 ctermbg=red | |
hi u1 ctermbg=yellow | |
hi u2 ctermbg=cyan | |
hi u3 ctermbg=darkgreen | |
hi u4 ctermbg=magenta | |
hi u5 ctermbg=darkred | |
let all_nicks = [] | |
function! IsolateNicks(key, val) | |
return substitute(a:val, '^\[.\{-}\]\s\(<.\{-}>\).*$', '\1', '') | |
endfunction | |
function! ColorizeNicks() | |
let all_lines = getline(1, '$') | |
let all_nicks = uniq(sort(map(all_lines, function('IsolateNicks')))) | |
let index = 0 | |
for nick in all_nicks | |
execute 'call matchadd("u' . index . '", "' . nick . '")' | |
let index = index + 1 | |
endfor | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment