Last active
January 25, 2022 11:22
-
-
Save EgZvor/ce92ddb573d1f90470fe71a94bbdd9bc to your computer and use it in GitHub Desktop.
Automatic search highlighting clearing for Vim
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
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