diff options
author | Chris <[email protected]> | 2020-05-08 22:12:01 -0400 |
---|---|---|
committer | Chris <[email protected]> | 2020-05-08 22:12:01 -0400 |
commit | 86bb86e4f111e4353a1ac14ac3cf2844391ee8b1 (patch) | |
tree | cef78bfc6ae66d7ba96f20fc98de84a1a2fcfe11 /general/functions.vim | |
parent | b5f4a43775e9923b22b74d60b104cf53e0217767 (diff) |
updates
Diffstat (limited to 'general/functions.vim')
-rw-r--r-- | general/functions.vim | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/general/functions.vim b/general/functions.vim new file mode 100644 index 00000000..bec4580b --- /dev/null +++ b/general/functions.vim @@ -0,0 +1,21 @@ +" distinct highlight current, first and last match when searching +function! HLCurrent() abort + if exists("currmatch") + call matchdelete(currmatch) + endif + " only on cursor + let patt = '\c\%#'.@/ + " check prev and next match + let prevmatch = search(@/, 'bWn') + let nextmatch = search(@/, 'Wn') + " if on first or last match + if prevmatch == 0 || nextmatch == 0 + let currmatch = matchadd('EdgeSearch', patt, 101) + else + let currmatch = matchadd('IncSearch', patt, 101) + endif + redraw +endfunction + +nnoremap <silent> n n:call HLCurrent()<cr> +nnoremap <silent> N N:call HLCurrent()<cr> |