diff --git a/.vimrc b/.vimrc index 2a5c4ee..2669bfd 100644 --- a/.vimrc +++ b/.vimrc @@ -301,9 +301,32 @@ function! s:ExecuteInShell(command) echo 'Execution of ' . command . ' complete.' endfunction - command! -complete=shellcmd -nargs=+ Shell call s:ExecuteInShellOutput() command! -complete=shellcmd -nargs=+ Exec call s:ExecuteInShell() command! -nargs=* Make call s:ExecuteInShellOutput('make '.) command! -nargs=* Git call s:ExecuteInShellOutput('git '.) command! -nargs=* PTW call s:ExecuteInShell('ptw post --client=vim "'..'"') + +" 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()set hlselseset nohlsendif +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(''), '\').'\>' + augroup end + setl updatetime=500 + echo 'Highlight current word: ON' + return 1 + endif +endfunction +