Skip to content

Instantly share code, notes, and snippets.

@EgZvor
Last active January 25, 2022 11:22
Show Gist options
  • Save EgZvor/ce92ddb573d1f90470fe71a94bbdd9bc to your computer and use it in GitHub Desktop.
Save EgZvor/ce92ddb573d1f90470fe71a94bbdd9bc to your computer and use it in GitHub Desktop.
Automatic search highlighting clearing for Vim
if exists('g:loaded_auto_search_highlighting')
finish
endif
let g:loaded_auto_search_highlighting = 1
if ! exists('g:auto_search_highlighting')
let g:auto_search_highlighting = 1
endif
augroup AutoSearchHighlighting
autocmd!
autocmd CmdlineEnter /,\? set hlsearch
autocmd CmdlineLeave /,\?
\ if g:auto_search_highlighting |
\ set nohlsearch |
\ endif
augroup END
command -nargs=0 ToggleAutoSearchHighlighting
\ let &hlsearch = g:auto_search_highlighting |
\ let g:auto_search_highlighting = !g:auto_search_highlighting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment