From 505e3205d2ff07cefe1abdd2a6f6c6309d41552c Mon Sep 17 00:00:00 2001 From: michener Date: Wed, 6 Apr 2011 22:16:25 +0000 Subject: [PATCH] Add highlight function git-svn-id: http://photonzero.com/dotfiles/trunk@92 23f722f6-122a-0410-8cef-c75bd312dd78 --- .vimrc | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) 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 +