Skip to content
Browse files

Clean up interesting word highlights.

  • Loading branch information...
1 parent 6b1dd14 commit 92b7e1f172230ec796167a8415c3a18a2ae92f65 @sjl committed Nov 19, 2012
Showing with 63 additions and 13 deletions.
  1. +1 −1 .hgsubstate
  2. +62 −12 vim/vimrc
View
2 .hgsubstate
@@ -3,7 +3,7 @@ b0da16490f168f68072973b45dbc27a74fb7b529 mercurial/histedit
4d95cb18a3b420154ef978c53de1d2e692f8343d mercurial/templates
64981213be2efd939e6e6e109e2b32c24e95fd95 vim/bundle/AnsiEsc.vim
9895285042a2fd5691b2f6582aa979e4d1bdffea vim/bundle/ack
-edced74507462215bb2431b5db34fdef18baeaf0 vim/bundle/badwolf
+b8e07a24e77d3bad16a89bde409f97ccc307486a vim/bundle/badwolf
8533fffd9fbb690dfc8e334f91a10c72e35a6dce vim/bundle/clam
dc349bb7d30f713d770fc1fa0fe209e6aab82dc8 vim/bundle/commentary
3c6182371db8e8ede3789d21b52386569eda2208 vim/bundle/ctrlp
View
74 vim/vimrc
@@ -532,13 +532,6 @@ noremap <C-l> <C-w>l
noremap <leader>v <C-w>v
" }}}
-" Highlight word {{{
-
-nnoremap <silent> <leader>h1 :execute 'match InterestingWord1 /\<<c-r><c-w>\>/'<cr>
-nnoremap <silent> <leader>h2 :execute '2match InterestingWord2 /\<<c-r><c-w>\>/'<cr>
-nnoremap <silent> <leader>h3 :execute '3match InterestingWord3 /\<<c-r><c-w>\>/'<cr>
-
-" }}}
" Visual Mode */# from Scrooloose {{{
function! s:VSetSearch()
@@ -1750,21 +1743,24 @@ function! BlockColor() " {{{
call matchdelete(77883)
call matchdelete(77884)
call matchdelete(77885)
+ call matchdelete(77886)
else
let g:blockcolor_state = 1
call matchadd("BlockColor1", '^ \{4}.*', 1, 77881)
call matchadd("BlockColor2", '^ \{8}.*', 2, 77882)
call matchadd("BlockColor3", '^ \{12}.*', 3, 77883)
call matchadd("BlockColor4", '^ \{16}.*', 4, 77884)
call matchadd("BlockColor5", '^ \{20}.*', 5, 77885)
+ call matchadd("BlockColor6", '^ \{24}.*', 6, 77886)
endif
endfunction " }}}
" Default highlights {{{
-hi def BlockColor1 guibg=#222222
-hi def BlockColor2 guibg=#2a2a2a
-hi def BlockColor3 guibg=#353535
-hi def BlockColor4 guibg=#3d3d3d
-hi def BlockColor5 guibg=#444444
+hi def BlockColor1 guibg=#222222 ctermbg=234
+hi def BlockColor2 guibg=#2a2a2a ctermbg=235
+hi def BlockColor3 guibg=#353535 ctermbg=236
+hi def BlockColor4 guibg=#3d3d3d ctermbg=237
+hi def BlockColor5 guibg=#444444 ctermbg=238
+hi def BlockColor6 guibg=#4a4a4a ctermbg=239
" }}}
nnoremap <leader>B :call BlockColor()<cr>
@@ -1805,6 +1801,60 @@ endfunction " }}}
command! -nargs=0 Pulse call s:Pulse()
" }}}
+" Highlight Word {{{
+"
+" This mini-plugin provides a few mappings for highlighting words temporarily.
+"
+" Sometimes you're looking at a hairy piece of code and would like a certain
+" word or two to stand out temporarily. You can search for it, but that only
+" gives you one color of highlighting. Now you can use <leader>N where N is
+" a number from 1-6 to highlight the current word in a specific color.
+
+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 " }}}
+
+" Mappings {{{
+
+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>
+
+" }}}
+" Default Highlights {{{
+
+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
+
+" }}}
+
+" }}}
" }}}
" Environments (GUI/Console) ---------------------------------------------- {{{

0 comments on commit 92b7e1f

Please sign in to comment.
Something went wrong with that request. Please try again.