86976421465f

Clean up interesting word highlights.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 19 Nov 2012 13:28:03 -0500
parents 504def1b4005
children 7e89ab9326f9 a4e75d5bbcb0
branches/tags (none)
files .hgsubstate vim/vimrc

Changes

--- a/.hgsubstate	Mon Nov 19 12:53:05 2012 -0500
+++ b/.hgsubstate	Mon Nov 19 13:28:03 2012 -0500
@@ -3,7 +3,7 @@
 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
--- a/vim/vimrc	Mon Nov 19 12:53:05 2012 -0500
+++ b/vim/vimrc	Mon Nov 19 13:28:03 2012 -0500
@@ -532,13 +532,6 @@
 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,6 +1743,7 @@
         call matchdelete(77883)
         call matchdelete(77884)
         call matchdelete(77885)
+        call matchdelete(77886)
     else
         let g:blockcolor_state = 1
         call matchadd("BlockColor1", '^ \{4}.*', 1, 77881)
@@ -1757,14 +1751,16 @@
         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 @@
 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) ---------------------------------------------- {{{