summaryrefslogtreecommitdiff
path: root/general
diff options
context:
space:
mode:
Diffstat (limited to 'general')
-rw-r--r--general/functions.vim21
-rw-r--r--general/settings.vim2
2 files changed, 21 insertions, 2 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>
diff --git a/general/settings.vim b/general/settings.vim
index 49c5136f..c2f89897 100644
--- a/general/settings.vim
+++ b/general/settings.vim
@@ -1,8 +1,6 @@
" set leader key
"map <Space> <Leader>
"nmap <space> <leader>
-let mapleader=" "
-nnoremap <Space> <Nop>
set iskeyword+=- " treat dash separated words as a word text object"
if !exists('g:vscode')