update tcomment

git-svn-id: https://vimsuite.svn.sourceforge.net/svnroot/vimsuite/trunk@200 eb2d0018-73a3-4aeb-bfe9-1def61c9ec69
This commit is contained in:
alterdepp 2011-05-26 13:09:04 +00:00
parent 0642385224
commit fe3c306d74
4 changed files with 494 additions and 314 deletions

View File

@ -3,44 +3,99 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-09-17.
" @Last Change: 2010-09-29.
" @Revision: 0.0.249
" @Last Change: 2011-04-12.
" @Revision: 0.0.407
" call tlog#Log('Load: '. expand('<sfile>')) " vimtlib-sfile
" If true, comment blank lines too
if !exists("g:tcommentBlankLines")
let g:tcommentBlankLines = 1
" If true, comment blank lines too
let g:tcommentBlankLines = 1 "{{{2
endif
" Guess the file type based on syntax names always or for some fileformat only
if !exists("g:tcommentGuessFileType")
let g:tcommentGuessFileType = 0
if !exists("g:tcommentOpModeExtra")
" Modifies how the operator works.
" > ... Move the cursor to the end of the comment
let g:tcommentOpModeExtra = '' "{{{2
endif
if !exists('g:tcommentOptions')
" Other key-value options used by |tcomment#Comment()|.
"
" Example: If you want to put the opening comment marker always in
" the first column regardless of the block's indentation, put this
" into your |vimrc| file: >
" let g:tcommentOptions = {'col': 1}
let g:tcommentOptions = {} "{{{2
endif
if !exists('g:tcomment#ignore_char_type')
" |text-objects| for use with |tcomment#Operator| can have different
" types: line, block, char etc. Text objects like aB, it, at etc.
" have type char but this may not work reliably. By default,
" tcomment handles those text objects most often as if they were of
" type line. Set this variable to 0 in order to change this
" behaviour. Be prepared that the result may not always match your
" intentions.
let g:tcomment#ignore_char_type = 1 "{{{2
endif
if !exists("g:tcommentGuessFileType")
" Guess the file type based on syntax names always or for some fileformat only
" If non-zero, try to guess filetypes.
" tcomment also checks g:tcommentGuessFileType_{&filetype} for
" filetype specific values.
"
" Values:
" 0 ... don't guess
" 1 ... guess
" FILETYPE ... assume this filetype
let g:tcommentGuessFileType = 0 "{{{2
endif
" In php documents, the php part is usually marked as phpRegion. We thus
" assume that the buffers default comment style isn't php but html
if !exists("g:tcommentGuessFileType_dsl")
let g:tcommentGuessFileType_dsl = 'xml'
" For dsl documents, assumet filetype = xml.
let g:tcommentGuessFileType_dsl = 'xml' "{{{2
endif
if !exists("g:tcommentGuessFileType_php")
let g:tcommentGuessFileType_php = 'html'
" In php documents, the php part is usually marked as phpRegion. We
" thus assume that the buffers default comment style isn't php but
" html.
let g:tcommentGuessFileType_php = 'html' "{{{2
endif
if !exists("g:tcommentGuessFileType_html")
let g:tcommentGuessFileType_html = 1
let g:tcommentGuessFileType_html = 1 "{{{2
endif
if !exists("g:tcommentGuessFileType_tskeleton")
let g:tcommentGuessFileType_tskeleton = 1
let g:tcommentGuessFileType_tskeleton = 1 "{{{2
endif
if !exists("g:tcommentGuessFileType_vim")
let g:tcommentGuessFileType_vim = 1
let g:tcommentGuessFileType_vim = 1 "{{{2
endif
if !exists("g:tcommentGuessFileType_django")
let g:tcommentGuessFileType_django = 1 "{{{2
endif
if !exists("g:tcommentIgnoreTypes_php")
let g:tcommentIgnoreTypes_php = 'sql'
" In php files, some syntax regions are wongly highlighted as sql
" markup. We thus ignore sql syntax when guessing the filetype in
" php files.
let g:tcommentIgnoreTypes_php = 'sql' "{{{2
endif
if !exists('g:tcommentSyntaxMap') "{{{2
if !exists('g:tcomment#syntax_substitute')
" :read: let g:tcomment#syntax_substitute = {...} "{{{2
" Perform replacements on the syntax name.
let g:tcomment#syntax_substitute = {
\ '\C^javaScript': {'sub': 'javascript'}
\ }
endif
if !exists('g:tcommentSyntaxMap')
" tcomment guesses filetypes based on the name of the current syntax
" region. This works well if the syntax names match
" /filetypeSomeName/. Other syntax names have to be explicitly
" mapped onto the corresponding filetype.
" :read: let g:tcommentSyntaxMap = {...} "{{{2
let g:tcommentSyntaxMap = {
\ 'vimMzSchemeRegion': 'scheme',
\ 'vimPerlRegion': 'perl',
@ -50,17 +105,9 @@ if !exists('g:tcommentSyntaxMap') "{{{2
\ }
endif
" If you don't define these variables, TComment will use &commentstring
" instead. We override the default values here in order to have a blank after
" the comment marker. Block comments work only if we explicitly define the
" markup.
" The format for block comments is similar to normal commentstrings with the
" exception that the format strings for blocks can contain a second line that
" defines how "middle lines" (see :h format-comments) should be displayed.
" I personally find this style rather irritating but here is an alternative
" definition that does this left-handed bar thing
if !exists("g:tcommentBlockC")
" Generic c-like block comments.
" :read: let g:tcommentBlockC = {...} "{{{2
let g:tcommentBlockC = {
\ 'commentstring': '/*%s */',
\ 'middle': ' * ',
@ -70,6 +117,8 @@ if !exists("g:tcommentBlockC")
\ }
endif
if !exists("g:tcommentBlockC2")
" Generic c-like block comments (alternative markup).
" :read: let g:tcommentBlockC2 = {...} "{{{2
let g:tcommentBlockC2 = {
\ 'commentstring': '/**%s */',
\ 'middle': ' * ',
@ -79,21 +128,38 @@ if !exists("g:tcommentBlockC2")
\ }
endif
if !exists("g:tcommentInlineC")
let g:tcommentInlineC = "/* %s */"
" Generic c-like comments.
let g:tcommentInlineC = "/* %s */" "{{{2
endif
if !exists("g:tcommentBlockXML")
let g:tcommentBlockXML = "<!--%s-->\n "
" Generic xml-like block comments.
let g:tcommentBlockXML = "<!--%s-->\n " "{{{2
endif
if !exists("g:tcommentInlineXML")
let g:tcommentInlineXML = "<!-- %s -->"
" Generic xml-like comments.
let g:tcommentInlineXML = "<!-- %s -->" "{{{2
endif
let s:typesDirty = 1
let s:definitions = {}
" Currently this function just sets a variable
" If you don't explicitly define a comment style, |:TComment| will use
" 'commentstring' instead. We override the default values here in order
" to have a blank after the comment marker. Block comments work only if
" we explicitly define the markup.
"
" The comment definition can be either a string or a dictionary.
"
" If it is a string:
" The format for block comments is similar to 'commentstrings' with the
" exception that the format strings for blocks can contain a second line
" that defines how "middle lines" (see :h format-comments) should be
" displayed.
"
" If it is a dictionary:
" See the help on the args argument of |tcomment#Comment|.
function! tcomment#DefineType(name, commentdef)
if !has_key(s:definitions, a:name)
if type(a:commentdef) == 4
@ -107,6 +173,7 @@ function! tcomment#DefineType(name, commentdef)
let s:typesDirty = 1
endf
" :nodoc:
" Return 1 if a comment type is defined.
function! tcomment#TypeExists(name)
return has_key(s:definitions, a:name)
@ -135,7 +202,11 @@ call tcomment#DefineType('crontab', '# %s' )
call tcomment#DefineType('cs', '// %s' )
call tcomment#DefineType('cs_inline', g:tcommentInlineC )
call tcomment#DefineType('cs_block', g:tcommentBlockC )
call tcomment#DefineType('debsources', '# %s' )
call tcomment#DefineType('debcontrol', '# %s' )
call tcomment#DefineType('desktop', '# %s' )
call tcomment#DefineType('django', '{# %s #}' )
call tcomment#DefineType('django_block', "{%% comment %%}%s{%% endcomment %%}\n ")
call tcomment#DefineType('docbk', '<!-- %s -->' )
call tcomment#DefineType('docbk_inline', g:tcommentInlineXML)
call tcomment#DefineType('docbk_block', g:tcommentBlockXML )
@ -146,8 +217,12 @@ call tcomment#DefineType('dylan', '// %s' )
call tcomment#DefineType('eiffel', '-- %s' )
call tcomment#DefineType('erlang', '%%%% %s' )
call tcomment#DefineType('eruby', '<%%# %s' )
call tcomment#DefineType('fstab', '# %s' )
call tcomment#DefineType('gitcommit', '# %s' )
call tcomment#DefineType('gtkrc', '# %s' )
call tcomment#DefineType('go', '// %s' )
call tcomment#DefineType('go_inline', g:tcommentInlineC )
call tcomment#DefineType('go_block', g:tcommentBlockC )
call tcomment#DefineType('groovy', '// %s' )
call tcomment#DefineType('groovy_inline', g:tcommentInlineC )
call tcomment#DefineType('groovy_block', g:tcommentBlockC )
@ -172,10 +247,12 @@ call tcomment#DefineType('java_doc_block', g:tcommentBlockC2 )
call tcomment#DefineType('jproperties', '# %s' )
call tcomment#DefineType('lisp', '; %s' )
call tcomment#DefineType('lynx', '# %s' )
call tcomment#DefineType('matlab', '%% %s' )
call tcomment#DefineType('m4', 'dnl %s' )
call tcomment#DefineType('mail', '> %s' )
call tcomment#DefineType('msidl', '// %s' )
call tcomment#DefineType('msidl_block', g:tcommentBlockC )
call tcomment#DefineType('nginx', '# %s' )
call tcomment#DefineType('nroff', '.\\" %s' )
call tcomment#DefineType('nsis', '# %s' )
call tcomment#DefineType('objc', '/* %s */' )
@ -189,12 +266,13 @@ call tcomment#DefineType('pascal_inline', '(* %s *)' )
call tcomment#DefineType('pascal_block', "(*%s*)\n " )
call tcomment#DefineType('perl', '# %s' )
call tcomment#DefineType('perl_block', "=cut%s=cut" )
call tcomment#DefineType('php', '// %s' )
call tcomment#DefineType('php', {'commentstring_rx': '\%%(//\|#\) %s', 'commentstring': '// %s'})
call tcomment#DefineType('php_inline', g:tcommentInlineC )
call tcomment#DefineType('php_block', g:tcommentBlockC )
call tcomment#DefineType('php_2_block', g:tcommentBlockC2 )
call tcomment#DefineType('po', '# %s' )
call tcomment#DefineType('prolog', '%% %s' )
call tcomment#DefineType('python', '# %s' )
call tcomment#DefineType('rc', '// %s' )
call tcomment#DefineType('readline', '# %s' )
call tcomment#DefineType('ruby', '# %s' )
@ -202,8 +280,12 @@ call tcomment#DefineType('ruby_3', '### %s' )
call tcomment#DefineType('ruby_block', "=begin rdoc%s=end")
call tcomment#DefineType('ruby_nodoc_block', "=begin%s=end" )
call tcomment#DefineType('r', '# %s' )
call tcomment#DefineType('samba', '# %s' )
call tcomment#DefineType('sbs', "' %s" )
call tcomment#DefineType('scheme', '; %s' )
call tcomment#DefineType('scss', '// %s' )
call tcomment#DefineType('scss_inline', g:tcommentInlineC )
call tcomment#DefineType('scss_block', g:tcommentBlockC )
call tcomment#DefineType('sed', '# %s' )
call tcomment#DefineType('sgml', '<!-- %s -->' )
call tcomment#DefineType('sgml_inline', g:tcommentInlineXML)
@ -218,6 +300,7 @@ call tcomment#DefineType('spss_block', "* %s." )
call tcomment#DefineType('tcl', '# %s' )
call tcomment#DefineType('tex', '%% %s' )
call tcomment#DefineType('tpl', '<!-- %s -->' )
call tcomment#DefineType('typoscript', '# %s' )
call tcomment#DefineType('viki', '%% %s' )
call tcomment#DefineType('viki_3', '%%%%%% %s' )
call tcomment#DefineType('viki_inline', '{cmt: %s}' )
@ -250,18 +333,25 @@ let s:nullCommentString = '%s'
" tcomment#Comment(line1, line2, ?commentMode, ?commentAnyway, ?args...)
" args... are either:
" 1. a list of key=value pairs where known keys are:
" 1. a list of key=value pairs where known keys are (see also
" |g:tcommentOptions|):
" as=STRING ... Use a specific comment definition
" col=N ... Start the comment at column N (in block mode; must
" be smaller than |indent()|)
" col=N ... Start the comment at column N (in block
" mode; must be smaller than |indent()|)
" mode=STRING ... See the notes below on the "commentMode" argument
" begin=STRING ... Comment prefix
" end=STRING ... Comment postfix
" middle=STRING ... Middle line comments in block mode
" rxbeg=N ... Regexp to find the substring of "begin" that
" should be multipied by "count"
" rxbeg=N ... Regexp to find the substring of "begin"
" that should be multipied by "count"
" rxend=N ... The above for "end"
" rxmid=N ... The above for "middle"
" commentstring_rx ... A regexp format string that matches
" commented lines (no new groups may be
" introduced, the |regexp| is |\V|; % have
" to be doubled); "commentstring", "begin"
" and optionally "end" must be defined or
" deducible.
" 2. 1-2 values for: ?commentPrefix, ?commentPostfix
" 3. a dictionary (internal use only)
"
@ -285,13 +375,14 @@ function! tcomment#Comment(beg, end, ...)
if commentMode =~# 'i'
let commentMode = substitute(commentMode, '\Ci', line("'<") == line("'>") ? 'I' : 'G', 'g')
endif
let [cstart, cend] = s:GetStartEnd(commentMode)
" TLogVAR commentMode, cstart, cend
let [lbeg, cbeg, lend, cend] = s:GetStartEnd(a:beg, a:end, commentMode)
" TLogVAR commentMode, lbeg, cbeg, lend, cend
" get the correct commentstring
let cdef = copy(g:tcommentOptions)
if a:0 >= 3 && type(a:3) == 4
let cdef = a:3
call extend(cdef, a:3)
else
let cdef = s:GetCommentDefinition(a:beg, a:end, commentMode)
call extend(cdef, s:GetCommentDefinition(lbeg, lend, commentMode))
let ax = 3
if a:0 >= 3 && a:3 != '' && stridx(a:3, '=') == -1
let ax = 4
@ -302,7 +393,7 @@ function! tcomment#Comment(beg, end, ...)
endif
endif
if a:0 >= ax
call extend(cdef, s:ParseArgs(a:beg, a:end, commentMode, a:000[ax - 1 : -1]))
call extend(cdef, s:ParseArgs(lbeg, lend, commentMode, a:000[ax - 1 : -1]))
endif
if !empty(get(cdef, 'begin', '')) || !empty(get(cdef, 'end', ''))
let cdef.commentstring = s:EncodeCommentPart(get(cdef, 'begin', ''))
@ -315,15 +406,14 @@ function! tcomment#Comment(beg, end, ...)
call s:RepeatCommentstring(cdef)
endif
" echom "DBG" string(cdef) string(a:000)
let cms0 = s:BlockGetCommentString(cdef)
let cms0 = escape(cms0, '\')
let cms0 = s:BlockGetCommentRx(cdef)
" make whitespace optional; this conflicts with comments that require some
" whitespace
let cmtCheck = substitute(cms0, '\([ ]\)', '\1\\?', 'g')
" turn commentstring into a search pattern
let cmtCheck = s:SPrintF(cmtCheck, '\(\_.\{-}\)')
let cmtCheck = printf(cmtCheck, '\(\_.\{-}\)')
" set commentMode and indentStr
let [indentStr, uncomment] = s:CommentDef(a:beg, a:end, cmtCheck, commentMode, cstart, cend)
let [indentStr, uncomment] = s:CommentDef(lbeg, lend, cmtCheck, commentMode, cbeg, cend)
" TLogVAR indentStr, uncomment
let col = get(cdef, 'col', -1)
if col >= 0
@ -341,16 +431,19 @@ function! tcomment#Comment(beg, end, ...)
" go
if commentMode =~# 'B'
" We want a comment block
call s:CommentBlock(a:beg, a:end, uncomment, cmtCheck, cdef, indentStr)
call s:CommentBlock(lbeg, lend, uncomment, cmtCheck, cdef, indentStr)
else
" call s:CommentLines(a:beg, a:end, cstart, cend, uncomment, cmtCheck, cms0, indentStr)
" call s:CommentLines(lbeg, lend, cbeg, cend, uncomment, cmtCheck, cms0, indentStr)
" We want commented lines
" final search pattern for uncommenting
let cmtCheck = escape('\V\^\(\s\{-}\)'. cmtCheck .'\$', '"/\')
" final pattern for commenting
let cmtReplace = escape(cms0, '"/')
silent exec a:beg .','. a:end .'s/\V'.
\ s:StartRx(cstart) . indentStr .'\zs\(\.\{-}\)'. s:EndRx(cend) .'/'.
let cmtReplace = s:GetCommentReplace(cdef, cms0)
" echom "DBG tcomment#Comment" lbeg .','. lend .'s/\V'.
" \ s:StartPosRx(commentMode, lbeg, cbeg) . indentStr .'\zs\(\_.\{-}\)'. s:EndPosRx(commentMode, lend, cend) .'/'.
" \ '\=s:ProcessedLine('. uncomment .', submatch(0), "'. cmtCheck .'", "'. cmtReplace .'")/ge'
exec lbeg .','. lend .'s/\V'.
\ s:StartPosRx(commentMode, lbeg, cbeg) . indentStr .'\zs\(\_.\{-}\)'. s:EndPosRx(commentMode, lend, cend) .'/'.
\ '\=s:ProcessedLine('. uncomment .', submatch(0), "'. cmtCheck .'", "'. cmtReplace .'")/ge'
endif
" reposition cursor
@ -364,12 +457,18 @@ function! tcomment#Comment(beg, end, ...)
endf
function! s:GetStartEnd(commentMode) "{{{3
function! s:GetStartEnd(beg, end, commentMode) "{{{3
if type(a:beg) == 3
let [lbeg, cbeg] = a:beg
let [lend, cend] = a:end
else
let lbeg = a:beg
let lend = a:end
let commentMode = a:commentMode
if commentMode =~# 'R' || commentMode =~# 'I'
let cstart = col("'<")
if cstart == 0
let cstart = col('.')
let cbeg = col("'<")
if cbeg == 0
let cbeg = col('.')
endif
if commentMode =~# 'R'
let commentMode = substitute(commentMode, '\CR', 'G', 'g')
@ -381,10 +480,11 @@ function! s:GetStartEnd(commentMode) "{{{3
endif
endif
else
let cstart = 0
let cbeg = 0
let cend = 0
endif
return [cstart, cend]
endif
return [lbeg, cbeg, lend, cend]
endf
@ -434,7 +534,7 @@ function! tcomment#Operator(type, ...) "{{{3
let w:tcommentPos = getpos(".")
endif
let sel_save = &selection
let &selection = "inclusive"
set selection=inclusive
let reg_save = @@
" let pos = getpos('.')
" TLogVAR a:type
@ -445,6 +545,9 @@ function! tcomment#Operator(type, ...) "{{{3
elseif a:type == 'block'
silent exe "normal! `[\<C-V>`]"
let commentMode1 = 'I'
elseif a:type == 'char' && !g:tcomment#ignore_char_type
silent exe "normal! `[v`]"
let commentMode1 = 'I'
else
silent exe "normal! `[v`]"
let commentMode1 = 'i'
@ -452,19 +555,32 @@ function! tcomment#Operator(type, ...) "{{{3
if empty(commentMode)
let commentMode = commentMode1
endif
let beg = line("'[")
let end = line("']")
let lbeg = line("'[")
let lend = line("']")
let cbeg = col("'[")
let cend = col("']")
" echom "DBG tcomment#Operator" lbeg col("'[") col("'<") lend col("']") col("'>")
norm! 
let commentMode .= g:tcommentOpModeExtra
call tcomment#Comment(beg, end, commentMode.'o', bang)
if a:type =~ 'line\|block' || g:tcomment#ignore_char_type
call tcomment#Comment(lbeg, lend, commentMode.'o', bang)
else
call tcomment#Comment([lbeg, cbeg], [lend, cend], commentMode.'o', bang)
endif
finally
let &selection = sel_save
let @@ = reg_save
if g:tcommentOpModeExtra !~ '>'
" TLogVAR pos
" call setpos('.', pos)
if exists('w:tcommentPos')
call setpos('.', w:tcommentPos)
unlet! w:tcommentPos
else
echohl WarningMsg
echom "TComment: w:tcommentPos wasn't set. Please report this to the plugin author"
echohl NONE
endif
endif
endtry
endf
@ -518,6 +634,7 @@ endf
" collect all known comment types
" :nodoc:
function! tcomment#CollectFileTypes()
if s:typesDirty
let s:types = keys(s:definitions)
@ -530,12 +647,14 @@ call tcomment#CollectFileTypes()
" return a list of filetypes for which a tcomment_{&ft} is defined
" :nodoc:
function! tcomment#Complete(ArgLead, CmdLine, CursorPos) "{{{3
call tcomment#CollectFileTypes()
let completions = copy(s:types)
if index(completions, &filetype) != -1
" TLogVAR &filetype
call insert(completions, &filetype)
let filetype = s:Filetype()
if index(completions, filetype) != -1
" TLogVAR filetype
call insert(completions, filetype)
endif
if !empty(a:ArgLead)
call filter(completions, 'v:val =~ ''\V\^''.a:ArgLead')
@ -545,6 +664,7 @@ function! tcomment#Complete(ArgLead, CmdLine, CursorPos) "{{{3
endf
" :nodoc:
function! tcomment#CompleteArgs(ArgLead, CmdLine, CursorPos) "{{{3
let completions = ['as=', 'col=', 'count=', 'mode=', 'begin=', 'end=']
if !empty(a:ArgLead)
@ -587,67 +707,57 @@ function! s:GetCommentDefinition(beg, end, commentMode, ...)
endif
let cms = get(cdef, 'commentstring', '')
if empty(cms)
let filetype = s:Filetype()
if exists('b:commentstring')
let cms = b:commentstring
return s:GetCustomCommentString(&filetype, a:commentMode, cms)
return s:GetCustomCommentString(filetype, a:commentMode, cms)
elseif exists('b:commentStart') && b:commentStart != ''
let cms = s:EncodeCommentPart(b:commentStart) .' %s'
if exists('b:commentEnd') && b:commentEnd != ''
let cms = cms .' '. s:EncodeCommentPart(b:commentEnd)
endif
return s:GetCustomCommentString(&filetype, a:commentMode, cms)
elseif g:tcommentGuessFileType || (exists('g:tcommentGuessFileType_'. &filetype)
\ && g:tcommentGuessFileType_{&filetype} =~ '[^0]')
if g:tcommentGuessFileType_{&filetype} == 1
return s:GetCustomCommentString(filetype, a:commentMode, cms)
elseif g:tcommentGuessFileType || (exists('g:tcommentGuessFileType_'. filetype)
\ && g:tcommentGuessFileType_{filetype} =~ '[^0]')
if g:tcommentGuessFileType_{filetype} == 1
let altFiletype = ''
else
let altFiletype = g:tcommentGuessFileType_{&filetype}
let altFiletype = g:tcommentGuessFileType_{filetype}
endif
return s:GuessFileType(a:beg, a:end, a:commentMode, &filetype, altFiletype)
return s:GuessFileType(a:beg, a:end, a:commentMode, filetype, altFiletype)
else
return s:GetCustomCommentString(&filetype, a:commentMode, s:GuessCurrentCommentString(a:commentMode))
return s:GetCustomCommentString(filetype, a:commentMode, s:GuessCurrentCommentString(a:commentMode))
endif
let cdef.commentstring = cms
endif
return cdef
endf
" s:SPrintF(formatstring, ?values ...)
" => string
function! s:SPrintF(string, ...)
let n = 1
let r = ''
let s = a:string
while 1
let i = match(s, '%\(.\)')
if i >= 0
let x = s[i + 1]
let r = r . strpart(s, 0, i)
let s = strpart(s, i + 2)
if x == '%'
let r = r.'%'
function! s:StartPosRx(mode, line, col)
if a:mode =~# 'I'
return s:StartLineRx(a:line) . s:StartColRx(a:col)
else
if a:0 >= n
let v = a:{n}
let n = n + 1
else
echoerr 'Malformed format string (too many arguments required): '. a:string
return s:StartColRx(a:col)
endif
if x ==# 's'
let r = r.v
elseif x ==# 'S'
let r = r.'"'.v.'"'
else
echoerr 'Malformed format string: '. a:string
endif
endif
else
return r.s
endif
endwh
endf
function! s:StartRx(pos)
function! s:EndPosRx(mode, line, col)
if a:mode =~# 'I'
return s:EndLineRx(a:line) . s:EndColRx(a:col)
else
return s:EndColRx(a:col)
endif
endf
function! s:StartLineRx(pos)
return '\%'. a:pos .'l'
endf
function! s:EndLineRx(pos)
return '\%'. a:pos .'l'
endf
function! s:StartColRx(pos)
if a:pos == 0
return '\^'
else
@ -655,7 +765,7 @@ function! s:StartRx(pos)
endif
endf
function! s:EndRx(pos)
function! s:EndColRx(pos)
if a:pos == 0
return '\$'
else
@ -669,7 +779,8 @@ function! s:GetIndentString(line, start)
endf
function! s:CommentDef(beg, end, checkRx, commentMode, cstart, cend)
let mdrx = '\V'. s:StartRx(a:cstart) .'\s\*'. a:checkRx .'\s\*'. s:EndRx(0)
let mdrx = '\V'. s:StartColRx(a:cstart) .'\s\*'. a:checkRx .'\s\*'. s:EndColRx(0)
" let mdrx = '\V'. s:StartPosRx(a:commentMode, a:beg, a:cstart) .'\s\*'. a:checkRx .'\s\*'. s:EndPosRx(a:commentMode, a:end, 0)
let line = getline(a:beg)
if a:cstart != 0 && a:cend != 0
let line = strpart(line, 0, a:cend - 1)
@ -714,32 +825,35 @@ function! s:ProcessedLine(uncomment, match, checkRx, replace)
if a:uncomment
let rv = substitute(a:match, a:checkRx, '\1\2', '')
else
let rv = s:SPrintF(a:replace, a:match)
let rv = printf(a:replace, a:match)
endif
" TLogVAR rv
" let md = len(rv) - ml
let s:pos_end = getpos('.')
let s:pos_end[2] += len(rv)
" TLogVAR pe, md, a:match
" TLogVAR rv
if v:version > 702 || (v:version == 702 && has('patch407'))
let rv = escape(rv, ' ')
else
let rv = escape(rv, '\ ')
endif
let rv = substitute(rv, '\n', '\\\n', 'g')
" TLogVAR rv
" let rv = substitute(rv, '\n', '\\\n', 'g')
" TLogVAR rv
return rv
endf
function! s:CommentLines(beg, end, cstart, cend, uncomment, cmtCheck, cms0, indentStr) "{{{3
" We want commented lines
" final search pattern for uncommenting
let cmtCheck = escape('\V\^\(\s\{-}\)'. a:cmtCheck .'\$', '"/\')
" final pattern for commenting
let cmtReplace = escape(a:cms0, '"/')
silent exec a:beg .','. a:end .'s/\V'.
\ s:StartRx(a:cstart) . a:indentStr .'\zs\(\.\{-}\)'. s:EndRx(a:cend) .'/'.
\ '\=s:ProcessedLine('. a:uncomment .', submatch(0), "'. a:cmtCheck .'", "'. cmtReplace .'")/ge'
endf
" function! s:CommentLines(beg, end, cstart, cend, uncomment, cmtCheck, cms0, indentStr) "{{{3
" " We want commented lines
" " final search pattern for uncommenting
" let cmtCheck = escape('\V\^\(\s\{-}\)'. a:cmtCheck .'\$', '"/\')
" " final pattern for commenting
" let cmtReplace = escape(a:cms0, '"/')
" silent exec a:beg .','. a:end .'s/\V'.
" \ s:StartColRx(a:cstart) . a:indentStr .'\zs\(\.\{-}\)'. s:EndColRx(a:cend) .'/'.
" \ '\=s:ProcessedLine('. a:uncomment .', submatch(0), "'. a:cmtCheck .'", "'. cmtReplace .'")/ge'
" endf
function! s:CommentBlock(beg, end, uncomment, checkRx, cdef, indentStr)
let t = @t
@ -763,7 +877,7 @@ function! s:CommentBlock(beg, end, uncomment, checkRx, cdef, indentStr)
let @t = substitute(@t, '^'. a:indentStr, '', 'g')
let @t = ms . substitute(@t, '\n'. a:indentStr, '\n'. mx, 'g')
endif
let @t = s:SPrintF(cs, "\n". @t ."\n")
let @t = printf(cs, "\n". @t ."\n")
endif
silent norm! "tP
finally
@ -771,6 +885,14 @@ function! s:CommentBlock(beg, end, uncomment, checkRx, cdef, indentStr)
endtry
endf
function! s:Filetype(...) "{{{3
let ft = a:0 >= 1 ? a:1 : &filetype
let ft = substitute(ft, '\..*$', '', '')
return ft
endf
" inspired by Meikel Brandmeyer's EnhancedCommentify.vim
" this requires that a syntax names are prefixed by the filetype name
" s:GuessFileType(beg, end, commentMode, filetype, ?fallbackFiletype)
@ -790,7 +912,7 @@ function! s:GuessFileType(beg, end, commentMode, filetype, ...)
let le = len(getline(n))
" TLogVAR m, le
while m < le
let syntaxName = synIDattr(synID(n, m, 1), 'name')
let syntaxName = s:GetSyntaxName(n, m)
" TLogVAR syntaxName, n, m
let ftypeMap = get(g:tcommentSyntaxMap, syntaxName)
if !empty(ftypeMap)
@ -815,6 +937,21 @@ function! s:GuessFileType(beg, end, commentMode, filetype, ...)
return cdef
endf
function! s:GetSyntaxName(lnum, col) "{{{3
let syntaxName = synIDattr(synID(a:lnum, a:col, 1), 'name')
if !empty(g:tcomment#syntax_substitute)
for [rx, subdef] in items(g:tcomment#syntax_substitute)
if !has_key(subdef, 'if') || eval(subdef.if)
let syntaxName = substitute(syntaxName, rx, subdef.sub, 'g')
endif
endfor
endif
" TLogVAR syntaxName
return syntaxName
endf
function! s:CommentMode(commentMode, newmode) "{{{3
return substitute(a:commentMode, '\w\+', a:newmode, 'g')
endf
@ -896,6 +1033,25 @@ function! s:GetCustomCommentString(ft, commentMode, ...)
return cdef
endf
function! s:GetCommentReplace(cdef, cms0)
if has_key(a:cdef, 'commentstring_rx')
let rs = s:BlockGetCommentString(a:cdef)
else
let rs = a:cms0
endif
return escape(rs, '"/')
endf
function! s:BlockGetCommentRx(cdef)
if has_key(a:cdef, 'commentstring_rx')
return a:cdef.commentstring_rx
else
let cms0 = s:BlockGetCommentString(a:cdef)
let cms0 = escape(cms0, '\')
return cms0
endif
endf
function! s:BlockGetCommentString(cdef)
if has_key(a:cdef, 'middle')
return a:cdef.commentstring

View File

@ -1514,6 +1514,22 @@ g:netrw_use_nt_rcp pi_netrw.txt /*g:netrw_use_nt_rcp*
g:netrw_win95ftp pi_netrw.txt /*g:netrw_win95ftp*
g:netrw_winsize pi_netrw.txt /*g:netrw_winsize*
g:netrw_xstrlen pi_netrw.txt /*g:netrw_xstrlen*
g:tcomment#ignore_char_type tcomment.txt /*g:tcomment#ignore_char_type*
g:tcomment#syntax_substitute tcomment.txt /*g:tcomment#syntax_substitute*
g:tcommentBlankLines tcomment.txt /*g:tcommentBlankLines*
g:tcommentBlockC tcomment.txt /*g:tcommentBlockC*
g:tcommentBlockC2 tcomment.txt /*g:tcommentBlockC2*
g:tcommentBlockXML tcomment.txt /*g:tcommentBlockXML*
g:tcommentGuessFileType tcomment.txt /*g:tcommentGuessFileType*
g:tcommentGuessFileType_django tcomment.txt /*g:tcommentGuessFileType_django*
g:tcommentGuessFileType_dsl tcomment.txt /*g:tcommentGuessFileType_dsl*
g:tcommentGuessFileType_html tcomment.txt /*g:tcommentGuessFileType_html*
g:tcommentGuessFileType_php tcomment.txt /*g:tcommentGuessFileType_php*
g:tcommentGuessFileType_tskeleton tcomment.txt /*g:tcommentGuessFileType_tskeleton*
g:tcommentGuessFileType_vim tcomment.txt /*g:tcommentGuessFileType_vim*
g:tcommentIgnoreTypes_php tcomment.txt /*g:tcommentIgnoreTypes_php*
g:tcommentInlineC tcomment.txt /*g:tcommentInlineC*
g:tcommentInlineXML tcomment.txt /*g:tcommentInlineXML*
g:tcommentMapLeader1 tComment.txt /*g:tcommentMapLeader1*
g:tcommentMapLeader2 tComment.txt /*g:tcommentMapLeader2*
g:tcommentMapLeaderOp1 tComment.txt /*g:tcommentMapLeaderOp1*
@ -1522,6 +1538,8 @@ g:tcommentMapLeaderOp2 tComment.txt /*g:tcommentMapLeaderOp2*
g:tcommentMapLeaderOp2 tcomment.txt /*g:tcommentMapLeaderOp2*
g:tcommentOpModeExtra tComment.txt /*g:tcommentOpModeExtra*
g:tcommentOpModeExtra tcomment.txt /*g:tcommentOpModeExtra*
g:tcommentOptions tcomment.txt /*g:tcommentOptions*
g:tcommentSyntaxMap tcomment.txt /*g:tcommentSyntaxMap*
g:vimball_home pi_vimball.txt /*g:vimball_home*
g:vimball_mkdir pi_vimball.txt /*g:vimball_mkdir*
g:visincr_datedivset visincr.txt /*g:visincr_datedivset*
@ -1782,17 +1800,13 @@ tComment-Key-Bindings tComment.txt /*tComment-Key-Bindings*
tComment-Usage tComment.txt /*tComment-Usage*
tComment-commands tComment.txt /*tComment-commands*
tComment.txt tComment.txt /*tComment.txt*
tcomment#CollectFileTypes() tcomment.txt /*tcomment#CollectFileTypes()*
tcomment#Comment() tcomment.txt /*tcomment#Comment()*
tcomment#CommentAs() tcomment.txt /*tcomment#CommentAs()*
tcomment#Complete() tcomment.txt /*tcomment#Complete()*
tcomment#CompleteArgs() tcomment.txt /*tcomment#CompleteArgs()*
tcomment#DefineType() tcomment.txt /*tcomment#DefineType()*
tcomment#Operator() tcomment.txt /*tcomment#Operator()*
tcomment#OperatorAnyway() tcomment.txt /*tcomment#OperatorAnyway()*
tcomment#OperatorLine() tcomment.txt /*tcomment#OperatorLine()*
tcomment#OperatorLineAnyway() tcomment.txt /*tcomment#OperatorLineAnyway()*
tcomment#TypeExists() tcomment.txt /*tcomment#TypeExists()*
tcomment-maps tcomment.txt /*tcomment-maps*
tcomment.txt tcomment.txt /*tcomment.txt*
v_[% matchit.txt /*v_[%*
@ -1806,6 +1820,7 @@ vimball-extract pi_vimball.txt /*vimball-extract*
vimball-history pi_vimball.txt /*vimball-history*
vimball-intro pi_vimball.txt /*vimball-intro*
vimball-manual pi_vimball.txt /*vimball-manual*
vimball-windows pi_vimball.txt /*vimball-windows*
viscinr-I visincr.txt /*viscinr-I*
viscinr-contents visincr.txt /*viscinr-contents*
visincr visincr.txt /*visincr*

View File

@ -15,6 +15,9 @@ override the default choice.
TComment can properly handle an embedded syntax, e.g., ruby/python/perl
regions in vim scripts, HTML or JavaScript in php code etc.
Demo:
http://vimsomnia.blogspot.com/2010/11/tcomment-vim-plugin.html
*tcomment-maps*
Key bindings~
@ -34,9 +37,8 @@ and g:tcommentMapLeaderOp2):
gC{motion} :: Comment region
gCc :: Comment the current line
*g:tcommentOpModeExtra*
By default the cursor stays put. If you want the cursor to the end of
the commented text, set g:tcommentOpModeExtra to '>' (but this may not
the commented text, set |g:tcommentOpModeExtra| to '>' (but this may not
work properly with exclusive motions).
Primary key maps:
@ -79,23 +81,38 @@ please make sure, you have the current version of vimball (vimscript
========================================================================
Contents~
:TComment ..................... |:TComment|
:TCommentAs ................... |:TCommentAs|
:TCommentRight ................ |:TCommentRight|
:TCommentBlock ................ |:TCommentBlock|
:TCommentInline ............... |:TCommentInline|
:TCommentMaybeInline .......... |:TCommentMaybeInline|
tcomment#DefineType ........... |tcomment#DefineType()|
tcomment#TypeExists ........... |tcomment#TypeExists()|
tcomment#Comment .............. |tcomment#Comment()|
tcomment#Operator ............. |tcomment#Operator()|
tcomment#OperatorLine ......... |tcomment#OperatorLine()|
tcomment#OperatorAnyway ....... |tcomment#OperatorAnyway()|
tcomment#OperatorLineAnyway ... |tcomment#OperatorLineAnyway()|
tcomment#CommentAs ............ |tcomment#CommentAs()|
tcomment#CollectFileTypes ..... |tcomment#CollectFileTypes()|
tcomment#Complete ............. |tcomment#Complete()|
tcomment#CompleteArgs ......... |tcomment#CompleteArgs()|
:TComment ........................... |:TComment|
:TCommentAs ......................... |:TCommentAs|
:TCommentRight ...................... |:TCommentRight|
:TCommentBlock ...................... |:TCommentBlock|
:TCommentInline ..................... |:TCommentInline|
:TCommentMaybeInline ................ |:TCommentMaybeInline|
g:tcommentBlankLines ................ |g:tcommentBlankLines|
g:tcommentOpModeExtra ............... |g:tcommentOpModeExtra|
g:tcommentOptions ................... |g:tcommentOptions|
g:tcomment#ignore_char_type ......... |g:tcomment#ignore_char_type|
g:tcommentGuessFileType ............. |g:tcommentGuessFileType|
g:tcommentGuessFileType_dsl ......... |g:tcommentGuessFileType_dsl|
g:tcommentGuessFileType_php ......... |g:tcommentGuessFileType_php|
g:tcommentGuessFileType_html ........ |g:tcommentGuessFileType_html|
g:tcommentGuessFileType_tskeleton ... |g:tcommentGuessFileType_tskeleton|
g:tcommentGuessFileType_vim ......... |g:tcommentGuessFileType_vim|
g:tcommentGuessFileType_django ...... |g:tcommentGuessFileType_django|
g:tcommentIgnoreTypes_php ........... |g:tcommentIgnoreTypes_php|
g:tcomment#syntax_substitute ........ |g:tcomment#syntax_substitute|
g:tcommentSyntaxMap ................. |g:tcommentSyntaxMap|
g:tcommentBlockC .................... |g:tcommentBlockC|
g:tcommentBlockC2 ................... |g:tcommentBlockC2|
g:tcommentInlineC ................... |g:tcommentInlineC|
g:tcommentBlockXML .................. |g:tcommentBlockXML|
g:tcommentInlineXML ................. |g:tcommentInlineXML|
tcomment#DefineType ................. |tcomment#DefineType()|
tcomment#Comment .................... |tcomment#Comment()|
tcomment#Operator ................... |tcomment#Operator()|
tcomment#OperatorLine ............... |tcomment#OperatorLine()|
tcomment#OperatorAnyway ............. |tcomment#OperatorAnyway()|
tcomment#OperatorLineAnyway ......... |tcomment#OperatorLineAnyway()|
tcomment#CommentAs .................. |tcomment#CommentAs()|
========================================================================
@ -163,30 +180,146 @@ plugin/tcomment.vim~
========================================================================
autoload/tcomment.vim~
*g:tcommentBlankLines*
g:tcommentBlankLines (default: 1)
If true, comment blank lines too
*g:tcommentOpModeExtra*
g:tcommentOpModeExtra (default: '')
Modifies how the operator works.
> ... Move the cursor to the end of the comment
*g:tcommentOptions*
g:tcommentOptions (default: {})
Other key-value options used by |tcomment#Comment()|.
Example: If you want to put the opening comment marker always in
the first column regardless of the block's indentation, put this
into your |vimrc| file: >
let g:tcommentOptions = {'col': 1}
<
*g:tcomment#ignore_char_type*
g:tcomment#ignore_char_type (default: 1)
|text-objects| for use with |tcomment#Operator| can have different
types: line, block, char etc. Text objects like aB, it, at etc.
have type char but this may not work reliably. By default,
tcomment handles those text objects most often as if they were of
type line. Set this variable to 0 in order to change this
behaviour. Be prepared that the result may not always match your
intentions.
*g:tcommentGuessFileType*
g:tcommentGuessFileType (default: 0)
Guess the file type based on syntax names always or for some fileformat only
If non-zero, try to guess filetypes.
tcomment also checks g:tcommentGuessFileType_{&filetype} for
filetype specific values.
Values:
0 ... don't guess
1 ... guess
FILETYPE ... assume this filetype
*g:tcommentGuessFileType_dsl*
g:tcommentGuessFileType_dsl (default: 'xml')
For dsl documents, assumet filetype = xml.
*g:tcommentGuessFileType_php*
g:tcommentGuessFileType_php (default: 'html')
In php documents, the php part is usually marked as phpRegion. We
thus assume that the buffers default comment style isn't php but
html.
*g:tcommentGuessFileType_html*
g:tcommentGuessFileType_html (default: 1)
*g:tcommentGuessFileType_tskeleton*
g:tcommentGuessFileType_tskeleton (default: 1)
*g:tcommentGuessFileType_vim*
g:tcommentGuessFileType_vim (default: 1)
*g:tcommentGuessFileType_django*
g:tcommentGuessFileType_django (default: 1)
*g:tcommentIgnoreTypes_php*
g:tcommentIgnoreTypes_php (default: 'sql')
In php files, some syntax regions are wongly highlighted as sql
markup. We thus ignore sql syntax when guessing the filetype in
php files.
*g:tcomment#syntax_substitute*
g:tcomment#syntax_substitute (default: {...})
*g:tcommentSyntaxMap*
g:tcommentSyntaxMap (default: {...})
tcomment guesses filetypes based on the name of the current syntax
region. This works well if the syntax names match
/filetypeSomeName/. Other syntax names have to be explicitly
mapped onto the corresponding filetype.
*g:tcommentBlockC*
g:tcommentBlockC (default: {...})
Generic c-like block comments.
*g:tcommentBlockC2*
g:tcommentBlockC2 (default: {...})
Generic c-like block comments (alternative markup).
*g:tcommentInlineC*
g:tcommentInlineC (default: "/* %s */")
Generic c-like comments.
*g:tcommentBlockXML*
g:tcommentBlockXML (default: "<!--%s-->\n ")
Generic xml-like block comments.
*g:tcommentInlineXML*
g:tcommentInlineXML (default: "<!-- %s -->")
Generic xml-like comments.
*tcomment#DefineType()*
tcomment#DefineType(name, commentdef)
Currently this function just sets a variable
If you don't explicitly define a comment style, |:TComment| will use
'commentstring' instead. We override the default values here in order
to have a blank after the comment marker. Block comments work only if
we explicitly define the markup.
*tcomment#TypeExists()*
tcomment#TypeExists(name)
Return 1 if a comment type is defined.
The comment definition can be either a string or a dictionary.
If it is a string:
The format for block comments is similar to 'commentstrings' with the
exception that the format strings for blocks can contain a second line
that defines how "middle lines" (see :h format-comments) should be
displayed.
If it is a dictionary:
See the help on the args argument of |tcomment#Comment|.
*tcomment#Comment()*
tcomment#Comment(beg, end, ...)
tcomment#Comment(line1, line2, ?commentMode, ?commentAnyway, ?args...)
args... are either:
1. a list of key=value pairs where known keys are:
1. a list of key=value pairs where known keys are (see also
|g:tcommentOptions|):
as=STRING ... Use a specific comment definition
col=N ... Start the comment at column N (in block mode; must
be smaller than |indent()|)
col=N ... Start the comment at column N (in block
mode; must be smaller than |indent()|)
mode=STRING ... See the notes below on the "commentMode" argument
begin=STRING ... Comment prefix
end=STRING ... Comment postfix
middle=STRING ... Middle line comments in block mode
rxbeg=N ... Regexp to find the substring of "begin" that
should be multipied by "count"
rxbeg=N ... Regexp to find the substring of "begin"
that should be multipied by "count"
rxend=N ... The above for "end"
rxmid=N ... The above for "middle"
commentstring_rx ... A regexp format string that matches
commented lines (no new groups may be
introduced, the |regexp| is |\V|; % have
to be doubled); "commentstring", "begin"
and optionally "end" must be defined or
deducible.
2. 1-2 values for: ?commentPrefix, ?commentPostfix
3. a dictionary (internal use only)
@ -221,17 +354,6 @@ tcomment#CommentAs(beg, end, commentAnyway, filetype, ?args...)
|tcomment#Comment()|)
comment text as if it were of a specific filetype
*tcomment#CollectFileTypes()*
tcomment#CollectFileTypes()
collect all known comment types
*tcomment#Complete()*
tcomment#Complete(ArgLead, CmdLine, CursorPos)
return a list of filetypes for which a tcomment_{&ft} is defined
*tcomment#CompleteArgs()*
tcomment#CompleteArgs(ArgLead, CmdLine, CursorPos)
vim:tw=78:fo=tcq2:isk=!-~,^*,^|,^":ts=8:ft=help:norl:

View File

@ -2,15 +2,14 @@
" @Author: Tom Link (micathom AT gmail com)
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 27-Dez-2004.
" @Last Change: 2010-10-02.
" @Revision: 709
"
" GetLatestVimScripts: 1173 1 tComment.vim
" @Last Change: 2011-05-26.
" @Revision: 720
" GetLatestVimScripts: 1173 1 tcomment.vim
if &cp || exists('loaded_tcomment')
finish
endif
let loaded_tcomment = 201
let loaded_tcomment = 205
if !exists("g:tcommentMapLeader1")
" g:tcommentMapLeader1 should be a shortcut that can be used with
@ -28,9 +27,6 @@ endif
if !exists("g:tcommentMapLeaderOp2")
let g:tcommentMapLeaderOp2 = 'gC'
endif
if !exists("g:tcommentOpModeExtra")
let g:tcommentOpModeExtra = ''
endif
" :display: :[range]TComment[!] ?ARGS...
@ -144,112 +140,3 @@ if (g:tcommentMapLeaderOp2 != '')
exec 'xnoremap <silent> '. g:tcommentMapLeaderOp2 .' :TCommentMaybeInline<cr>'
endif
finish
-----------------------------------------------------------------------
History
0.1
- Initial release
0.2
- Fixed uncommenting of non-aligned comments
- improved support for block comments (with middle lines and indentation)
- using TCommentBlock for file types that don't have block comments creates
single line comments
- removed the TCommentAsBlock command (TCommentAs provides its functionality)
- removed g:tcommentSetCMS
- the default key bindings have slightly changed
1.3
- slightly improved recognition of embedded syntax
- if no commentstring is defined in whatever way, reconstruct one from
&comments
- The TComment... commands now have bang variants that don't act as toggles
but always comment out the selected text
- fixed problem with commentstrings containing backslashes
- comment as visual block (allows commenting text to the right of the main
text, i.e., this command doesn't work on whole lines but on the text to the
right of the cursor)
- enable multimode for dsl, vim filetypes
- added explicit support for some other file types I ran into
1.4
- Fixed problem when &commentstring was invalid (e.g. lua)
- perl_block by Kyosuke Takayama.
- <c-_>s mapped to :TCommentAs <c-r>=&ft<cr>
1.5
- "Inline" visual comments (uses the &filetype_inline style if
available; doesn't check if the filetype actually supports this kind of
comments); tComment can't currently deduce inline comment styles from
&comments or &commentstring (I personally hardly ever use them); default
map: <c-_>i or <c-_>I
- In visual mode: if the selection spans several lines, normal mode is
selected; if the selection covers only a part of one line, inline mode
is selected
- Fixed problem with lines containing ^M or ^@ characters.
- It's no longer necessary to call TCommentCollectFileTypes() after
defining a new filetype via TCommentDefineType()
- Disabled single <c-_> mappings
- Renamed TCommentVisualBlock to TCommentRight
- FIX: Forgot 'x' in ExtractCommentsPart() (thanks to Fredrik Acosta)
1.6
- Ignore sql when guessing the comment string in php files; tComment
sometimes chooses the wrong comment string because the use of sql syntax
is used too loosely in php files; if you want to comment embedded sql
code you have to use TCommentAs
- Use keepjumps in commands.
- Map <c-_>p & <L>_p to vip:TComment<cr>
- Made key maps configurable via g:tcommentMapLeader1 and
g:tcommentMapLeader2
1.7
- gc{motion} (see g:tcommentMapLeaderOp1) functions as a comment toggle
operator (i.e., something like gcl... works, mostly); gC{motion} (see
g:tcommentMapLeaderOp2) will unconditionally comment the text.
- TCommentAs takes an optional second argument (the comment level)
- New "n" map: TCommentAs &filetype [COUNT]
- Defined mail comments/citations
- g:tcommentSyntaxMap: Map syntax names to filetypes for buffers with
mixed syntax groups that don't match the filetypeEmbeddedsyntax scheme (e.g.
'vimRubyRegion', which should be commented as ruby syntax, not as vim
syntax)
- FIX: Comments in vim*Region
- TComment: The use of the type argument has slightly changed (IG -> i,
new: >)
1.8
- Definitly require vim7
- Split the plugin into autoload & plugin.
- g:TCommentFileTypes is a list
- Fixed some block comment strings
- Removed extraneous newline in some block comments.
- Maps for visal mode (thanks Krzysztof Goj)
1.9
- Fix left offset for inline comments (via operator binding)
1.10
- tcomment#Operator defines w:tcommentPos if invoked repeatedly
- s:GuessFileType: use len(getline()) instead of col()
1.11
- Support for erlang (thanks to Zhang Jinzhu)
1.12
- Moved the definition of some variables from plugin/tComment.vim to
autoload/tcomment.vim
- Changed comment string for eruby (proposed by Vinicius Baggio)
- Support for x86conf
2.0
- Enabled key=value pairs to configure commenting
- Renamed the file plugin/tComment.vim to plugin/tcomment.vim
- Renamed certain global functions to tcomment#...
2.1
- FIX