diff options
author | Florian Pritz <bluewind@xssn.at> | 2009-10-17 23:32:22 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xssn.at> | 2009-10-17 23:32:22 +0200 |
commit | ddc01a57fbf64a0571782aa1ff6c835efafa209a (patch) | |
tree | cfbbcc109d8600964de7762de146216bd6e93d9d /.vimrc | |
parent | ec2677cea89b4daa732f4bbcef478a6affeae53a (diff) | |
download | dotfiles-ddc01a57fbf64a0571782aa1ff6c835efafa209a.tar.gz dotfiles-ddc01a57fbf64a0571782aa1ff6c835efafa209a.tar.xz |
vimrc: add hotkey for commenting
src: http://rsontech.net/articles/2009/09/22/11/vim-comments-revisited
Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to '.vimrc')
-rw-r--r-- | .vimrc | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -49,6 +49,32 @@ if !exists(":DiffOrig") \ | wincmd p | diffthis endif +" Comment out a visual block +function CommentLines() + execute ":s@^@".g:StartComment." @g" + "execute ":s@^\\(\\s*\\)@\\1".g:StartComment." @g" + + execute ":s@$@ ".g:EndComment."@g" +endfunction + +" Uncomment a visual block +function UncommentLines() + execute ":s@^".g:StartComment." @\@g" + "execute ":s@^\\(\\s*\\)".g:StartComment." @\\1@g" + + execute ":s@ ".g:EndComment."$@@g" +endfunction + +" Set comment characters for common languages +autocmd FileType python,sh,bash,zsh,ruby,perl let StartComment="#" | let EndComment="" +autocmd FileType html let StartComment="<!--" | let EndComment="-->" +autocmd FileType php,c,javascript let StartComment="//" | let EndComment="" +autocmd FileType cpp let StartComment="/*" | let EndComment="*/" +autocmd FileType vim let StartComment="\"" | let EndComment="" + +vmap <C-c> :call CommentLines()<cr> +vmap <C-u> :call UncommentLines()<cr> + set runtimepath+=/usr/share/vim "inoremap <tab> <c-n> |