add word highlighting options to vimrc
Copied from sjl, these mappings make it easy to highlight different words in different colors in the file, making it easy to track multiple words throughout the file
This commit is contained in:
@@ -319,6 +319,44 @@ function! TrimWhiteSpace()
|
||||
%s/\s\+$//e
|
||||
endfunction
|
||||
|
||||
function! HiInterestingWord(n)
|
||||
" Save our location.
|
||||
normal! mz
|
||||
|
||||
" Yank the current word into the z register.
|
||||
normal! "zyiw
|
||||
|
||||
" Calculate an arbitrary match ID. Hopefully nothing else is using it.
|
||||
let mid = 86750 + a:n
|
||||
|
||||
" Clear existing matches, but don't worry if they don't exist.
|
||||
silent! call matchdelete(mid)
|
||||
|
||||
" Construct a literal pattern that has to match at boundaries.
|
||||
let pat = '\V\<' . escape(@z, '\') . '\>'
|
||||
|
||||
" Actually match the words.
|
||||
call matchadd("InterestingWord" . a:n, pat, 1, mid)
|
||||
|
||||
" Move back to our original location.
|
||||
normal! `z
|
||||
endfunction
|
||||
|
||||
nnoremap <silent> <leader>1 :call HiInterestingWord(1)<cr>
|
||||
nnoremap <silent> <leader>2 :call HiInterestingWord(2)<cr>
|
||||
nnoremap <silent> <leader>3 :call HiInterestingWord(3)<cr>
|
||||
nnoremap <silent> <leader>4 :call HiInterestingWord(4)<cr>
|
||||
nnoremap <silent> <leader>5 :call HiInterestingWord(5)<cr>
|
||||
nnoremap <silent> <leader>6 :call HiInterestingWord(6)<cr>
|
||||
|
||||
hi def InterestingWord1 guifg=#000000 ctermfg=16 guibg=#ffa724 ctermbg=214
|
||||
hi def InterestingWord2 guifg=#000000 ctermfg=16 guibg=#aeee00 ctermbg=154
|
||||
hi def InterestingWord3 guifg=#000000 ctermfg=16 guibg=#8cffba ctermbg=121
|
||||
hi def InterestingWord4 guifg=#000000 ctermfg=16 guibg=#b88853 ctermbg=137
|
||||
hi def InterestingWord5 guifg=#000000 ctermfg=16 guibg=#ff9eb8 ctermbg=211
|
||||
hi def InterestingWord6 guifg=#000000 ctermfg=16 guibg=#ff2c4b ctermbg=195
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Plugins
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
Reference in New Issue
Block a user