" tComment.vim -- An easily extensible & universal comment plugin " @Author: Tom Link (micathom AT gmail com) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 27-Dez-2004. " @Last Change: 2011-05-26. " @Revision: 720 " GetLatestVimScripts: 1173 1 tcomment.vim if &cp || exists('loaded_tcomment') finish endif let loaded_tcomment = 205 if !exists("g:tcommentMapLeader1") " g:tcommentMapLeader1 should be a shortcut that can be used with " map, imap, vmap. let g:tcommentMapLeader1 = '' endif if !exists("g:tcommentMapLeader2") " g:tcommentMapLeader2 should be a shortcut that can be used with " map, xmap. let g:tcommentMapLeader2 = '_' endif if !exists("g:tcommentMapLeaderOp1") let g:tcommentMapLeaderOp1 = 'gc' endif if !exists("g:tcommentMapLeaderOp2") let g:tcommentMapLeaderOp2 = 'gC' endif " :display: :[range]TComment[!] ?ARGS... " If there is a visual selection that begins and ends in the same line, " then |:TCommentInline| is used instead. " The optional range defaults to the current line. With a bang '!', " always comment the line. " " ARGS... are either (see also |tcomment#Comment()|): " 1. a list of key=value pairs " 2. 1-2 values for: ?commentBegin, ?commentEnd command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TComment \ keepjumps call tcomment#Comment(, , 'G', "", ) " :display: :[range]TCommentAs[!] commenttype ?ARGS... " TCommentAs requires g:tcomment_{filetype} to be defined. " With a bang '!', always comment the line. " " ARGS... are either (see also |tcomment#Comment()|): " 1. a list of key=value pairs " 2. 1-2 values for: ?commentBegin, ?commentEnd command! -bang -complete=customlist,tcomment#Complete -range -nargs=+ TCommentAs \ call tcomment#CommentAs(, , "", ) " :display: :[range]TCommentRight[!] ?ARGS... " Comment the text to the right of the cursor. If a visual selection was " made (be it block-wise or not), all lines are commented out at from " the current cursor position downwards. " With a bang '!', always comment the line. " " ARGS... are either (see also |tcomment#Comment()|): " 1. a list of key=value pairs " 2. 1-2 values for: ?commentBegin, ?commentEnd command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TCommentRight \ keepjumps call tcomment#Comment(, , 'R', "", ) " :display: :[range]TCommentBlock[!] ?ARGS... " Comment as "block", e.g. use the {&ft}_block comment style. The " commented text isn't indented or reformated. " With a bang '!', always comment the line. " " ARGS... are either (see also |tcomment#Comment()|): " 1. a list of key=value pairs " 2. 1-2 values for: ?commentBegin, ?commentEnd command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TCommentBlock \ keepjumps call tcomment#Comment(, , 'B', "", ) " :display: :[range]TCommentInline[!] ?ARGS... " Use the {&ft}_inline comment style. " With a bang '!', always comment the line. " " ARGS... are either (see also |tcomment#Comment()|): " 1. a list of key=value pairs " 2. 1-2 values for: ?commentBegin, ?commentEnd command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TCommentInline \ keepjumps call tcomment#Comment(, , 'I', "", ) " :display: :[range]TCommentMaybeInline[!] ?ARGS... " With a bang '!', always comment the line. " " ARGS... are either (see also |tcomment#Comment()|): " 1. a list of key=value pairs " 2. 1-2 values for: ?commentBegin, ?commentEnd command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TCommentMaybeInline \ keepjumps call tcomment#Comment(, , 'i', "", ) if (g:tcommentMapLeader1 != '') exec 'noremap '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' :TComment' exec 'vnoremap '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' :TCommentMaybeInline' exec 'inoremap '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' :TComment' exec 'noremap '. g:tcommentMapLeader1 .'p m`vip:TComment``' exec 'inoremap '. g:tcommentMapLeader1 .'p :norm! m`vip:TComment``' exec 'noremap '. g:tcommentMapLeader1 .' :TComment ' exec 'inoremap '. g:tcommentMapLeader1 .' :TComment ' exec 'inoremap '. g:tcommentMapLeader1 .'r :TCommentRight' exec 'noremap '. g:tcommentMapLeader1 .'r :TCommentRight' exec 'vnoremap '. g:tcommentMapLeader1 .'i :TCommentInline' exec 'vnoremap '. g:tcommentMapLeader1 .'r :TCommentRight' exec 'noremap '. g:tcommentMapLeader1 .'b :TCommentBlock' exec 'inoremap '. g:tcommentMapLeader1 .'b :TCommentBlock' exec 'noremap '. g:tcommentMapLeader1 .'a :TCommentAs ' exec 'inoremap '. g:tcommentMapLeader1 .'a :TCommentAs ' exec 'noremap '. g:tcommentMapLeader1 .'n :TCommentAs =&ft ' exec 'inoremap '. g:tcommentMapLeader1 .'n :TCommentAs =&ft ' exec 'noremap '. g:tcommentMapLeader1 .'s :TCommentAs =&ft_' exec 'inoremap '. g:tcommentMapLeader1 .'s :TCommentAs =&ft_' endif if (g:tcommentMapLeader2 != '') exec 'noremap '. g:tcommentMapLeader2 .'_ :TComment' exec 'xnoremap '. g:tcommentMapLeader2 .'_ :TCommentMaybeInline' exec 'noremap '. g:tcommentMapLeader2 .'p vip:TComment' exec 'noremap '. g:tcommentMapLeader2 .' :TComment ' exec 'xnoremap '. g:tcommentMapLeader2 .'i :TCommentInline' exec 'noremap '. g:tcommentMapLeader2 .'r :TCommentRight' exec 'xnoremap '. g:tcommentMapLeader2 .'r :TCommentRight' exec 'noremap '. g:tcommentMapLeader2 .'b :TCommentBlock' exec 'noremap '. g:tcommentMapLeader2 .'a :TCommentAs ' exec 'noremap '. g:tcommentMapLeader2 .'n :TCommentAs =&ft ' exec 'noremap '. g:tcommentMapLeader2 .'s :TCommentAs =&ft_' endif if (g:tcommentMapLeaderOp1 != '') exec 'nnoremap '. g:tcommentMapLeaderOp1 .' :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#Operatorg@' exec 'nnoremap '. g:tcommentMapLeaderOp1 .'c :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLineg@$' exec 'xnoremap '. g:tcommentMapLeaderOp1 .' :TCommentMaybeInline' endif if (g:tcommentMapLeaderOp2 != '') exec 'nnoremap '. g:tcommentMapLeaderOp2 .' :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorAnywayg@' exec 'nnoremap '. g:tcommentMapLeaderOp2 .'c :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLineAnywayg@$' exec 'xnoremap '. g:tcommentMapLeaderOp2 .' :TCommentMaybeInline' endif