Skip to content

Instantly share code, notes, and snippets.

@romainl
Created July 14, 2017 09:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romainl/209d95033f622d1d913fe162221ad88c to your computer and use it in GitHub Desktop.
Save romainl/209d95033f622d1d913fe162221ad88c to your computer and use it in GitHub Desktop.
Colorize IRC nicks
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