Skip to content

Commit df7e9eb

Browse files
committed
Remove long line hightlight; turned out to be annoying; Add mappings for easy highlighting of word under cursor; nice way to highlight things without having to search for it moving your cursor.
1 parent 19cff19 commit df7e9eb

File tree

1 file changed

+53
-3
lines changed

1 file changed

+53
-3
lines changed

vimrc

+53-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ set incsearch " show my search when typing
5050
" wait less time for command sequences
5151
set timeoutlen=500
5252

53-
" Highlight long lines (soft limit: 80, hard limit: 100)
54-
:au BufRead *.php,*.py let w:m1=matchadd('Search', '\%<101v.\%>80v', -1)
55-
:au BufRead *.php,*.py let w:m2=matchadd('ErrorMsg', '\%>100v.\+', -1)
5653
:au BufRead *.php,*.py set formatoptions-=t
5754
:au BufRead *.php,*.py set textwidth=79 " keep it < 80!
5855

@@ -269,3 +266,56 @@ endfunction
269266
command! Phpcs execute RunPhpcs()
270267
autocmd BufRead *.php map <leader>M :execute RunPhpcs()<CR>
271268
269+
" highlight stuff taken from https://github.com/sjl/dotfiles/blob/master/vim/vimrc
270+
" }}}
271+
" Highlight Word {{{
272+
"
273+
" This mini-plugin provides a few mappings for highlighting words temporarily.
274+
"
275+
" Sometimes you're looking at a hairy piece of code and would like a certain
276+
" word or two to stand out temporarily. You can search for it, but that only
277+
" gives you one color of highlighting. Now you can use <leader>N where N is
278+
" a number from 1-6 to highlight the current word in a specific color.
279+
280+
function! HiInterestingWord(n) " {{{
281+
" Save our location.
282+
normal! mz
283+
284+
" Yank the current word into the z register.
285+
normal! "zyiw
286+
287+
" Calculate an arbitrary match ID. Hopefully nothing else is using it.
288+
let mid = 86750 + a:n
289+
290+
" Clear existing matches, but don't worry if they don't exist.
291+
silent! call matchdelete(mid)
292+
293+
" Construct a literal pattern that has to match at boundaries.
294+
let pat = '\V\<' . escape(@z, '\') . '\>'
295+
296+
" Actually match the words.
297+
call matchadd("InterestingWord" . a:n, pat, 1, mid)
298+
299+
" Move back to our original location.
300+
normal! `z
301+
endfunction " }}}
302+
303+
" Mappings {{{
304+
nnoremap <silent> <leader>1 :call HiInterestingWord(1)<cr>
305+
nnoremap <silent> <leader>2 :call HiInterestingWord(2)<cr>
306+
nnoremap <silent> <leader>3 :call HiInterestingWord(3)<cr>
307+
nnoremap <silent> <leader>4 :call HiInterestingWord(4)<cr>
308+
nnoremap <silent> <leader>5 :call HiInterestingWord(5)<cr>
309+
nnoremap <silent> <leader>6 :call HiInterestingWord(6)<cr>
310+
" }}}
311+
312+
" Default Highlights {{{
313+
hi def InterestingWord1 guifg=#000000 ctermfg=16 guibg=#ffa724 ctermbg=214
314+
hi def InterestingWord2 guifg=#000000 ctermfg=16 guibg=#aeee00 ctermbg=154
315+
hi def InterestingWord3 guifg=#000000 ctermfg=16 guibg=#8cffba ctermbg=121
316+
hi def InterestingWord4 guifg=#000000 ctermfg=16 guibg=#b88853 ctermbg=137
317+
hi def InterestingWord5 guifg=#000000 ctermfg=16 guibg=#ff9eb8 ctermbg=211
318+
hi def InterestingWord6 guifg=#000000 ctermfg=16 guibg=#ff2c4b ctermbg=195
319+
" }}}
320+
321+
noremap <silent> <leader>N :noh<cr>:call clearmatches()<cr>

0 commit comments

Comments
 (0)