Last active
November 2, 2017 23:19
-
-
Save amadeus/9e7bf0f1477b6c5fbf7a928e9ac81968 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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