From 44dcf9e53ee0e2f3700ecb326716c2b795593629 Mon Sep 17 00:00:00 2001 From: Max Christian Pohle Date: Fri, 9 Jun 2017 20:46:49 +0200 Subject: Improved performance of word-highlighting - completely rewrote it --- vimrc-full | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/vimrc-full b/vimrc-full index 1344f7e..e605d38 100644 --- a/vimrc-full +++ b/vimrc-full @@ -1,4 +1,4 @@ -" vim: tabstop=2 softtabstop=2 shiftwidth=2 textwidth=160 +" vim: tabstop=2 softtabstop=2 shiftwidth=2 textwidth=160 iskeyword+=\: set encoding=utf-8 | " set up vim's cosole encoding (not file encoding, for which there is fileencoding=) set t_Co=256 | " required on some ssh sessions @@ -68,7 +68,7 @@ set winminwidth=30 | " (and all other windows, so TODO: watch out) set tags+=../tags " set textwidth=100 | " line length (80 used to be default, but...) " set colorcolumn= | " not used, because we have a :match directive for textwidth -set updatetime=10 | " updates the screen more often +set updatetime=80 | " updates the screen more often set viminfo+=% | " restore buffer list set writedelay=0 set wildmenu | " use a menu in the command line @@ -658,17 +658,15 @@ let g:netrw_preview = 0 | " let g:netrw_winsize = 20 | " window size in percent +highlight WordBold cterm=bold gui=bold function! HighlightWordUnderCursor() - highlight WordBold cterm=bold gui=bold - + if(exists('w:m1') && w:m1 > 0) + call matchdelete(w:m1) + let w:m1 = 0 + endif let l:currentword = escape(expand(''), '.') - exec 'syn clear' 'WordBold' if(strlen(l:currentword) > 0) - " exec '2match' 'WordBold' '/'.l:currentword.'/' - " exec 'syn match' 'WordBold' '/'.l:currentword.'/' - if getline(".")[col(".")-1] !~# '[[:punct:][:blank:]]' - exec '2match' 'Bold' '/\V\<'.l:currentword.'\>/' - endif + let w:m1=matchadd('WordBold', l:currentword, -1, 100) endif endfunction autocmd! CursorHold,CursorHoldI * call HighlightWordUnderCursor() -- cgit v1.2.3