Permalink
Browse files

highlight matches only within the window viewport

  • Loading branch information...
1 parent c59e6ab commit 0cfba1dee3189c975234de6886e8d11a1d149d06 @chrisbra committed Mar 26, 2013
Showing with 6 additions and 0 deletions.
  1. +6 −0 autoload/ftimproved.vim
View
@@ -94,12 +94,18 @@ fun! <sid>HighlightMatch(char, dir) "{{{1
let output=''
if !empty(a:char)
let output = matchstr(a:char, '^\%(\\c\)\?\\V\zs.*')
+ " remove escaping for display
+ let output = substitute(output, '\\\\', '\\', 'g')
if a:dir
let pat = '\%(\%>'. col('.'). 'c\&\%'. line('.'). 'l'
let pat .= '\|\%>'. line('.'). 'l\)'. a:char
+ " Make sure, it only matches within the current viewport
+ let pat = '\%('. pat. '\m\)\ze\&\%<'.(line('w$')+1).'l'
else
let pat = '\%(\%<'. col('.'). 'c\&\%'. line('.'). 'l'
let pat .= '\|\%<'. line('.'). 'l\)'. a:char
+ " Make sure, it only matches within the current viewport
+ let pat = '\%('. pat. '\m\)\ze\&\%>'.(line('w0')-1).'l'
endif
let s:matchid = matchadd('IncSearch', pat)
endif

0 comments on commit 0cfba1d

Please sign in to comment.