How to have vim highlight color change for the pattern under cursor? -


is there way have search highlight text in vim under cursor have different color compared search text not under cursor?

my .vimrc has codes:

function! hiinterestingword(n) " {{{2     " save our location.     normal! mz     " yank current word z register.     normal! "zyiw     " calculate arbitrary match id.  nothing else using it.     let mid = 77750 + a:n     " clear existing matches, don't worry if don't exist.     "silent! call matchdelete(mid)     try         call matchdelete(mid)     catch 'e803'         " construct literal pattern has match @ boundaries.         let pat = '\v\<' . escape(@z, '\') . '\>'         " match words.         call matchadd("interestingword" . a:n, pat, 1, mid)     endtry     " move our original location.     normal! `z endfunction   "clear highlighting function! clearallhi()     in range(1,6)         let mid = 77750 +         silent! call matchdelete(mid)     endfor endfunction  nnoremap <silent> <leader>0 :call clearallhi()<cr> 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 "}}} 

this allows press <leader> + 1-6 high light word under cursor in different colors; pressing twice clear highlighting. (you can change color in hi def...) commands. , <leader>+0 clear highlights.

you can put codes in vimrc try.

it works this:

enter image description here


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -