Skip to content

Instantly share code, notes, and snippets.

@amadeus amadeus/vimrc.vim
Last active Nov 2, 2017

Embed
What would you like to do?
let g:hl_was_on = 0
function! ToggleHLSearch(enter)
if a:enter == 1 && v:hlsearch == 1
let g:hl_was_on = 1
elseif a:enter == 1
let g:hl_was_on = 0
set hlsearch
elseif a:enter == 0 && g:hl_was_on == 0
let g:hl_was_on = 0
set nohlsearch
else
let g:hl_was_on = 0
endif
endfunction
augroup searching
autocmd!
autocmd CmdlineEnter * :call ToggleHLSearch(1)
autocmd CmdlineLeave * :call ToggleHLSearch(0)
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.