Skip to content

Instantly share code, notes, and snippets.

@RobertAudi
Created May 18, 2014 17:15
Show Gist options
  • Save RobertAudi/99a656670eaec8a5f9c5 to your computer and use it in GitHub Desktop.
Save RobertAudi/99a656670eaec8a5f9c5 to your computer and use it in GitHub Desktop.
set hlsearch
highlight CurSearch guibg=green
nnoremap <silent> N N:silent! call HighlightCurrentMatch()<CR>
nnoremap <silent> n n:silent! call HighlightCurrentMatch()<CR>
function! HighlightCurrentMatch()
let col = col(".") - 1
let endCol = searchpos(getreg("/"), "cne")[1] + 1
let line = line(".")
let matchPat = '/\%' . line . 'l\%>' . col . 'c\%<' . endCol . 'c/'
echomsg matchPat
3match none
exe ':3match CurSearch ' . matchPat
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment