Add highlight function

git-svn-id: http://photonzero.com/dotfiles/trunk@92 23f722f6-122a-0410-8cef-c75bd312dd78
This commit is contained in:
michener 2011-04-06 22:16:25 +00:00
parent 785e1dd0c3
commit 505e3205d2

25
.vimrc
View file

@ -301,9 +301,32 @@ function! s:ExecuteInShell(command)
echo 'Execution of ' . command . ' complete.'
endfunction
command! -complete=shellcmd -nargs=+ Shell call s:ExecuteInShellOutput(<q-args>)
command! -complete=shellcmd -nargs=+ Exec call s:ExecuteInShell(<q-args>)
command! -nargs=* Make call s:ExecuteInShellOutput('make '.<q-args>)
command! -nargs=* Git call s:ExecuteInShellOutput('git '.<q-args>)
command! -nargs=* PTW call s:ExecuteInShell('ptw post --client=vim "'.<q-args>.'"')
" 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>else<Bar>set nohls<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