1
0
mirror of https://git.decapod.one/brethil/dotfiles synced 2024-11-21 19:11:30 +01:00

vim: add autohighlight toggle

This commit is contained in:
bretello 2020-02-14 16:37:50 +01:00
parent 4a398b06a3
commit 72b6ce135e

View File

@ -1,3 +1,4 @@
colorscheme twilight256
set mouse=a relativenumber number foldmethod=indent nofoldenable "without nofoldenable all folds are closed at startup"
set splitbelow splitright
set autoread
@ -22,3 +23,25 @@ packadd termdebug
let g:gitgutter_enabled = 1
" Highlight all instances of word under cursor, when idle.
" Useful when studying strange source code.
" Type z/ to toggle highlighting on/off.
nnoremap z/ :if AutoHighlightToggle()<Bar>set hls<Bar>endif<CR>
function! AutoHighlightToggle()
let @/ = ''
if exists('#auto_highlight')
au! auto_highlight
augroup! auto_highlight
setl updatetime=4000
echo 'Highlight current word: off'
return 0
else
augroup auto_highlight
au!
au CursorHold * let @/ = '\V\<'.escape(expand('<cword>'), '\').'\>'
augroup end
setl updatetime=500
echo 'Highlight current word: ON'
return 1
endif
endfunction