Skip to content

Instantly share code, notes, and snippets.

@kcsongor
Created January 24, 2019 19:29
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 kcsongor/e0dbaff8a24dabb24666fbfe5317a1a4 to your computer and use it in GitHub Desktop.
Save kcsongor/e0dbaff8a24dabb24666fbfe5317a1a4 to your computer and use it in GitHub Desktop.
highlight words
let s:hlcounter = 1
function! Highlight(word)
let id = 110 + s:hlcounter
exe 'hi Group' . id . ' ctermbg=' . (20 + id) . ' ctermfg=0'
silent! call matchdelete(id)
silent! call matchadd('Group' . id, '\<' . a:word . '\>', 100, id)
let s:hlcounter = s:hlcounter + 1
endfunction
function! ResetHl()
call clearmatches()
let s:hlcounter = 1
endfunction
command! HlWord call Highlight(expand('<cword>'))
command! HlClear call ResetHl()
nnoremap <leader>hw :HlWord<cr>
nnoremap <leader>hc :HlClear<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment