GetLatestVimScripts
git-svn-id: https://vimsuite.svn.sourceforge.net/svnroot/vimsuite/trunk@192 eb2d0018-73a3-4aeb-bfe9-1def61c9ec69
This commit is contained in:
parent
08fed3134c
commit
fa46615dad
@ -7,14 +7,14 @@ ScriptID SourceID Filename
|
|||||||
670 8073 visincr.vim (Visual Increment)
|
670 8073 visincr.vim (Visual Increment)
|
||||||
862 2635 cscope_quickfix.vim
|
862 2635 cscope_quickfix.vim
|
||||||
51 171 cscope_macros.vim
|
51 171 cscope_macros.vim
|
||||||
102 9375 DirDiff.vim
|
102 13435 DirDiff.vim
|
||||||
1189 8687 matrix.vim
|
1189 8687 matrix.vim
|
||||||
1173 11513 tcomment
|
1173 13972 tcomment
|
||||||
948 2878 Scons Compiler plugin
|
948 2878 Scons Compiler plugin
|
||||||
1709 6421 Scons Syntax file
|
1709 6421 Scons Syntax file
|
||||||
1772 7248 DAMOS.zip DAMOS tools (von Stefan)
|
1772 7248 DAMOS.zip DAMOS tools (von Stefan)
|
||||||
987 11878 DoxygenToolkit.vim
|
987 14064 DoxygenToolkit.vim
|
||||||
1397 11713 xml.vim
|
1397 14039 xml.vim
|
||||||
1290 5190 LogiPat.vim
|
1290 5190 LogiPat.vim
|
||||||
1462 5612 dtd2xml
|
1462 5612 dtd2xml
|
||||||
1046 4249 Lusty Explorer
|
1046 4249 Lusty Explorer
|
||||||
@ -27,8 +27,8 @@ ScriptID SourceID Filename
|
|||||||
294 10110 Align.vim
|
294 10110 Align.vim
|
||||||
479 9276 MultipleSearch.vba
|
479 9276 MultipleSearch.vba
|
||||||
1066 7618 cecutil.vim
|
1066 7618 cecutil.vim
|
||||||
1173 11513 tComment.vim
|
1173 13972 tComment.vim
|
||||||
2701 10950 editsrec
|
2701 13194 editsrec
|
||||||
642 8136 :AutoInstall: getscript.vim
|
642 8136 :AutoInstall: getscript.vim
|
||||||
1075 11979 :AutoInstall: netrw.vim
|
1075 11979 :AutoInstall: netrw.vim
|
||||||
1502 11981 :AutoInstall: vimball.vim
|
1502 11981 :AutoInstall: vimball.vim
|
||||||
|
@ -4,6 +4,11 @@
|
|||||||
" License: This File is placed in the Public Domain.
|
" License: This File is placed in the Public Domain.
|
||||||
" Revision | Date [DD.MM.YY] | Changes
|
" Revision | Date [DD.MM.YY] | Changes
|
||||||
" 00.01.00 | 05.07.09 | 01. Revision
|
" 00.01.00 | 05.07.09 | 01. Revision
|
||||||
|
" 00.01.10 | 29.03.10 | BugFix, in libsrec#CrCS()
|
||||||
|
" | | leading Zeros in Result
|
||||||
|
" 00.02.00 | 29.03.10 | Fun added, MkS5()
|
||||||
|
" 00.02.10 | 15.06.10 | BugFix, in libsrec#CrCS()
|
||||||
|
" | | wrong Source for CS
|
||||||
|
|
||||||
" create ByteCount
|
" create ByteCount
|
||||||
fun libsrec#CrBC(line)
|
fun libsrec#CrBC(line)
|
||||||
@ -141,6 +146,15 @@ fun libsrec#CrCS(line)
|
|||||||
let s:csby = s:csby / 16
|
let s:csby = s:csby / 16
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
|
" add missing Zeros
|
||||||
|
while strlen(s:chsu) < 2
|
||||||
|
let s:chsu = "0" . s:chsu
|
||||||
|
endwhile
|
||||||
|
" Exception Handling
|
||||||
|
if strlen(s:chsu) > 2
|
||||||
|
let s:chsu = "CS"
|
||||||
|
endif
|
||||||
|
|
||||||
unlet s:hxva
|
unlet s:hxva
|
||||||
unlet s:csby
|
unlet s:csby
|
||||||
endif
|
endif
|
||||||
@ -150,3 +164,50 @@ fun libsrec#CrCS(line)
|
|||||||
return s:chsu
|
return s:chsu
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
|
" make S5 record
|
||||||
|
fun libsrec#MkS5(line)
|
||||||
|
let s:srec = ""
|
||||||
|
let s:line = ""
|
||||||
|
let s:srco = 0
|
||||||
|
let s:srad = ""
|
||||||
|
|
||||||
|
let s:srec = s:srec . "S5" . "03"
|
||||||
|
|
||||||
|
let s:n = 1
|
||||||
|
while (line2byte(s:n) != line2byte("."))
|
||||||
|
let s:line = getline(s:n)
|
||||||
|
if ((s:line[0] == "S") && ((s:line[1] == "1") || (s:line[1] == "2") || (s:line[1] == "3")))
|
||||||
|
let s:srco = s:srco + 1
|
||||||
|
endif
|
||||||
|
let s:n = s:n + 1
|
||||||
|
endwhile
|
||||||
|
unlet s:n
|
||||||
|
|
||||||
|
" convert to Hex Value,
|
||||||
|
" Hex String without "0x"
|
||||||
|
let s:hxva = "0123456789ABCDEF"
|
||||||
|
while s:srco
|
||||||
|
let s:srad = s:hxva[s:srco % 16] . s:srad
|
||||||
|
let s:srco = s:srco / 16
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
" add missing Zeros
|
||||||
|
while strlen(s:srad) < 4
|
||||||
|
let s:srad = "0" . s:srad
|
||||||
|
endwhile
|
||||||
|
" Exception Handling
|
||||||
|
if strlen(s:srad) > 4
|
||||||
|
let s:srad = "AAAA"
|
||||||
|
endif
|
||||||
|
|
||||||
|
unlet s:hxva
|
||||||
|
|
||||||
|
let s:srec = s:srec . s:srad . libsrec#CrCS(s:srec . s:srad)
|
||||||
|
|
||||||
|
unlet s:srad
|
||||||
|
unlet s:srco
|
||||||
|
unlet s:line
|
||||||
|
"unlet s:srec
|
||||||
|
return s:srec
|
||||||
|
endfun
|
||||||
|
|
||||||
|
@ -3,13 +3,237 @@
|
|||||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||||
" @Created: 2007-09-17.
|
" @Created: 2007-09-17.
|
||||||
" @Last Change: 2009-02-15.
|
" @Last Change: 2010-09-29.
|
||||||
" @Revision: 0.0.66
|
" @Revision: 0.0.249
|
||||||
|
|
||||||
if &cp || exists("loaded_tcomment_autoload")
|
" call tlog#Log('Load: '. expand('<sfile>')) " vimtlib-sfile
|
||||||
finish
|
|
||||||
|
|
||||||
|
" If true, comment blank lines too
|
||||||
|
if !exists("g:tcommentBlankLines")
|
||||||
|
let g:tcommentBlankLines = 1
|
||||||
endif
|
endif
|
||||||
let loaded_tcomment_autoload = 1
|
|
||||||
|
" Guess the file type based on syntax names always or for some fileformat only
|
||||||
|
if !exists("g:tcommentGuessFileType")
|
||||||
|
let g:tcommentGuessFileType = 0
|
||||||
|
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'
|
||||||
|
endif
|
||||||
|
if !exists("g:tcommentGuessFileType_php")
|
||||||
|
let g:tcommentGuessFileType_php = 'html'
|
||||||
|
endif
|
||||||
|
if !exists("g:tcommentGuessFileType_html")
|
||||||
|
let g:tcommentGuessFileType_html = 1
|
||||||
|
endif
|
||||||
|
if !exists("g:tcommentGuessFileType_tskeleton")
|
||||||
|
let g:tcommentGuessFileType_tskeleton = 1
|
||||||
|
endif
|
||||||
|
if !exists("g:tcommentGuessFileType_vim")
|
||||||
|
let g:tcommentGuessFileType_vim = 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !exists("g:tcommentIgnoreTypes_php")
|
||||||
|
let g:tcommentIgnoreTypes_php = 'sql'
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !exists('g:tcommentSyntaxMap') "{{{2
|
||||||
|
let g:tcommentSyntaxMap = {
|
||||||
|
\ 'vimMzSchemeRegion': 'scheme',
|
||||||
|
\ 'vimPerlRegion': 'perl',
|
||||||
|
\ 'vimPythonRegion': 'python',
|
||||||
|
\ 'vimRubyRegion': 'ruby',
|
||||||
|
\ 'vimTclRegion': 'tcl',
|
||||||
|
\ }
|
||||||
|
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")
|
||||||
|
let g:tcommentBlockC = {
|
||||||
|
\ 'commentstring': '/*%s */',
|
||||||
|
\ 'middle': ' * ',
|
||||||
|
\ 'rxbeg': '\*\+',
|
||||||
|
\ 'rxend': '\*\+',
|
||||||
|
\ 'rxmid': '\*\+',
|
||||||
|
\ }
|
||||||
|
endif
|
||||||
|
if !exists("g:tcommentBlockC2")
|
||||||
|
let g:tcommentBlockC2 = {
|
||||||
|
\ 'commentstring': '/**%s */',
|
||||||
|
\ 'middle': ' * ',
|
||||||
|
\ 'rxbeg': '\*\+',
|
||||||
|
\ 'rxend': '\*\+',
|
||||||
|
\ 'rxmid': '\*\+',
|
||||||
|
\ }
|
||||||
|
endif
|
||||||
|
if !exists("g:tcommentInlineC")
|
||||||
|
let g:tcommentInlineC = "/* %s */"
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !exists("g:tcommentBlockXML")
|
||||||
|
let g:tcommentBlockXML = "<!--%s-->\n "
|
||||||
|
endif
|
||||||
|
if !exists("g:tcommentInlineXML")
|
||||||
|
let g:tcommentInlineXML = "<!-- %s -->"
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:typesDirty = 1
|
||||||
|
|
||||||
|
let s:definitions = {}
|
||||||
|
|
||||||
|
" Currently this function just sets a variable
|
||||||
|
function! tcomment#DefineType(name, commentdef)
|
||||||
|
if !has_key(s:definitions, a:name)
|
||||||
|
if type(a:commentdef) == 4
|
||||||
|
let cdef = copy(a:commentdef)
|
||||||
|
else
|
||||||
|
let cdef = a:0 >= 1 ? a:1 : {}
|
||||||
|
let cdef.commentstring = a:commentdef
|
||||||
|
endif
|
||||||
|
let s:definitions[a:name] = cdef
|
||||||
|
endif
|
||||||
|
let s:typesDirty = 1
|
||||||
|
endf
|
||||||
|
|
||||||
|
" Return 1 if a comment type is defined.
|
||||||
|
function! tcomment#TypeExists(name)
|
||||||
|
return has_key(s:definitions, a:name)
|
||||||
|
endf
|
||||||
|
|
||||||
|
call tcomment#DefineType('aap', '# %s' )
|
||||||
|
call tcomment#DefineType('ada', '-- %s' )
|
||||||
|
call tcomment#DefineType('apache', '# %s' )
|
||||||
|
call tcomment#DefineType('autoit', '; %s' )
|
||||||
|
call tcomment#DefineType('asm', '; %s' )
|
||||||
|
call tcomment#DefineType('awk', '# %s' )
|
||||||
|
call tcomment#DefineType('catalog', '-- %s --' )
|
||||||
|
call tcomment#DefineType('catalog_block', "--%s--\n " )
|
||||||
|
call tcomment#DefineType('cpp', '// %s' )
|
||||||
|
call tcomment#DefineType('cpp_inline', g:tcommentInlineC )
|
||||||
|
call tcomment#DefineType('cpp_block', g:tcommentBlockC )
|
||||||
|
call tcomment#DefineType('css', '/* %s */' )
|
||||||
|
call tcomment#DefineType('css_inline', g:tcommentInlineC )
|
||||||
|
call tcomment#DefineType('css_block', g:tcommentBlockC )
|
||||||
|
call tcomment#DefineType('c', '/* %s */' )
|
||||||
|
call tcomment#DefineType('c_inline', g:tcommentInlineC )
|
||||||
|
call tcomment#DefineType('c_block', g:tcommentBlockC )
|
||||||
|
call tcomment#DefineType('cfg', '# %s' )
|
||||||
|
call tcomment#DefineType('conf', '# %s' )
|
||||||
|
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('desktop', '# %s' )
|
||||||
|
call tcomment#DefineType('docbk', '<!-- %s -->' )
|
||||||
|
call tcomment#DefineType('docbk_inline', g:tcommentInlineXML)
|
||||||
|
call tcomment#DefineType('docbk_block', g:tcommentBlockXML )
|
||||||
|
call tcomment#DefineType('dosbatch', 'rem %s' )
|
||||||
|
call tcomment#DefineType('dosini', '; %s' )
|
||||||
|
call tcomment#DefineType('dsl', '; %s' )
|
||||||
|
call tcomment#DefineType('dylan', '// %s' )
|
||||||
|
call tcomment#DefineType('eiffel', '-- %s' )
|
||||||
|
call tcomment#DefineType('erlang', '%%%% %s' )
|
||||||
|
call tcomment#DefineType('eruby', '<%%# %s' )
|
||||||
|
call tcomment#DefineType('gitcommit', '# %s' )
|
||||||
|
call tcomment#DefineType('gtkrc', '# %s' )
|
||||||
|
call tcomment#DefineType('groovy', '// %s' )
|
||||||
|
call tcomment#DefineType('groovy_inline', g:tcommentInlineC )
|
||||||
|
call tcomment#DefineType('groovy_block', g:tcommentBlockC )
|
||||||
|
call tcomment#DefineType('groovy_doc_block', g:tcommentBlockC2 )
|
||||||
|
call tcomment#DefineType('haskell', '-- %s' )
|
||||||
|
call tcomment#DefineType('haskell_block', "{-%s-}\n " )
|
||||||
|
call tcomment#DefineType('haskell_inline', '{- %s -}' )
|
||||||
|
call tcomment#DefineType('html', '<!-- %s -->' )
|
||||||
|
call tcomment#DefineType('html_inline', g:tcommentInlineXML)
|
||||||
|
call tcomment#DefineType('html_block', g:tcommentBlockXML )
|
||||||
|
call tcomment#DefineType('io', '// %s' )
|
||||||
|
call tcomment#DefineType('javaScript', '// %s' )
|
||||||
|
call tcomment#DefineType('javaScript_inline', g:tcommentInlineC )
|
||||||
|
call tcomment#DefineType('javaScript_block', g:tcommentBlockC )
|
||||||
|
call tcomment#DefineType('javascript', '// %s' )
|
||||||
|
call tcomment#DefineType('javascript_inline', g:tcommentInlineC )
|
||||||
|
call tcomment#DefineType('javascript_block', g:tcommentBlockC )
|
||||||
|
call tcomment#DefineType('java', '/* %s */' )
|
||||||
|
call tcomment#DefineType('java_inline', g:tcommentInlineC )
|
||||||
|
call tcomment#DefineType('java_block', g:tcommentBlockC )
|
||||||
|
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('m4', 'dnl %s' )
|
||||||
|
call tcomment#DefineType('mail', '> %s' )
|
||||||
|
call tcomment#DefineType('msidl', '// %s' )
|
||||||
|
call tcomment#DefineType('msidl_block', g:tcommentBlockC )
|
||||||
|
call tcomment#DefineType('nroff', '.\\" %s' )
|
||||||
|
call tcomment#DefineType('nsis', '# %s' )
|
||||||
|
call tcomment#DefineType('objc', '/* %s */' )
|
||||||
|
call tcomment#DefineType('objc_inline', g:tcommentInlineC )
|
||||||
|
call tcomment#DefineType('objc_block', g:tcommentBlockC )
|
||||||
|
call tcomment#DefineType('ocaml', '(* %s *)' )
|
||||||
|
call tcomment#DefineType('ocaml_inline', '(* %s *)' )
|
||||||
|
call tcomment#DefineType('ocaml_block', "(*%s*)\n " )
|
||||||
|
call tcomment#DefineType('pascal', '(* %s *)' )
|
||||||
|
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_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('rc', '// %s' )
|
||||||
|
call tcomment#DefineType('readline', '# %s' )
|
||||||
|
call tcomment#DefineType('ruby', '# %s' )
|
||||||
|
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('sbs', "' %s" )
|
||||||
|
call tcomment#DefineType('scheme', '; %s' )
|
||||||
|
call tcomment#DefineType('sed', '# %s' )
|
||||||
|
call tcomment#DefineType('sgml', '<!-- %s -->' )
|
||||||
|
call tcomment#DefineType('sgml_inline', g:tcommentInlineXML)
|
||||||
|
call tcomment#DefineType('sgml_block', g:tcommentBlockXML )
|
||||||
|
call tcomment#DefineType('sh', '# %s' )
|
||||||
|
call tcomment#DefineType('sql', '-- %s' )
|
||||||
|
call tcomment#DefineType('spec', '# %s' )
|
||||||
|
call tcomment#DefineType('sps', '* %s.' )
|
||||||
|
call tcomment#DefineType('sps_block', "* %s." )
|
||||||
|
call tcomment#DefineType('spss', '* %s.' )
|
||||||
|
call tcomment#DefineType('spss_block', "* %s." )
|
||||||
|
call tcomment#DefineType('tcl', '# %s' )
|
||||||
|
call tcomment#DefineType('tex', '%% %s' )
|
||||||
|
call tcomment#DefineType('tpl', '<!-- %s -->' )
|
||||||
|
call tcomment#DefineType('viki', '%% %s' )
|
||||||
|
call tcomment#DefineType('viki_3', '%%%%%% %s' )
|
||||||
|
call tcomment#DefineType('viki_inline', '{cmt: %s}' )
|
||||||
|
call tcomment#DefineType('vim', '" %s' )
|
||||||
|
call tcomment#DefineType('vim_3', '""" %s' )
|
||||||
|
call tcomment#DefineType('websec', '# %s' )
|
||||||
|
call tcomment#DefineType('x86conf', '# %s' )
|
||||||
|
call tcomment#DefineType('xml', '<!-- %s -->' )
|
||||||
|
call tcomment#DefineType('xml_inline', g:tcommentInlineXML)
|
||||||
|
call tcomment#DefineType('xml_block', g:tcommentBlockXML )
|
||||||
|
call tcomment#DefineType('xs', '// %s' )
|
||||||
|
call tcomment#DefineType('xs_block', g:tcommentBlockC )
|
||||||
|
call tcomment#DefineType('xslt', '<!-- %s -->' )
|
||||||
|
call tcomment#DefineType('xslt_inline', g:tcommentInlineXML)
|
||||||
|
call tcomment#DefineType('xslt_block', g:tcommentBlockXML )
|
||||||
|
call tcomment#DefineType('yaml', '# %s' )
|
||||||
|
|
||||||
|
|
||||||
function! s:DefaultValue(option)
|
function! s:DefaultValue(option)
|
||||||
@ -24,26 +248,124 @@ let s:defaultComments = s:DefaultValue('comments')
|
|||||||
let s:defaultCommentString = s:DefaultValue('commentstring')
|
let s:defaultCommentString = s:DefaultValue('commentstring')
|
||||||
let s:nullCommentString = '%s'
|
let s:nullCommentString = '%s'
|
||||||
|
|
||||||
" tcomment#Comment(line1, line2, ?commentMode, ?commentAnyway, ?commentBegin, ?commentEnd)
|
" tcomment#Comment(line1, line2, ?commentMode, ?commentAnyway, ?args...)
|
||||||
|
" args... are either:
|
||||||
|
" 1. a list of key=value pairs where known keys are:
|
||||||
|
" as=STRING ... Use a specific comment definition
|
||||||
|
" 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"
|
||||||
|
" rxend=N ... The above for "end"
|
||||||
|
" rxmid=N ... The above for "middle"
|
||||||
|
" 2. 1-2 values for: ?commentPrefix, ?commentPostfix
|
||||||
|
" 3. a dictionary (internal use only)
|
||||||
|
"
|
||||||
" commentMode:
|
" commentMode:
|
||||||
" G ... guess
|
" G ... guess the value of commentMode
|
||||||
" B ... block
|
" B ... block (use extra lines for the comment markers)
|
||||||
" i ... maybe inline, guess
|
" i ... maybe inline, guess
|
||||||
" I ... inline
|
" I ... inline
|
||||||
" R ... right
|
" R ... right (comment the line right of the cursor)
|
||||||
" v ... visual
|
" v ... visual
|
||||||
" o ... operator
|
" o ... operator
|
||||||
|
" By default, each line in range will be commented by adding the comment
|
||||||
|
" prefix and postfix.
|
||||||
function! tcomment#Comment(beg, end, ...)
|
function! tcomment#Comment(beg, end, ...)
|
||||||
" save the cursor position
|
|
||||||
let co = col('.')
|
|
||||||
let li = line('.')
|
|
||||||
let s:pos_end = getpos("'>")
|
|
||||||
let commentMode = a:0 >= 1 ? a:1 : 'G'
|
let commentMode = a:0 >= 1 ? a:1 : 'G'
|
||||||
let commentAnyway = a:0 >= 2 ? (a:2 == '!') : 0
|
let commentAnyway = a:0 >= 2 ? (a:2 == '!') : 0
|
||||||
" TLogVAR a:beg, a:end, a:1, commentMode, commentAnyway
|
" TLogVAR a:beg, a:end, a:1, commentMode, commentAnyway
|
||||||
|
" save the cursor position
|
||||||
|
let pos = getpos('.')
|
||||||
|
let s:pos_end = getpos("'>")
|
||||||
if commentMode =~# 'i'
|
if commentMode =~# 'i'
|
||||||
let commentMode = substitute(commentMode, '\Ci', line("'<") == line("'>") ? 'I' : 'G', 'g')
|
let commentMode = substitute(commentMode, '\Ci', line("'<") == line("'>") ? 'I' : 'G', 'g')
|
||||||
endif
|
endif
|
||||||
|
let [cstart, cend] = s:GetStartEnd(commentMode)
|
||||||
|
" TLogVAR commentMode, cstart, cend
|
||||||
|
" get the correct commentstring
|
||||||
|
if a:0 >= 3 && type(a:3) == 4
|
||||||
|
let cdef = a:3
|
||||||
|
else
|
||||||
|
let cdef = s:GetCommentDefinition(a:beg, a:end, commentMode)
|
||||||
|
let ax = 3
|
||||||
|
if a:0 >= 3 && a:3 != '' && stridx(a:3, '=') == -1
|
||||||
|
let ax = 4
|
||||||
|
let cdef.begin = a:3
|
||||||
|
if a:0 >= 4 && a:4 != '' && stridx(a:4, '=') == -1
|
||||||
|
let ax = 5
|
||||||
|
let cdef.end = a:4
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if a:0 >= ax
|
||||||
|
call extend(cdef, s:ParseArgs(a:beg, a:end, commentMode, a:000[ax - 1 : -1]))
|
||||||
|
endif
|
||||||
|
if !empty(get(cdef, 'begin', '')) || !empty(get(cdef, 'end', ''))
|
||||||
|
let cdef.commentstring = s:EncodeCommentPart(get(cdef, 'begin', ''))
|
||||||
|
\ . '%s'
|
||||||
|
\ . s:EncodeCommentPart(get(cdef, 'end', ''))
|
||||||
|
endif
|
||||||
|
let commentMode = cdef.mode
|
||||||
|
endif
|
||||||
|
if !empty(filter(['count', 'cbeg', 'cend', 'cmid'], 'has_key(cdef, v:val)'))
|
||||||
|
call s:RepeatCommentstring(cdef)
|
||||||
|
endif
|
||||||
|
" echom "DBG" string(cdef) string(a:000)
|
||||||
|
let cms0 = s:BlockGetCommentString(cdef)
|
||||||
|
let cms0 = escape(cms0, '\')
|
||||||
|
" 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, '\(\_.\{-}\)')
|
||||||
|
" set commentMode and indentStr
|
||||||
|
let [indentStr, uncomment] = s:CommentDef(a:beg, a:end, cmtCheck, commentMode, cstart, cend)
|
||||||
|
" TLogVAR indentStr, uncomment
|
||||||
|
let col = get(cdef, 'col', -1)
|
||||||
|
if col >= 0
|
||||||
|
let col -= 1
|
||||||
|
let indent = len(indentStr)
|
||||||
|
if col > indent
|
||||||
|
let cms0 = repeat(' ', col - indent) . cms0
|
||||||
|
else
|
||||||
|
let indentStr = repeat(' ', col)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if commentAnyway
|
||||||
|
let uncomment = 0
|
||||||
|
endif
|
||||||
|
" go
|
||||||
|
if commentMode =~# 'B'
|
||||||
|
" We want a comment block
|
||||||
|
call s:CommentBlock(a:beg, a:end, uncomment, cmtCheck, cdef, indentStr)
|
||||||
|
else
|
||||||
|
" call s:CommentLines(a:beg, a:end, cstart, 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) .'/'.
|
||||||
|
\ '\=s:ProcessedLine('. uncomment .', submatch(0), "'. cmtCheck .'", "'. cmtReplace .'")/ge'
|
||||||
|
endif
|
||||||
|
" reposition cursor
|
||||||
|
" TLogVAR commentMode
|
||||||
|
if commentMode =~ '>'
|
||||||
|
call setpos('.', s:pos_end)
|
||||||
|
else
|
||||||
|
" TLogVAR pos
|
||||||
|
call setpos('.', pos)
|
||||||
|
endif
|
||||||
|
endf
|
||||||
|
|
||||||
|
|
||||||
|
function! s:GetStartEnd(commentMode) "{{{3
|
||||||
|
let commentMode = a:commentMode
|
||||||
if commentMode =~# 'R' || commentMode =~# 'I'
|
if commentMode =~# 'R' || commentMode =~# 'I'
|
||||||
let cstart = col("'<")
|
let cstart = col("'<")
|
||||||
if cstart == 0
|
if cstart == 0
|
||||||
@ -62,54 +384,49 @@ function! tcomment#Comment(beg, end, ...)
|
|||||||
let cstart = 0
|
let cstart = 0
|
||||||
let cend = 0
|
let cend = 0
|
||||||
endif
|
endif
|
||||||
" TLogVAR commentMode, cstart, cend
|
return [cstart, cend]
|
||||||
" get the correct commentstring
|
|
||||||
if a:0 >= 3 && a:3 != ''
|
|
||||||
let cms = s:EncodeCommentPart(a:3) .'%s'
|
|
||||||
if a:0 >= 4 && a:4 != ''
|
|
||||||
let cms = cms . s:EncodeCommentPart(a:4)
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
let [cms, commentMode] = s:GetCommentString(a:beg, a:end, commentMode)
|
|
||||||
endif
|
|
||||||
let cms0 = s:BlockGetCommentString(cms)
|
|
||||||
let cms0 = escape(cms0, '\')
|
|
||||||
" 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, '\(\_.\{-}\)')
|
|
||||||
" set commentMode and indentStr
|
|
||||||
let [indentStr, uncomment] = s:CommentDef(a:beg, a:end, cmtCheck, commentMode, cstart, cend)
|
|
||||||
" TLogVAR indentStr, uncomment
|
|
||||||
if commentAnyway
|
|
||||||
let uncomment = 0
|
|
||||||
endif
|
|
||||||
" go
|
|
||||||
if commentMode =~# 'B'
|
|
||||||
" We want a comment block
|
|
||||||
call s:CommentBlock(a:beg, a:end, uncomment, cmtCheck, cms, indentStr)
|
|
||||||
else
|
|
||||||
" call s:CommentLines(a:beg, a:end, cstart, 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) .'/'.
|
|
||||||
\ '\=s:ProcessedLine('. uncomment .', submatch(0), "'. cmtCheck .'", "'. cmtReplace .'")/ge'
|
|
||||||
endif
|
|
||||||
" reposition cursor
|
|
||||||
" TLogVAR commentMode
|
|
||||||
if commentMode =~ '>'
|
|
||||||
call setpos('.', s:pos_end)
|
|
||||||
else
|
|
||||||
" TLogVAR li, co
|
|
||||||
call cursor(li, co)
|
|
||||||
endif
|
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
|
||||||
|
function! s:RepeatCommentstring(cdef) "{{{3
|
||||||
|
" TLogVAR a:cdef
|
||||||
|
let cms = s:BlockGetCommentString(a:cdef)
|
||||||
|
let mid = s:BlockGetMiddleString(a:cdef)
|
||||||
|
let cms_fbeg = match(cms, '\s*%\@<!%s')
|
||||||
|
let cms_fend = matchend(cms, '%\@<!%s\s*')
|
||||||
|
let rxbeg = get(a:cdef, 'rxbeg', '^.*$')
|
||||||
|
let rxend = get(a:cdef, 'rxend', '^.*$')
|
||||||
|
let rpbeg = repeat('&', get(a:cdef, 'cbeg', get(a:cdef, 'count', 1)))
|
||||||
|
let rpend = repeat('&', get(a:cdef, 'cend', get(a:cdef, 'count', 1)))
|
||||||
|
let a:cdef.commentstring = substitute(cms[0 : cms_fbeg - 1], rxbeg, rpbeg, '')
|
||||||
|
\. cms[cms_fbeg : cms_fend - 1]
|
||||||
|
\. substitute(cms[cms_fend : -1], rxend, rpend, '')
|
||||||
|
" TLogVAR cms, a:cdef.commentstring
|
||||||
|
if !empty(mid)
|
||||||
|
let rxmid = get(a:cdef, 'rxmid', '^.*$')
|
||||||
|
let rpmid = repeat('&', get(a:cdef, 'cmid', get(a:cdef, 'count', 1)))
|
||||||
|
let a:cdef.middle = substitute(mid, rxmid, rpmid, '')
|
||||||
|
" TLogVAR mid, a:cdef.middle
|
||||||
|
endif
|
||||||
|
return a:cdef
|
||||||
|
endf
|
||||||
|
|
||||||
|
|
||||||
|
function! s:ParseArgs(beg, end, commentMode, arglist) "{{{3
|
||||||
|
let args = {}
|
||||||
|
for arg in a:arglist
|
||||||
|
let key = matchstr(arg, '^[^=]\+')
|
||||||
|
let value = matchstr(arg, '=\zs.*$')
|
||||||
|
if key == 'as'
|
||||||
|
call extend(args, s:GetCommentDefinitionForType(a:beg, a:end, a:commentMode, value))
|
||||||
|
else
|
||||||
|
let args[key] = value
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return args
|
||||||
|
endf
|
||||||
|
|
||||||
|
|
||||||
function! tcomment#Operator(type, ...) "{{{3
|
function! tcomment#Operator(type, ...) "{{{3
|
||||||
let commentMode = a:0 >= 1 ? a:1 : ''
|
let commentMode = a:0 >= 1 ? a:1 : ''
|
||||||
let bang = a:0 >= 2 ? a:2 : ''
|
let bang = a:0 >= 2 ? a:2 : ''
|
||||||
@ -168,10 +485,13 @@ function! tcomment#OperatorLineAnyway(type) "{{{3
|
|||||||
endf
|
endf
|
||||||
|
|
||||||
|
|
||||||
|
" :display: tcomment#CommentAs(beg, end, commentAnyway, filetype, ?args...)
|
||||||
|
" Where args is either:
|
||||||
|
" 1. A count NUMBER
|
||||||
|
" 2. An args list (see the notes on the "args" argument of
|
||||||
|
" |tcomment#Comment()|)
|
||||||
" comment text as if it were of a specific filetype
|
" comment text as if it were of a specific filetype
|
||||||
function! tcomment#CommentAs(beg, end, commentAnyway, filetype, ...)
|
function! tcomment#CommentAs(beg, end, commentAnyway, filetype, ...)
|
||||||
let ccount = a:0 >= 1 ? a:1 : 1
|
|
||||||
" TLogVAR ccount
|
|
||||||
if a:filetype =~ '_block$'
|
if a:filetype =~ '_block$'
|
||||||
let commentMode = 'B'
|
let commentMode = 'B'
|
||||||
let ft = substitute(a:filetype, '_block$', '', '')
|
let ft = substitute(a:filetype, '_block$', '', '')
|
||||||
@ -182,74 +502,90 @@ function! tcomment#CommentAs(beg, end, commentAnyway, filetype, ...)
|
|||||||
let commentMode = 'G'
|
let commentMode = 'G'
|
||||||
let ft = a:filetype
|
let ft = a:filetype
|
||||||
endif
|
endif
|
||||||
let [cms, commentMode] = s:GetCommentString(a:beg, a:end, commentMode, ft)
|
if a:0 >= 1
|
||||||
let pre = substitute(cms, '%s.*$', '', '')
|
if type(a:1) == 0
|
||||||
let pre = substitute(pre, '%%', '%', 'g')
|
let cdef = {'count': a:0 >= 1 ? a:1 : 1}
|
||||||
let post = substitute(cms, '^.\{-}%s', '', '')
|
else
|
||||||
let post = substitute(post, '%%', '%', 'g')
|
let cdef = s:ParseArgs(a:beg, a:end, commentMode, a:000)
|
||||||
if ccount > 1
|
|
||||||
let pre_l = matchlist(pre, '^\(\S\+\)\(.*\)$')
|
|
||||||
" TLogVAR pre_l
|
|
||||||
if !empty(get(pre_l, 1))
|
|
||||||
let pre = repeat(pre_l[1], ccount) . pre_l[2]
|
|
||||||
endif
|
endif
|
||||||
let post_l = matchlist(post, '^\(\s*\)\(.\+\)$')
|
else
|
||||||
" TLogVAR post_l
|
let cdef = {}
|
||||||
if !empty(get(post_l, 2))
|
|
||||||
let post = post_l[1] . repeat(post_l[2], ccount)
|
|
||||||
endif
|
endif
|
||||||
endif
|
" echom "DBG" string(cdef)
|
||||||
keepjumps call tcomment#Comment(a:beg, a:end, commentMode, a:commentAnyway, pre, post)
|
call extend(cdef, s:GetCommentDefinitionForType(a:beg, a:end, commentMode, ft))
|
||||||
|
keepjumps call tcomment#Comment(a:beg, a:end, commentMode, a:commentAnyway, cdef)
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
|
||||||
" ----------------------------------------------------------------
|
" collect all known comment types
|
||||||
" collect all variables matching ^tcomment_
|
|
||||||
function! tcomment#CollectFileTypes()
|
function! tcomment#CollectFileTypes()
|
||||||
if g:tcommentFileTypesDirty
|
if s:typesDirty
|
||||||
redir => vars
|
let s:types = keys(s:definitions)
|
||||||
silent let
|
let s:typesRx = '\V\^\('. join(s:types, '\|') .'\)\(\u\.\*\)\?\$'
|
||||||
redir END
|
let s:typesDirty = 0
|
||||||
let g:tcommentFileTypes = split(vars, '\n')
|
|
||||||
call filter(g:tcommentFileTypes, 'v:val =~ "tcomment_"')
|
|
||||||
call map(g:tcommentFileTypes, 'matchstr(v:val, ''tcomment_\zs\S\+'')')
|
|
||||||
call sort(g:tcommentFileTypes)
|
|
||||||
let g:tcommentFileTypesRx = '\V\^\('. join(g:tcommentFileTypes, '\|') .'\)\(\u\.\*\)\?\$'
|
|
||||||
let g:tcommentFileTypesDirty = 0
|
|
||||||
endif
|
endif
|
||||||
endf
|
endf
|
||||||
|
|
||||||
call tcomment#CollectFileTypes()
|
call tcomment#CollectFileTypes()
|
||||||
|
|
||||||
|
|
||||||
" return a list of filetypes for which a tcomment_{&ft} is defined
|
" return a list of filetypes for which a tcomment_{&ft} is defined
|
||||||
function! tcomment#FileTypes(ArgLead, CmdLine, CursorPos)
|
function! tcomment#Complete(ArgLead, CmdLine, CursorPos) "{{{3
|
||||||
" TLogVAR a:ArgLead, a:CmdLine, a:CursorPos
|
|
||||||
call tcomment#CollectFileTypes()
|
call tcomment#CollectFileTypes()
|
||||||
let types = copy(g:tcommentFileTypes)
|
let completions = copy(s:types)
|
||||||
if index(g:tcommentFileTypes, &filetype) != -1
|
if index(completions, &filetype) != -1
|
||||||
" TLogVAR &filetype
|
" TLogVAR &filetype
|
||||||
call insert(types, &filetype)
|
call insert(completions, &filetype)
|
||||||
endif
|
endif
|
||||||
if empty(a:ArgLead)
|
if !empty(a:ArgLead)
|
||||||
return types
|
call filter(completions, 'v:val =~ ''\V\^''.a:ArgLead')
|
||||||
else
|
|
||||||
return filter(types, 'v:val =~ ''\V''.a:ArgLead')
|
|
||||||
endif
|
endif
|
||||||
|
let completions += tcomment#CompleteArgs(a:ArgLead, a:CmdLine, a:CursorPos)
|
||||||
|
return completions
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
|
||||||
|
function! tcomment#CompleteArgs(ArgLead, CmdLine, CursorPos) "{{{3
|
||||||
|
let completions = ['as=', 'col=', 'count=', 'mode=', 'begin=', 'end=']
|
||||||
|
if !empty(a:ArgLead)
|
||||||
|
if a:ArgLead =~ '^as='
|
||||||
|
call tcomment#CollectFileTypes()
|
||||||
|
let completions += map(copy(s:types), '"as=". v:val')
|
||||||
|
endif
|
||||||
|
call filter(completions, 'v:val =~ ''\V\^''.a:ArgLead')
|
||||||
|
endif
|
||||||
|
return completions
|
||||||
|
endf
|
||||||
|
|
||||||
|
|
||||||
function! s:EncodeCommentPart(string)
|
function! s:EncodeCommentPart(string)
|
||||||
return substitute(a:string, '%', '%%', 'g')
|
return substitute(a:string, '%', '%%', 'g')
|
||||||
endf
|
endf
|
||||||
|
|
||||||
" s:GetCommentString(beg, end, commentMode, ?filetype="")
|
|
||||||
function! s:GetCommentString(beg, end, commentMode, ...)
|
function! s:GetCommentDefinitionForType(beg, end, commentMode, filetype) "{{{3
|
||||||
|
let cdef = s:GetCommentDefinition(a:beg, a:end, a:commentMode, a:filetype)
|
||||||
|
let cms = cdef.commentstring
|
||||||
|
let commentMode = cdef.mode
|
||||||
|
let pre = substitute(cms, '%s.*$', '', '')
|
||||||
|
let pre = substitute(pre, '%%', '%', 'g')
|
||||||
|
let post = substitute(cms, '^.\{-}%s', '', '')
|
||||||
|
let post = substitute(post, '%%', '%', 'g')
|
||||||
|
let cdef.begin = pre
|
||||||
|
let cdef.end = post
|
||||||
|
return cdef
|
||||||
|
endf
|
||||||
|
|
||||||
|
|
||||||
|
" s:GetCommentDefinition(beg, end, commentMode, ?filetype="")
|
||||||
|
function! s:GetCommentDefinition(beg, end, commentMode, ...)
|
||||||
let ft = a:0 >= 1 ? a:1 : ''
|
let ft = a:0 >= 1 ? a:1 : ''
|
||||||
if ft != ''
|
if ft != ''
|
||||||
let [cms, commentMode] = s:GetCustomCommentString(ft, a:commentMode)
|
let cdef = s:GetCustomCommentString(ft, a:commentMode)
|
||||||
else
|
else
|
||||||
let cms = ''
|
let cdef = {'mode': a:commentMode}
|
||||||
let commentMode = a:commentMode
|
|
||||||
endif
|
endif
|
||||||
|
let cms = get(cdef, 'commentstring', '')
|
||||||
if empty(cms)
|
if empty(cms)
|
||||||
if exists('b:commentstring')
|
if exists('b:commentstring')
|
||||||
let cms = b:commentstring
|
let cms = b:commentstring
|
||||||
@ -271,8 +607,9 @@ function! s:GetCommentString(beg, end, commentMode, ...)
|
|||||||
else
|
else
|
||||||
return s:GetCustomCommentString(&filetype, a:commentMode, s:GuessCurrentCommentString(a:commentMode))
|
return s:GetCustomCommentString(&filetype, a:commentMode, s:GuessCurrentCommentString(a:commentMode))
|
||||||
endif
|
endif
|
||||||
|
let cdef.commentstring = cms
|
||||||
endif
|
endif
|
||||||
return [cms, commentMode]
|
return cdef
|
||||||
endf
|
endf
|
||||||
|
|
||||||
" s:SPrintF(formatstring, ?values ...)
|
" s:SPrintF(formatstring, ?values ...)
|
||||||
@ -338,14 +675,14 @@ function! s:CommentDef(beg, end, checkRx, commentMode, cstart, cend)
|
|||||||
let line = strpart(line, 0, a:cend - 1)
|
let line = strpart(line, 0, a:cend - 1)
|
||||||
endif
|
endif
|
||||||
let uncomment = (line =~ mdrx)
|
let uncomment = (line =~ mdrx)
|
||||||
let it = s:GetIndentString(a:beg, a:cstart)
|
let indentStr = s:GetIndentString(a:beg, a:cstart)
|
||||||
let il = indent(a:beg)
|
let il = indent(a:beg)
|
||||||
let n = a:beg + 1
|
let n = a:beg + 1
|
||||||
while n <= a:end
|
while n <= a:end
|
||||||
if getline(n) =~ '\S'
|
if getline(n) =~ '\S'
|
||||||
let jl = indent(n)
|
let jl = indent(n)
|
||||||
if jl < il
|
if jl < il
|
||||||
let it = s:GetIndentString(n, a:cstart)
|
let indentStr = s:GetIndentString(n, a:cstart)
|
||||||
let il = jl
|
let il = jl
|
||||||
endif
|
endif
|
||||||
if a:commentMode =~# 'G'
|
if a:commentMode =~# 'G'
|
||||||
@ -365,10 +702,11 @@ function! s:CommentDef(beg, end, checkRx, commentMode, cstart, cend)
|
|||||||
let @t = t
|
let @t = t
|
||||||
endtry
|
endtry
|
||||||
endif
|
endif
|
||||||
return [it, uncomment]
|
return [indentStr, uncomment]
|
||||||
endf
|
endf
|
||||||
|
|
||||||
function! s:ProcessedLine(uncomment, match, checkRx, replace)
|
function! s:ProcessedLine(uncomment, match, checkRx, replace)
|
||||||
|
" TLogVAR a:uncomment, a:match, a:checkRx, a:replace
|
||||||
if !(a:match =~ '\S' || g:tcommentBlankLines)
|
if !(a:match =~ '\S' || g:tcommentBlankLines)
|
||||||
return a:match
|
return a:match
|
||||||
endif
|
endif
|
||||||
@ -378,11 +716,16 @@ function! s:ProcessedLine(uncomment, match, checkRx, replace)
|
|||||||
else
|
else
|
||||||
let rv = s:SPrintF(a:replace, a:match)
|
let rv = s:SPrintF(a:replace, a:match)
|
||||||
endif
|
endif
|
||||||
|
" TLogVAR rv
|
||||||
" let md = len(rv) - ml
|
" let md = len(rv) - ml
|
||||||
let s:pos_end = getpos('.')
|
let s:pos_end = getpos('.')
|
||||||
let s:pos_end[2] += len(rv)
|
let s:pos_end[2] += len(rv)
|
||||||
" TLogVAR pe, md, a:match
|
" TLogVAR pe, md, a:match
|
||||||
|
if v:version > 702 || (v:version == 702 && has('patch407'))
|
||||||
|
let rv = escape(rv, '
')
|
||||||
|
else
|
||||||
let rv = escape(rv, '\
')
|
let rv = escape(rv, '\
')
|
||||||
|
endif
|
||||||
let rv = substitute(rv, '\n', '\\\n', 'g')
|
let rv = substitute(rv, '\n', '\\\n', 'g')
|
||||||
return rv
|
return rv
|
||||||
endf
|
endf
|
||||||
@ -398,11 +741,11 @@ function! s:CommentLines(beg, end, cstart, cend, uncomment, cmtCheck, cms0, inde
|
|||||||
\ '\=s:ProcessedLine('. a:uncomment .', submatch(0), "'. a:cmtCheck .'", "'. cmtReplace .'")/ge'
|
\ '\=s:ProcessedLine('. a:uncomment .', submatch(0), "'. a:cmtCheck .'", "'. cmtReplace .'")/ge'
|
||||||
endf
|
endf
|
||||||
|
|
||||||
function! s:CommentBlock(beg, end, uncomment, checkRx, replace, indentStr)
|
function! s:CommentBlock(beg, end, uncomment, checkRx, cdef, indentStr)
|
||||||
let t = @t
|
let t = @t
|
||||||
try
|
try
|
||||||
silent exec 'norm! '. a:beg.'G1|v'.a:end.'G$"td'
|
silent exec 'norm! '. a:beg.'G1|v'.a:end.'G$"td'
|
||||||
let ms = s:BlockGetMiddleString(a:replace)
|
let ms = s:BlockGetMiddleString(a:cdef)
|
||||||
let mx = escape(ms, '\')
|
let mx = escape(ms, '\')
|
||||||
if a:uncomment
|
if a:uncomment
|
||||||
let @t = substitute(@t, '\V\^\s\*'. a:checkRx .'\$', '\1', '')
|
let @t = substitute(@t, '\V\^\s\*'. a:checkRx .'\$', '\1', '')
|
||||||
@ -412,7 +755,7 @@ function! s:CommentBlock(beg, end, uncomment, checkRx, replace, indentStr)
|
|||||||
let @t = substitute(@t, '^\n', '', '')
|
let @t = substitute(@t, '^\n', '', '')
|
||||||
let @t = substitute(@t, '\n\s*$', '', '')
|
let @t = substitute(@t, '\n\s*$', '', '')
|
||||||
else
|
else
|
||||||
let cs = s:BlockGetCommentString(a:replace)
|
let cs = s:BlockGetCommentString(a:cdef)
|
||||||
let cs = a:indentStr . substitute(cs, '%s', '%s'. a:indentStr, '')
|
let cs = a:indentStr . substitute(cs, '%s', '%s'. a:indentStr, '')
|
||||||
if ms != ''
|
if ms != ''
|
||||||
let ms = a:indentStr . ms
|
let ms = a:indentStr . ms
|
||||||
@ -433,13 +776,12 @@ endf
|
|||||||
" s:GuessFileType(beg, end, commentMode, filetype, ?fallbackFiletype)
|
" s:GuessFileType(beg, end, commentMode, filetype, ?fallbackFiletype)
|
||||||
function! s:GuessFileType(beg, end, commentMode, filetype, ...)
|
function! s:GuessFileType(beg, end, commentMode, filetype, ...)
|
||||||
if a:0 >= 1 && a:1 != ''
|
if a:0 >= 1 && a:1 != ''
|
||||||
let [cms, commentMode] = s:GetCustomCommentString(a:1, a:commentMode)
|
let cdef = s:GetCustomCommentString(a:1, a:commentMode)
|
||||||
if cms == ''
|
if empty(get(cdef, 'commentstring', ''))
|
||||||
let cms = s:GuessCurrentCommentString(a:commentMode)
|
let cdef.commentstring = s:GuessCurrentCommentString(a:commentMode)
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let commentMode = s:CommentMode(a:commentMode, 'G')
|
let cdef = {'commentstring': s:GuessCurrentCommentString(0), 'mode': s:CommentMode(a:commentMode, 'G')}
|
||||||
let cms = s:GuessCurrentCommentString(0)
|
|
||||||
endif
|
endif
|
||||||
let n = a:beg
|
let n = a:beg
|
||||||
" TLogVAR n, a:beg, a:end
|
" TLogVAR n, a:beg, a:end
|
||||||
@ -453,14 +795,14 @@ function! s:GuessFileType(beg, end, commentMode, filetype, ...)
|
|||||||
let ftypeMap = get(g:tcommentSyntaxMap, syntaxName)
|
let ftypeMap = get(g:tcommentSyntaxMap, syntaxName)
|
||||||
if !empty(ftypeMap)
|
if !empty(ftypeMap)
|
||||||
" TLogVAR ftypeMap
|
" TLogVAR ftypeMap
|
||||||
return s:GetCustomCommentString(ftypeMap, a:commentMode, cms)
|
return s:GetCustomCommentString(ftypeMap, a:commentMode, cdef.commentstring)
|
||||||
elseif syntaxName =~ g:tcommentFileTypesRx
|
elseif syntaxName =~ s:typesRx
|
||||||
let ft = substitute(syntaxName, g:tcommentFileTypesRx, '\1', '')
|
let ft = substitute(syntaxName, s:typesRx, '\1', '')
|
||||||
" TLogVAR ft
|
" TLogVAR ft
|
||||||
if exists('g:tcommentIgnoreTypes_'. a:filetype) && g:tcommentIgnoreTypes_{a:filetype} =~ '\<'.ft.'\>'
|
if exists('g:tcommentIgnoreTypes_'. a:filetype) && g:tcommentIgnoreTypes_{a:filetype} =~ '\<'.ft.'\>'
|
||||||
let m += 1
|
let m += 1
|
||||||
else
|
else
|
||||||
return s:GetCustomCommentString(ft, a:commentMode, cms)
|
return s:GetCustomCommentString(ft, a:commentMode, cdef.commentstring)
|
||||||
endif
|
endif
|
||||||
elseif syntaxName == '' || syntaxName == 'None' || syntaxName =~ '^\u\+$' || syntaxName =~ '^\u\U*$'
|
elseif syntaxName == '' || syntaxName == 'None' || syntaxName =~ '^\u\+$' || syntaxName =~ '^\u\U*$'
|
||||||
let m += 1
|
let m += 1
|
||||||
@ -470,7 +812,7 @@ function! s:GuessFileType(beg, end, commentMode, filetype, ...)
|
|||||||
endwh
|
endwh
|
||||||
let n += 1
|
let n += 1
|
||||||
endwh
|
endwh
|
||||||
return [cms, commentMode]
|
return cdef
|
||||||
endf
|
endf
|
||||||
|
|
||||||
function! s:CommentMode(commentMode, newmode) "{{{3
|
function! s:CommentMode(commentMode, newmode) "{{{3
|
||||||
@ -509,15 +851,7 @@ function! s:ConstructFromComments(commentMode)
|
|||||||
exec s:ExtractCommentsPart('s')
|
exec s:ExtractCommentsPart('s')
|
||||||
if s != ''
|
if s != ''
|
||||||
exec s:ExtractCommentsPart('e')
|
exec s:ExtractCommentsPart('e')
|
||||||
" if a:commentMode
|
|
||||||
" exec s:ExtractCommentsPart("m")
|
|
||||||
" if m != ""
|
|
||||||
" let m = "\n". m
|
|
||||||
" endif
|
|
||||||
" return s.'%s'.e.m
|
|
||||||
" else
|
|
||||||
return s.' %s '.e
|
return s.' %s '.e
|
||||||
" endif
|
|
||||||
endif
|
endif
|
||||||
if line != ''
|
if line != ''
|
||||||
return line .' %s'
|
return line .' %s'
|
||||||
@ -542,33 +876,40 @@ endf
|
|||||||
" s:GetCustomCommentString(ft, commentMode, ?default="")
|
" s:GetCustomCommentString(ft, commentMode, ?default="")
|
||||||
function! s:GetCustomCommentString(ft, commentMode, ...)
|
function! s:GetCustomCommentString(ft, commentMode, ...)
|
||||||
let commentMode = a:commentMode
|
let commentMode = a:commentMode
|
||||||
let customComment = exists('g:tcomment_'. a:ft)
|
let customComment = tcomment#TypeExists(a:ft)
|
||||||
if commentMode =~# 'B' && exists('g:tcomment_'. a:ft .'_block')
|
if commentMode =~# 'B' && tcomment#TypeExists(a:ft .'_block')
|
||||||
let cms = g:tcomment_{a:ft}_block
|
let def = s:definitions[a:ft .'_block']
|
||||||
elseif commentMode =~? 'I' && exists('g:tcomment_'. a:ft .'_inline')
|
elseif commentMode =~? 'I' && tcomment#TypeExists(a:ft .'_inline')
|
||||||
let cms = g:tcomment_{a:ft}_inline
|
let def = s:definitions[a:ft .'_inline']
|
||||||
elseif customComment
|
elseif customComment
|
||||||
let cms = g:tcomment_{a:ft}
|
let def = s:definitions[a:ft]
|
||||||
let commentMode = s:CommentMode(commentMode, 'G')
|
let commentMode = s:CommentMode(commentMode, 'G')
|
||||||
elseif a:0 >= 1
|
elseif a:0 >= 1
|
||||||
let cms = a:1
|
let def = {'commentstring': a:1}
|
||||||
let commentMode = s:CommentMode(commentMode, 'G')
|
let commentMode = s:CommentMode(commentMode, 'G')
|
||||||
else
|
else
|
||||||
let cms = ''
|
let def = {}
|
||||||
let commentMode = s:CommentMode(commentMode, 'G')
|
let commentMode = s:CommentMode(commentMode, 'G')
|
||||||
endif
|
endif
|
||||||
return [cms, commentMode]
|
let cdef = copy(def)
|
||||||
|
let cdef.mode = commentMode
|
||||||
|
return cdef
|
||||||
endf
|
endf
|
||||||
|
|
||||||
function! s:BlockGetCommentString(cms)
|
function! s:BlockGetCommentString(cdef)
|
||||||
" return substitute(a:cms, '\n.*$', '', '')
|
if has_key(a:cdef, 'middle')
|
||||||
return matchstr(a:cms, '^.\{-}\ze\(\n\|$\)')
|
return a:cdef.commentstring
|
||||||
|
else
|
||||||
|
return matchstr(a:cdef.commentstring, '^.\{-}\ze\(\n\|$\)')
|
||||||
|
endif
|
||||||
endf
|
endf
|
||||||
|
|
||||||
function! s:BlockGetMiddleString(cms)
|
function! s:BlockGetMiddleString(cdef)
|
||||||
" let rv = substitute(a:cms, '^.\{-}\n\([^\n]*\)', '\1', '')
|
if has_key(a:cdef, 'middle')
|
||||||
let rv = matchstr(a:cms, '\n\zs.*')
|
return a:cdef.middle
|
||||||
return rv == a:cms ? '' : rv
|
else
|
||||||
|
return matchstr(a:cdef.commentstring, '\n\zs.*')
|
||||||
|
endif
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
" License: This File is placed in the Public Domain.
|
" License: This File is placed in the Public Domain.
|
||||||
" Revision | Date [DD.MM.YY] | Changes
|
" Revision | Date [DD.MM.YY] | Changes
|
||||||
" 00.01.00 | 05.07.09 | 01. Revision
|
" 00.01.00 | 05.07.09 | 01. Revision
|
||||||
|
" 00.02.00 | 29.03.10 | Description added
|
||||||
|
|
||||||
*editsrec.txt* Global Plugin for Editing .srec Files
|
*editsrec.txt* Global Plugin for Editing .srec Files
|
||||||
|
|
||||||
@ -19,3 +20,22 @@ The Purpose of this Plugin is to edit .srec-Files.
|
|||||||
Currently it only allows Editing Line by Line,
|
Currently it only allows Editing Line by Line,
|
||||||
but Handling of Files will be added later.
|
but Handling of Files will be added later.
|
||||||
|
|
||||||
|
Commands | Description |
|
||||||
|
---------|-----------------------------------|
|
||||||
|
lb | build a line from ByteCount |
|
||||||
|
pb | build only the ByteCount |
|
||||||
|
---------|-----------------------------------|
|
||||||
|
la | build a line from ADdress |
|
||||||
|
pa | build only the ADdress |
|
||||||
|
---------|-----------------------------------|
|
||||||
|
ld | build a line from DAta |
|
||||||
|
pd | build only the DAta |
|
||||||
|
---------|-----------------------------------|
|
||||||
|
lc | build a line from CheckSum |
|
||||||
|
pc | build only the CheckSum |
|
||||||
|
---------|-----------------------------------|
|
||||||
|
m5 | make an S5 record on a blank line |
|
||||||
|
| |
|
||||||
|
|
||||||
|
see *editsrec_test.txt* for examples
|
||||||
|
|
||||||
|
@ -33,10 +33,16 @@
|
|||||||
:SearchBuffers MultipleSearch.txt /*:SearchBuffers*
|
:SearchBuffers MultipleSearch.txt /*:SearchBuffers*
|
||||||
:Sexplore pi_netrw.txt /*:Sexplore*
|
:Sexplore pi_netrw.txt /*:Sexplore*
|
||||||
:TComment tComment.txt /*:TComment*
|
:TComment tComment.txt /*:TComment*
|
||||||
|
:TComment tcomment.txt /*:TComment*
|
||||||
:TCommentAs tComment.txt /*:TCommentAs*
|
:TCommentAs tComment.txt /*:TCommentAs*
|
||||||
|
:TCommentAs tcomment.txt /*:TCommentAs*
|
||||||
:TCommentBlock tComment.txt /*:TCommentBlock*
|
:TCommentBlock tComment.txt /*:TCommentBlock*
|
||||||
|
:TCommentBlock tcomment.txt /*:TCommentBlock*
|
||||||
:TCommentInline tComment.txt /*:TCommentInline*
|
:TCommentInline tComment.txt /*:TCommentInline*
|
||||||
|
:TCommentInline tcomment.txt /*:TCommentInline*
|
||||||
|
:TCommentMaybeInline tcomment.txt /*:TCommentMaybeInline*
|
||||||
:TCommentRight tComment.txt /*:TCommentRight*
|
:TCommentRight tComment.txt /*:TCommentRight*
|
||||||
|
:TCommentRight tcomment.txt /*:TCommentRight*
|
||||||
:Texplore pi_netrw.txt /*:Texplore*
|
:Texplore pi_netrw.txt /*:Texplore*
|
||||||
:UseVimball pi_vimball.txt /*:UseVimball*
|
:UseVimball pi_vimball.txt /*:UseVimball*
|
||||||
:Vexplore pi_netrw.txt /*:Vexplore*
|
:Vexplore pi_netrw.txt /*:Vexplore*
|
||||||
@ -1413,6 +1419,7 @@ davs pi_netrw.txt /*davs*
|
|||||||
drv-dtArrayInit crefvim.txt /*drv-dtArrayInit*
|
drv-dtArrayInit crefvim.txt /*drv-dtArrayInit*
|
||||||
drv-dtIncompleteArrayDecl crefvim.txt /*drv-dtIncompleteArrayDecl*
|
drv-dtIncompleteArrayDecl crefvim.txt /*drv-dtIncompleteArrayDecl*
|
||||||
editsrec.txt editsrec.txt /*editsrec.txt*
|
editsrec.txt editsrec.txt /*editsrec.txt*
|
||||||
|
editsrec_test.txt editsrec.txt /*editsrec_test.txt*
|
||||||
ex-visincr-I visincr.txt /*ex-visincr-I*
|
ex-visincr-I visincr.txt /*ex-visincr-I*
|
||||||
ex-visincr-IA visincr.txt /*ex-visincr-IA*
|
ex-visincr-IA visincr.txt /*ex-visincr-IA*
|
||||||
ex-visincr-ID visincr.txt /*ex-visincr-ID*
|
ex-visincr-ID visincr.txt /*ex-visincr-ID*
|
||||||
@ -1504,8 +1511,11 @@ g:netrw_xstrlen pi_netrw.txt /*g:netrw_xstrlen*
|
|||||||
g:tcommentMapLeader1 tComment.txt /*g:tcommentMapLeader1*
|
g:tcommentMapLeader1 tComment.txt /*g:tcommentMapLeader1*
|
||||||
g:tcommentMapLeader2 tComment.txt /*g:tcommentMapLeader2*
|
g:tcommentMapLeader2 tComment.txt /*g:tcommentMapLeader2*
|
||||||
g:tcommentMapLeaderOp1 tComment.txt /*g:tcommentMapLeaderOp1*
|
g:tcommentMapLeaderOp1 tComment.txt /*g:tcommentMapLeaderOp1*
|
||||||
|
g:tcommentMapLeaderOp1 tcomment.txt /*g:tcommentMapLeaderOp1*
|
||||||
g:tcommentMapLeaderOp2 tComment.txt /*g:tcommentMapLeaderOp2*
|
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:tcommentOpModeExtra tcomment.txt /*g:tcommentOpModeExtra*
|
||||||
g:vimball_home pi_vimball.txt /*g:vimball_home*
|
g:vimball_home pi_vimball.txt /*g:vimball_home*
|
||||||
g:vimball_mkdir pi_vimball.txt /*g:vimball_mkdir*
|
g:vimball_mkdir pi_vimball.txt /*g:vimball_mkdir*
|
||||||
g:visincr_datedivset visincr.txt /*g:visincr_datedivset*
|
g:visincr_datedivset visincr.txt /*g:visincr_datedivset*
|
||||||
@ -1762,6 +1772,19 @@ tComment-Key-Bindings tComment.txt /*tComment-Key-Bindings*
|
|||||||
tComment-Usage tComment.txt /*tComment-Usage*
|
tComment-Usage tComment.txt /*tComment-Usage*
|
||||||
tComment-commands tComment.txt /*tComment-commands*
|
tComment-commands tComment.txt /*tComment-commands*
|
||||||
tComment.txt tComment.txt /*tComment.txt*
|
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_[%*
|
v_[% matchit.txt /*v_[%*
|
||||||
v_]% matchit.txt /*v_]%*
|
v_]% matchit.txt /*v_]%*
|
||||||
v_a% matchit.txt /*v_a%*
|
v_a% matchit.txt /*v_a%*
|
||||||
|
237
vimfiles/doc/tcomment.txt
Normal file
237
vimfiles/doc/tcomment.txt
Normal file
@ -0,0 +1,237 @@
|
|||||||
|
*tcomment.txt* An easily extensible & universal comment plugin
|
||||||
|
Author: Thomas Link, micathom AT gmail com?subject=vim
|
||||||
|
|
||||||
|
tcomment provides easy to use, file-type sensible comments for Vim. It
|
||||||
|
can handle embedded syntax.
|
||||||
|
|
||||||
|
TComment works like a toggle, i.e., it will comment out text that
|
||||||
|
contains uncommented lines, and it will remove comment markup for
|
||||||
|
already commented text (i.e. text that contains no uncommented lines).
|
||||||
|
|
||||||
|
If the file-type is properly defined, TComment will figure out which
|
||||||
|
comment string to use. Otherwise you use |tcomment#DefineType()| to
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
*tcomment-maps*
|
||||||
|
Key bindings~
|
||||||
|
|
||||||
|
Most of the time the default toggle keys will do what you want (or to be
|
||||||
|
more precise: what I think you want it to do ;-).
|
||||||
|
|
||||||
|
*g:tcommentMapLeaderOp1*
|
||||||
|
*g:tcommentMapLeaderOp2*
|
||||||
|
As operator (the prefix can be customized via g:tcommentMapLeaderOp1
|
||||||
|
and g:tcommentMapLeaderOp2):
|
||||||
|
|
||||||
|
gc{motion} :: Toggle comments (for small comments within one line
|
||||||
|
the &filetype_inline style will be used, if
|
||||||
|
defined)
|
||||||
|
gcc :: Toggle comment for the current line
|
||||||
|
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
|
||||||
|
work properly with exclusive motions).
|
||||||
|
|
||||||
|
Primary key maps:
|
||||||
|
|
||||||
|
<c-_><c-_> :: :TComment
|
||||||
|
<c-_><space> :: :TComment <QUERY COMMENT-BEGIN ?COMMENT-END>
|
||||||
|
<c-_>b :: :TCommentBlock
|
||||||
|
<c-_>a :: :TCommentAs <QUERY COMMENT TYPE>
|
||||||
|
<c-_>n :: :TCommentAs &filetype <QUERY COUNT>
|
||||||
|
<c-_>s :: :TCommentAs &filetype_<QUERY COMMENT SUBTYPE>
|
||||||
|
<c-_>i :: :TCommentInline
|
||||||
|
<c-_>r :: :TCommentRight
|
||||||
|
<c-_>p :: Comment the current inner paragraph
|
||||||
|
|
||||||
|
A secondary set of key maps is defined for normal mode.
|
||||||
|
|
||||||
|
<Leader>__ :: :TComment
|
||||||
|
<Leader>_p :: Comment the current inner paragraph
|
||||||
|
<Leader>_<space> :: :TComment <QUERY COMMENT-BEGIN ?COMMENT-END>
|
||||||
|
<Leader>_i :: :TCommentInline
|
||||||
|
<Leader>_r :: :TCommentRight
|
||||||
|
<Leader>_b :: :TCommentBlock
|
||||||
|
<Leader>_a :: :TCommentAs <QUERY COMMENT TYPE>
|
||||||
|
<Leader>_n :: :TCommentAs &filetype <QUERY COUNT>
|
||||||
|
<Leader>_s :: :TCommentAs &filetype_<QUERY COMMENT SUBTYPE>
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
Install~
|
||||||
|
|
||||||
|
Edit the vba file and type: >
|
||||||
|
|
||||||
|
:so %
|
||||||
|
|
||||||
|
See :help vimball for details. If you have difficulties or use vim 7.0,
|
||||||
|
please make sure, you have the current version of vimball (vimscript
|
||||||
|
#1502) installed or update your runtime.
|
||||||
|
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
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()|
|
||||||
|
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
plugin/tcomment.vim~
|
||||||
|
|
||||||
|
*:TComment*
|
||||||
|
:[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
|
||||||
|
|
||||||
|
*:TCommentAs*
|
||||||
|
:[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
|
||||||
|
|
||||||
|
*:TCommentRight*
|
||||||
|
:[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
|
||||||
|
|
||||||
|
*:TCommentBlock*
|
||||||
|
:[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
|
||||||
|
|
||||||
|
*:TCommentInline*
|
||||||
|
:[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
|
||||||
|
|
||||||
|
*:TCommentMaybeInline*
|
||||||
|
:[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
|
||||||
|
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
autoload/tcomment.vim~
|
||||||
|
|
||||||
|
*tcomment#DefineType()*
|
||||||
|
tcomment#DefineType(name, commentdef)
|
||||||
|
Currently this function just sets a variable
|
||||||
|
|
||||||
|
*tcomment#TypeExists()*
|
||||||
|
tcomment#TypeExists(name)
|
||||||
|
Return 1 if a comment type is defined.
|
||||||
|
|
||||||
|
*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:
|
||||||
|
as=STRING ... Use a specific comment definition
|
||||||
|
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"
|
||||||
|
rxend=N ... The above for "end"
|
||||||
|
rxmid=N ... The above for "middle"
|
||||||
|
2. 1-2 values for: ?commentPrefix, ?commentPostfix
|
||||||
|
3. a dictionary (internal use only)
|
||||||
|
|
||||||
|
commentMode:
|
||||||
|
G ... guess the value of commentMode
|
||||||
|
B ... block (use extra lines for the comment markers)
|
||||||
|
i ... maybe inline, guess
|
||||||
|
I ... inline
|
||||||
|
R ... right (comment the line right of the cursor)
|
||||||
|
v ... visual
|
||||||
|
o ... operator
|
||||||
|
By default, each line in range will be commented by adding the comment
|
||||||
|
prefix and postfix.
|
||||||
|
|
||||||
|
*tcomment#Operator()*
|
||||||
|
tcomment#Operator(type, ...)
|
||||||
|
|
||||||
|
*tcomment#OperatorLine()*
|
||||||
|
tcomment#OperatorLine(type)
|
||||||
|
|
||||||
|
*tcomment#OperatorAnyway()*
|
||||||
|
tcomment#OperatorAnyway(type)
|
||||||
|
|
||||||
|
*tcomment#OperatorLineAnyway()*
|
||||||
|
tcomment#OperatorLineAnyway(type)
|
||||||
|
|
||||||
|
*tcomment#CommentAs()*
|
||||||
|
tcomment#CommentAs(beg, end, commentAnyway, filetype, ?args...)
|
||||||
|
Where args is either:
|
||||||
|
1. A count NUMBER
|
||||||
|
2. An args list (see the notes on the "args" argument of
|
||||||
|
|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:
|
@ -64,7 +64,7 @@ let s:SpaceInfront = '^\s*<'
|
|||||||
let s:EndofName = '\($\|\s\|>\)'
|
let s:EndofName = '\($\|\s\|>\)'
|
||||||
|
|
||||||
" Buffer variables {{{1
|
" Buffer variables {{{1
|
||||||
let b:emptyTags='^\(img\|input\|param\|frame\|br\|hr\|meta\|link\|base\|area\)$'
|
let b:emptyTags='^\(area\|base\|br\|col\|command\|embed\|hr\|img\|input\|keygen\|link\|meta\|param\|source\|track\|wbr\)$'
|
||||||
let b:firstWasEndTag = 0
|
let b:firstWasEndTag = 0
|
||||||
let b:html_mode =((&filetype =~ 'x\?html') && !exists("g:xml_no_html"))
|
let b:html_mode =((&filetype =~ 'x\?html') && !exists("g:xml_no_html"))
|
||||||
let b:haveAtt = 0
|
let b:haveAtt = 0
|
||||||
@ -607,7 +607,11 @@ fun! s:CloseTagFun()
|
|||||||
normal! h
|
normal! h
|
||||||
if s:TagUnderCursor()
|
if s:TagUnderCursor()
|
||||||
if b:firstWasEndTag == 0
|
if b:firstWasEndTag == 0
|
||||||
|
if exists('b:did_indent') && b:did_indent == 1
|
||||||
|
exe "normal! 2f>s\<Cr>\<Esc>Ox\<Esc>$x"
|
||||||
|
else
|
||||||
exe "normal! 2f>s\<Cr>\<Esc>Ox\<Esc>>>$x"
|
exe "normal! 2f>s\<Cr>\<Esc>Ox\<Esc>>>$x"
|
||||||
|
en
|
||||||
start!
|
start!
|
||||||
retu
|
retu
|
||||||
en
|
en
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
" FILE: "/home/wlee/.vim/plugin/DirDiff.vim" {{{
|
" FILE: "/home/wlee/.vim/plugin/DirDiff.vim" {{{
|
||||||
" LAST MODIFICATION: "Mon, 20 Oct 2008 09:04:59 -0500 (wlee)"
|
" LAST MODIFICATION: "Mon, 20 Oct 2008 09:04:59 -0500 (wlee)"
|
||||||
" HEADER MAINTAINED BY: N/A
|
" HEADER MAINTAINED BY: N/A
|
||||||
" VERSION: 1.1.2
|
" VERSION: 1.1.3
|
||||||
" (C) 2001-2006 by William Lee, <wl1012@yahoo.com>
|
" (C) 2001-2010 by William Lee, <wl1012@yahoo.com>
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
|
|
||||||
@ -147,9 +147,12 @@
|
|||||||
"
|
"
|
||||||
" Florian Delizy for the i18n diff patch
|
" Florian Delizy for the i18n diff patch
|
||||||
" Robert Webb for his sorting function
|
" Robert Webb for his sorting function
|
||||||
|
" Wu WeiWei for his Chinese diff patch
|
||||||
" Salman Halim, Yosuke Kimura, and others for their suggestions
|
" Salman Halim, Yosuke Kimura, and others for their suggestions
|
||||||
"
|
"
|
||||||
" HISTORY:
|
" HISTORY:
|
||||||
|
" 1.1.3 - Applied the patch to 1.1.2 by Wu WeiWei in order to make diff
|
||||||
|
" that's localized in Chinese work.
|
||||||
" 1.1.2 - Applied the patch to 1.1.0 instead of 1.0.2. Please do not use
|
" 1.1.2 - Applied the patch to 1.1.0 instead of 1.0.2. Please do not use
|
||||||
" 1.1.1
|
" 1.1.1
|
||||||
" 1.1.1 - Make it work with filename with spaces. (Thanks to Atte Kojo)
|
" 1.1.1 - Make it work with filename with spaces. (Thanks to Atte Kojo)
|
||||||
@ -281,6 +284,11 @@ if !exists("g:DirDiffTextOnlyIn")
|
|||||||
let g:DirDiffTextOnlyIn = "Only in "
|
let g:DirDiffTextOnlyIn = "Only in "
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" String used for the English equivalent ": ")
|
||||||
|
if !exists("g:DirDiffTextOnlyInCenter")
|
||||||
|
let g:DirDiffTextOnlyInCenter = ": "
|
||||||
|
endif
|
||||||
|
|
||||||
" Set some script specific variables:
|
" Set some script specific variables:
|
||||||
"
|
"
|
||||||
let s:DirDiffFirstDiffLine = 6
|
let s:DirDiffFirstDiffLine = 6
|
||||||
@ -778,11 +786,11 @@ endfunction
|
|||||||
|
|
||||||
"Returns the source (A or B) of the "Only" line
|
"Returns the source (A or B) of the "Only" line
|
||||||
function! <SID>ParseOnlySrc(line)
|
function! <SID>ParseOnlySrc(line)
|
||||||
return substitute(a:line, '^.*' . s:DirDiffDiffOnlyLine . '\[\(.\)\].*:.*', '\1', '')
|
return substitute(a:line, '^.*' . s:DirDiffDiffOnlyLine . '\[\(.\)\].*' . s:DirDiffDiffOnlyLineCenter . '.*', '\1', '')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! <SID>ParseOnlyFile(line)
|
function! <SID>ParseOnlyFile(line)
|
||||||
let regex = '^.*' . s:DirDiffDiffOnlyLine . '\[.\]\(.*\): \(.*\)'
|
let regex = '^.*' . s:DirDiffDiffOnlyLine . '\[.\]\(.*\)' . s:DirDiffDiffOnlyLineCenter . '\(.*\)'
|
||||||
let root = substitute(a:line, regex , '\1', '')
|
let root = substitute(a:line, regex , '\1', '')
|
||||||
let file = root . s:sep . substitute(a:line, regex , '\2', '')
|
let file = root . s:sep . substitute(a:line, regex , '\2', '')
|
||||||
return file
|
return file
|
||||||
@ -1006,6 +1014,7 @@ function! <SID>GetDiffStrings()
|
|||||||
" what's set in the global variables
|
" what's set in the global variables
|
||||||
|
|
||||||
if (g:DirDiffDynamicDiffText == 0)
|
if (g:DirDiffDynamicDiffText == 0)
|
||||||
|
let s:DirDiffDiffOnlyLineCenter = g:DirDiffTextOnlyInCenter
|
||||||
let s:DirDiffDiffOnlyLine = g:DirDiffTextOnlyIn
|
let s:DirDiffDiffOnlyLine = g:DirDiffTextOnlyIn
|
||||||
let s:DirDiffDifferLine = g:DirDiffTextFiles
|
let s:DirDiffDifferLine = g:DirDiffTextFiles
|
||||||
let s:DirDiffDifferAndLine = g:DirDiffTextAnd
|
let s:DirDiffDifferAndLine = g:DirDiffTextAnd
|
||||||
@ -1032,7 +1041,9 @@ function! <SID>GetDiffStrings()
|
|||||||
"echo "First line: " . getline(1)
|
"echo "First line: " . getline(1)
|
||||||
"echo "tmp1: " . tmp1
|
"echo "tmp1: " . tmp1
|
||||||
"echo "tmp1rx: " . tmp1rx
|
"echo "tmp1rx: " . tmp1rx
|
||||||
let s:DirDiffDiffOnlyLine = substitute( getline(1), tmp1rx . ".*$", "", '')
|
let regex = '\(^.*\)' . tmp1rx . '\(.*\)' . "test"
|
||||||
|
let s:DirDiffDiffOnlyLine = substitute( getline(1), regex, '\1', '')
|
||||||
|
let s:DirDiffDiffOnlyLineCenter = substitute( getline(1), regex, '\2', '')
|
||||||
"echo "DirDiff Only: " . s:DirDiffDiffOnlyLine
|
"echo "DirDiff Only: " . s:DirDiffDiffOnlyLine
|
||||||
|
|
||||||
q
|
q
|
||||||
@ -1067,4 +1078,12 @@ function! <SID>GetDiffStrings()
|
|||||||
call <SID>Delete(tmp2)
|
call <SID>Delete(tmp2)
|
||||||
call <SID>Delete(tmpdiff)
|
call <SID>Delete(tmpdiff)
|
||||||
|
|
||||||
|
"avoid get diff text again
|
||||||
|
let g:DirDiffTextOnlyInCenter = s:DirDiffDiffOnlyLineCenter
|
||||||
|
let g:DirDiffTextOnlyIn = s:DirDiffDiffOnlyLine
|
||||||
|
let g:DirDiffTextFiles = s:DirDiffDifferLine
|
||||||
|
let g:DirDiffTextAnd = s:DirDiffDifferAndLine
|
||||||
|
let g:DirDiffTextDiffer = s:DirDiffDifferEndLine
|
||||||
|
let g:DirDiffDynamicDiffText = 0
|
||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -1,13 +1,46 @@
|
|||||||
" DoxygenToolkit.vim
|
" DoxygenToolkit.vim
|
||||||
" Brief: Usefull tools for Doxygen (comment, author, license).
|
" Brief: Usefull tools for Doxygen (comment, author, license).
|
||||||
" Version: 0.2.7
|
" Version: 0.2.13
|
||||||
" Date: 12/06/09
|
" Date: 2010/10/16
|
||||||
" Author: Mathias Lorente
|
" Author: Mathias Lorente
|
||||||
"
|
"
|
||||||
" TODO: add automatically (option controlled) in/in out flags to function
|
" TODO: add automatically (option controlled) in/in out flags to function
|
||||||
" parameters
|
" parameters
|
||||||
" TODO: (Python) Check default paramareters defined as list/dictionnary/tuple
|
" TODO: (Python) Check default paramareters defined as list/dictionnary/tuple
|
||||||
"
|
"
|
||||||
|
" Note: Correct insertion position and 'xxx_post' parameters.
|
||||||
|
" - Insert position is correct when g:DoxygenToolkit_compactOneLineDoc = "yes"
|
||||||
|
" and let g:DoxygenToolkit_commentType = "C++" are set.
|
||||||
|
" - When you define:
|
||||||
|
" g:DoxygenToolkit_briefTag_pre = "@brief "
|
||||||
|
" g:DoxygenToolkit_briefTag_post = "<++>"
|
||||||
|
" g:DoxygenToolkit_briefTag_funcName = "yes"
|
||||||
|
" Documentation generated with these parameters is something like:
|
||||||
|
" /// @brief foo <++>
|
||||||
|
" You can configure similarly parameters to get something like:
|
||||||
|
" /// @brief foo <++>
|
||||||
|
" /// @param bar <++>
|
||||||
|
" /// @param baz <++>
|
||||||
|
"
|
||||||
|
" Note: Position the cursor at the right position for one line documentation.
|
||||||
|
"
|
||||||
|
" Note: Remove trailing blank characters where they are not needed.
|
||||||
|
"
|
||||||
|
" Note: 'extern' keyword added in list of values to ignore for return type.
|
||||||
|
"
|
||||||
|
" Note: Correct bugs related to templates and add support for throw statement
|
||||||
|
" (many thanks to Dennis Lubert):
|
||||||
|
" - Template parameter of different type from class and typename are
|
||||||
|
" recognized.
|
||||||
|
" - Indentation mistake while detecting template.
|
||||||
|
" - New option are available: g:DoxygenToolkit_throwTag_pre and
|
||||||
|
" g:DoxygenToolkit_throwTag_post
|
||||||
|
"
|
||||||
|
" Note: Add support for documentation of template parameters.
|
||||||
|
" Thanks to Dennis (plasmahh) and its suggestions.
|
||||||
|
" - New option are available: g:DoxygenToolkit_templateParamTag_pre
|
||||||
|
" and g:DoxygenToolkit_templateParamTag_post
|
||||||
|
"
|
||||||
" Note: Solve almost all compatibility problem with c/c++ IDE
|
" Note: Solve almost all compatibility problem with c/c++ IDE
|
||||||
"
|
"
|
||||||
" Note: Bug correction and improve compatibility with c/c++ IDE
|
" Note: Bug correction and improve compatibility with c/c++ IDE
|
||||||
@ -252,6 +285,12 @@ endif
|
|||||||
if !exists("g:DoxygenToolkit_briefTag_post")
|
if !exists("g:DoxygenToolkit_briefTag_post")
|
||||||
let g:DoxygenToolkit_briefTag_post = ""
|
let g:DoxygenToolkit_briefTag_post = ""
|
||||||
endif
|
endif
|
||||||
|
if !exists("g:DoxygenToolkit_templateParamTag_pre")
|
||||||
|
let g:DoxygenToolkit_templateParamTag_pre = "@tparam "
|
||||||
|
endif
|
||||||
|
if !exists("g:DoxygenToolkit_templateParamTag_post")
|
||||||
|
let g:DoxygenToolkit_templateParamTag_post = ""
|
||||||
|
endif
|
||||||
if !exists("g:DoxygenToolkit_paramTag_pre")
|
if !exists("g:DoxygenToolkit_paramTag_pre")
|
||||||
let g:DoxygenToolkit_paramTag_pre = "@param "
|
let g:DoxygenToolkit_paramTag_pre = "@param "
|
||||||
endif
|
endif
|
||||||
@ -261,6 +300,12 @@ endif
|
|||||||
if !exists("g:DoxygenToolkit_returnTag")
|
if !exists("g:DoxygenToolkit_returnTag")
|
||||||
let g:DoxygenToolkit_returnTag = "@return "
|
let g:DoxygenToolkit_returnTag = "@return "
|
||||||
endif
|
endif
|
||||||
|
if !exists("g:DoxygenToolkit_throwTag_pre")
|
||||||
|
let g:DoxygenToolkit_throwTag_pre = "@throw " " @exception is also valid
|
||||||
|
endif
|
||||||
|
if !exists("g:DoxygenToolkit_throwTag_post")
|
||||||
|
let g:DoxygenToolkit_throwTag_post = ""
|
||||||
|
endif
|
||||||
if !exists("g:DoxygenToolkit_blockHeader")
|
if !exists("g:DoxygenToolkit_blockHeader")
|
||||||
let g:DoxygenToolkit_blockHeader = ""
|
let g:DoxygenToolkit_blockHeader = ""
|
||||||
endif
|
endif
|
||||||
@ -343,7 +388,7 @@ if !exists("g:DoxygenToolkit_compactDoc")
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" Necessary '\<' and '\>' will be added to each item of the list.
|
" Necessary '\<' and '\>' will be added to each item of the list.
|
||||||
let s:ignoreForReturn = ['template', 'explicit', 'inline', 'static', 'virtual', 'void\([[:blank:]]*\*\)\@!', 'const', 'volatile', 'struct']
|
let s:ignoreForReturn = ['template', 'explicit', 'inline', 'static', 'virtual', 'void\([[:blank:]]*\*\)\@!', 'const', 'volatile', 'struct', 'extern']
|
||||||
if !exists("g:DoxygenToolkit_ignoreForReturn")
|
if !exists("g:DoxygenToolkit_ignoreForReturn")
|
||||||
let g:DoxygenToolkit_ignoreForReturn = s:ignoreForReturn[:]
|
let g:DoxygenToolkit_ignoreForReturn = s:ignoreForReturn[:]
|
||||||
else
|
else
|
||||||
@ -517,6 +562,7 @@ function! <SID>DoxygenCommentFunc()
|
|||||||
let l:endDocPattern = ';\|{\|\%([^:]\zs:\ze\%([^:]\|$\)\)'
|
let l:endDocPattern = ';\|{\|\%([^:]\zs:\ze\%([^:]\|$\)\)'
|
||||||
let l:commentPattern = '\%(/*\)\|\%(//\)\'
|
let l:commentPattern = '\%(/*\)\|\%(//\)\'
|
||||||
let l:templateParameterPattern = "<[^<>]*>"
|
let l:templateParameterPattern = "<[^<>]*>"
|
||||||
|
let l:throwPattern = '.*\<throw\>[[:blank:]]*(\([^()]*\)).*' "available only for 'cpp' type
|
||||||
|
|
||||||
let l:classPattern = '\<class\>[[:blank:]]\+\zs'.l:someNameWithNamespacePattern.'\ze.*\%('.l:endDocPattern.'\)'
|
let l:classPattern = '\<class\>[[:blank:]]\+\zs'.l:someNameWithNamespacePattern.'\ze.*\%('.l:endDocPattern.'\)'
|
||||||
let l:structPattern = '\<struct\>[[:blank:]]\+\zs'.l:someNameWithNamespacePattern.'\ze[^(),]*\%('.l:endDocPattern.'\)'
|
let l:structPattern = '\<struct\>[[:blank:]]\+\zs'.l:someNameWithNamespacePattern.'\ze[^(),]*\%('.l:endDocPattern.'\)'
|
||||||
@ -539,7 +585,7 @@ function! <SID>DoxygenCommentFunc()
|
|||||||
let l:count = 1
|
let l:count = 1
|
||||||
let l:endDocFound = 0
|
let l:endDocFound = 0
|
||||||
|
|
||||||
let l:doc = { "type": "", "name": "None", "params": [], "returns": "" }
|
let l:doc = { "type": "", "name": "None", "params": [], "returns": "" , "templates": [], "throws": [] }
|
||||||
|
|
||||||
" Mark current line for future use
|
" Mark current line for future use
|
||||||
mark d
|
mark d
|
||||||
@ -566,13 +612,28 @@ function! <SID>DoxygenCommentFunc()
|
|||||||
|
|
||||||
" Look for the end of the function/class/... to document
|
" Look for the end of the function/class/... to document
|
||||||
" TODO does not work when function/class/... is commented out!
|
" TODO does not work when function/class/... is commented out!
|
||||||
|
let l:readError = "Cannot reach end of function/class/... declaration!"
|
||||||
let l:count = 0
|
let l:count = 0
|
||||||
|
let l:throwCompleted = 0
|
||||||
|
let l:endReadPattern = l:endDocPattern
|
||||||
while( l:endDocFound == 0 && l:count < g:DoxygenToolkit_maxFunctionProtoLines )
|
while( l:endDocFound == 0 && l:count < g:DoxygenToolkit_maxFunctionProtoLines )
|
||||||
let l:lineBuffer = s:RemoveComments( l:lineBuffer )
|
let l:lineBuffer = s:RemoveComments( l:lineBuffer )
|
||||||
" Valid only for cpp. For Python it must be 'class ...:' or 'def ...:' or
|
" Valid only for cpp. For Python it must be 'class ...:' or 'def ...:' or
|
||||||
" '... EOL'.
|
" '... EOL'.
|
||||||
if( match( l:lineBuffer, l:endDocPattern ) != -1 )
|
if( match( l:lineBuffer, l:endReadPattern ) != -1 )
|
||||||
|
" Look for throw statement at the end
|
||||||
|
if( s:CheckFileType() == "cpp" && l:throwCompleted == 0 )
|
||||||
|
" throw statement can have already been read or can be on next line
|
||||||
|
if( match( l:lineBuffer.' '.getline( line ( "." ) + 1 ), '.*\<throw\>.*' ) != -1 )
|
||||||
|
let l:endReadPattern = l:throwPattern
|
||||||
|
let l:throwCompleted = 1
|
||||||
|
let l:readError = "Cannot reach end of throw statement"
|
||||||
|
else
|
||||||
let l:endDocFound = 1
|
let l:endDocFound = 1
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
let l:endDocFound = 1
|
||||||
|
endif
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
exec "normal j"
|
exec "normal j"
|
||||||
@ -585,7 +646,7 @@ function! <SID>DoxygenCommentFunc()
|
|||||||
" Fall here when only comments have been found.
|
" Fall here when only comments have been found.
|
||||||
call s:WarnMsg( "Nothing to document here!" )
|
call s:WarnMsg( "Nothing to document here!" )
|
||||||
else
|
else
|
||||||
call s:WarnMsg( "Cannot reach end of function/class/... declaration!" )
|
call s:WarnMsg( l:readError )
|
||||||
endif
|
endif
|
||||||
exec "normal `d"
|
exec "normal `d"
|
||||||
return
|
return
|
||||||
@ -594,6 +655,8 @@ function! <SID>DoxygenCommentFunc()
|
|||||||
" Trim the buffer
|
" Trim the buffer
|
||||||
let l:lineBuffer = substitute( l:lineBuffer, "^[[:blank:]]*\|[[:blank:]]*$", "", "g" )
|
let l:lineBuffer = substitute( l:lineBuffer, "^[[:blank:]]*\|[[:blank:]]*$", "", "g" )
|
||||||
|
|
||||||
|
" Check whether it is a template definition
|
||||||
|
call s:ParseFunctionTemplateParameters( l:lineBuffer, l:doc )
|
||||||
" Remove any template parameter.
|
" Remove any template parameter.
|
||||||
if( s:CheckFileType() == "cpp" )
|
if( s:CheckFileType() == "cpp" )
|
||||||
while( match( l:lineBuffer, l:templateParameterPattern ) != -1 )
|
while( match( l:lineBuffer, l:templateParameterPattern ) != -1 )
|
||||||
@ -637,6 +700,9 @@ function! <SID>DoxygenCommentFunc()
|
|||||||
else
|
else
|
||||||
let l:doc.type = 'function'
|
let l:doc.type = 'function'
|
||||||
call s:ParseFunctionParameters( l:lineBuffer, l:doc )
|
call s:ParseFunctionParameters( l:lineBuffer, l:doc )
|
||||||
|
if( l:throwCompleted == 1 )
|
||||||
|
call s:ParseThrowParameters( l:lineBuffer, l:doc, l:throwPattern )
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" This is an attribute for Python
|
" This is an attribute for Python
|
||||||
@ -673,17 +739,17 @@ function! <SID>DoxygenCommentFunc()
|
|||||||
" Brief
|
" Brief
|
||||||
if( g:DoxygenToolkit_compactOneLineDoc =~ "yes" && l:doc.returns != "yes" && len( l:doc.params ) == 0 )
|
if( g:DoxygenToolkit_compactOneLineDoc =~ "yes" && l:doc.returns != "yes" && len( l:doc.params ) == 0 )
|
||||||
let s:compactOneLineDoc = "yes"
|
let s:compactOneLineDoc = "yes"
|
||||||
"exec "normal O".s:startCommentTag.g:DoxygenToolkit_briefTag_pre.g:DoxygenToolkit_briefTag_post
|
|
||||||
exec "normal O".strpart( s:startCommentTag, 0, 1 )
|
exec "normal O".strpart( s:startCommentTag, 0, 1 )
|
||||||
exec "normal A".strpart( s:startCommentTag, 1 ).g:DoxygenToolkit_briefTag_pre.g:DoxygenToolkit_briefTag_post
|
exec "normal A".strpart( s:startCommentTag, 1 ).g:DoxygenToolkit_briefTag_pre
|
||||||
else
|
else
|
||||||
let s:compactOneLineDoc = "no"
|
let s:compactOneLineDoc = "no"
|
||||||
let l:insertionMode = s:StartDocumentationBlock()
|
let l:insertionMode = s:StartDocumentationBlock()
|
||||||
exec "normal ".l:insertionMode.s:interCommentTag.g:DoxygenToolkit_briefTag_pre.g:DoxygenToolkit_briefTag_post
|
exec "normal ".l:insertionMode.s:interCommentTag.g:DoxygenToolkit_briefTag_pre
|
||||||
endif
|
endif
|
||||||
if( l:doc.name != "None" )
|
if( l:doc.name != "None" )
|
||||||
exec "normal A".l:doc.name." "
|
exec "normal A".l:doc.name." "
|
||||||
endif
|
endif
|
||||||
|
exec "normal A".g:DoxygenToolkit_briefTag_post
|
||||||
|
|
||||||
" Mark the line where the cursor will be positionned.
|
" Mark the line where the cursor will be positionned.
|
||||||
mark d
|
mark d
|
||||||
@ -694,26 +760,51 @@ function! <SID>DoxygenCommentFunc()
|
|||||||
else
|
else
|
||||||
let s:insertEmptyLine = 1
|
let s:insertEmptyLine = 1
|
||||||
endif
|
endif
|
||||||
for param in l:doc.params
|
for param in l:doc.templates
|
||||||
if( s:insertEmptyLine == 1 )
|
if( s:insertEmptyLine == 1 )
|
||||||
exec "normal o".s:interCommentTag
|
exec "normal o".substitute( s:interCommentTag, "[[:blank:]]*$", "", "" )
|
||||||
let s:insertEmptyLine = 0
|
let s:insertEmptyLine = 0
|
||||||
endif
|
endif
|
||||||
exec "normal o".s:interCommentTag.g:DoxygenToolkit_paramTag_pre.g:DoxygenToolkit_paramTag_post.param
|
exec "normal o".s:interCommentTag.g:DoxygenToolkit_templateParamTag_pre.param.g:DoxygenToolkit_templateParamTag_post
|
||||||
|
endfor
|
||||||
|
for param in l:doc.params
|
||||||
|
if( s:insertEmptyLine == 1 )
|
||||||
|
exec "normal o".substitute( s:interCommentTag, "[[:blank:]]*$", "", "" )
|
||||||
|
let s:insertEmptyLine = 0
|
||||||
|
endif
|
||||||
|
exec "normal o".s:interCommentTag.g:DoxygenToolkit_paramTag_pre.param.g:DoxygenToolkit_paramTag_post
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" Returned value
|
" Returned value
|
||||||
if( l:doc.returns == "yes" )
|
if( l:doc.returns == "yes" )
|
||||||
if( g:DoxygenToolkit_compactDoc != "yes" )
|
if( g:DoxygenToolkit_compactDoc != "yes" )
|
||||||
exec "normal o".s:interCommentTag
|
exec "normal o".substitute( s:interCommentTag, "[[:blank:]]*$", "", "" )
|
||||||
endif
|
endif
|
||||||
exec "normal o".s:interCommentTag.g:DoxygenToolkit_returnTag
|
exec "normal o".s:interCommentTag.g:DoxygenToolkit_returnTag
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Exception (throw) values (cpp only)
|
||||||
|
if( len( l:doc.throws ) > 0 )
|
||||||
|
if( g:DoxygenToolkit_compactDoc =~ "yes" )
|
||||||
|
let s:insertEmptyLine = 0
|
||||||
|
else
|
||||||
|
let s:insertEmptyLine = 1
|
||||||
|
endif
|
||||||
|
for param in l:doc.throws
|
||||||
|
if( s:insertEmptyLine == 1 )
|
||||||
|
exec "normal o".substitute( s:interCommentTag, "[[:blank:]]*$", "", "" )
|
||||||
|
let s:insertEmptyLine = 0
|
||||||
|
endif
|
||||||
|
exec "normal o".s:interCommentTag.g:DoxygenToolkit_throwTag_pre.param.g:DoxygenToolkit_throwTag_post
|
||||||
|
endfor
|
||||||
|
endif
|
||||||
|
|
||||||
" End (if any) of documentation block.
|
" End (if any) of documentation block.
|
||||||
if( s:endCommentTag != "" )
|
if( s:endCommentTag != "" )
|
||||||
if( s:compactOneLineDoc =~ "yes" )
|
if( s:compactOneLineDoc =~ "yes" )
|
||||||
let s:execCommand = "A"
|
let s:execCommand = "A"
|
||||||
|
exec "normal A "
|
||||||
|
exec "normal $md"
|
||||||
else
|
else
|
||||||
let s:execCommand = "o"
|
let s:execCommand = "o"
|
||||||
endif
|
endif
|
||||||
@ -728,7 +819,11 @@ function! <SID>DoxygenCommentFunc()
|
|||||||
exec "normal `d"
|
exec "normal `d"
|
||||||
|
|
||||||
call s:RestoreParameters()
|
call s:RestoreParameters()
|
||||||
|
if( s:compactOneLineDoc =~ "yes" && s:endCommentTag != "" )
|
||||||
|
startinsert
|
||||||
|
else
|
||||||
startinsert!
|
startinsert!
|
||||||
|
endif
|
||||||
|
|
||||||
" DEBUG purpose only
|
" DEBUG purpose only
|
||||||
"call s:WarnMsg( "Found a ".l:doc.type." named ".l:doc.name." (env: ".s:CheckFileType().")." )
|
"call s:WarnMsg( "Found a ".l:doc.type." named ".l:doc.name." (env: ".s:CheckFileType().")." )
|
||||||
@ -760,7 +855,7 @@ function! s:StartDocumentationBlock()
|
|||||||
if( s:startCommentTag != s:interCommentTag )
|
if( s:startCommentTag != s:interCommentTag )
|
||||||
"exec "normal O".s:startCommentTag
|
"exec "normal O".s:startCommentTag
|
||||||
exec "normal O".strpart( s:startCommentTag, 0, 1 )
|
exec "normal O".strpart( s:startCommentTag, 0, 1 )
|
||||||
exec "normal A".strpart( s:startCommentTag, 1 )
|
exec "normal A".substitute( strpart( s:startCommentTag, 1 ), "[[:blank:]]*$", "", "" )
|
||||||
let l:insertionMode = "o"
|
let l:insertionMode = "o"
|
||||||
else
|
else
|
||||||
let l:insertionMode = "O"
|
let l:insertionMode = "O"
|
||||||
@ -825,6 +920,7 @@ function! s:ParseFunctionParameters( lineBuffer, doc )
|
|||||||
" all the function definition to know whether a value is returned or not.
|
" all the function definition to know whether a value is returned or not.
|
||||||
if( s:CheckFileType() == "cpp" )
|
if( s:CheckFileType() == "cpp" )
|
||||||
let l:functionBuffer = strpart( a:lineBuffer, 0, l:paramPosition )
|
let l:functionBuffer = strpart( a:lineBuffer, 0, l:paramPosition )
|
||||||
|
" Remove unnecessary elements
|
||||||
for ignored in g:DoxygenToolkit_ignoreForReturn
|
for ignored in g:DoxygenToolkit_ignoreForReturn
|
||||||
let l:functionBuffer = substitute( l:functionBuffer, '\<'.ignored.'\>', '', 'g' )
|
let l:functionBuffer = substitute( l:functionBuffer, '\<'.ignored.'\>', '', 'g' )
|
||||||
endfor
|
endfor
|
||||||
@ -839,7 +935,7 @@ function! s:ParseFunctionParameters( lineBuffer, doc )
|
|||||||
let l:parametersBuffer = strpart( a:lineBuffer, l:paramPosition + 1 )
|
let l:parametersBuffer = strpart( a:lineBuffer, l:paramPosition + 1 )
|
||||||
" Remove trailing closing bracket and everything that follows and trim.
|
" Remove trailing closing bracket and everything that follows and trim.
|
||||||
if( s:CheckFileType() == "cpp" )
|
if( s:CheckFileType() == "cpp" )
|
||||||
let l:parametersBuffer = substitute( l:parametersBuffer, ')[^)]*\%(;\|{\|\%([^:]:\%([^:]\|$\)\)\).*', '', '' )
|
let l:parametersBuffer = substitute( l:parametersBuffer, ')[^)]*\%(;\|{\|\%([^:]:\%([^:]\|$\)\)\|\%(\<throw\>\)\).*', '', '' )
|
||||||
else
|
else
|
||||||
let l:parametersBuffer = substitute( l:parametersBuffer, ')[^)]*:.*', '', '' )
|
let l:parametersBuffer = substitute( l:parametersBuffer, ')[^)]*:.*', '', '' )
|
||||||
endif
|
endif
|
||||||
@ -941,6 +1037,38 @@ function! s:ParseParameter( param )
|
|||||||
return l:paramName
|
return l:paramName
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
" Extract template parameter name for function/class/method
|
||||||
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
function! s:ParseFunctionTemplateParameters( lineBuffer, doc )
|
||||||
|
if( match( a:lineBuffer, '^[[:blank:]]*template' ) == 0 )
|
||||||
|
let l:firstIndex = stridx( a:lineBuffer, '<' )
|
||||||
|
if( l:firstIndex != -1 )
|
||||||
|
let l:lastIndex = stridx( a:lineBuffer, '>', l:firstIndex + 1 )
|
||||||
|
if( l:lastIndex != -1 )
|
||||||
|
" Keep only template parameters
|
||||||
|
let l:parameters = strpart( a:lineBuffer, l:firstIndex + 1, l:lastIndex - l:firstIndex - 1)
|
||||||
|
" Split on separator (,)
|
||||||
|
let l:params = split( l:parameters, '\,' )
|
||||||
|
for param in l:params
|
||||||
|
" Extract template parameter name
|
||||||
|
let l:paramName = split( split( param, '=' )[0], '[[:blank:]]' )[-1]
|
||||||
|
call add( a:doc.templates, l:paramName )
|
||||||
|
endfor
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
" Extract throw parameter name
|
||||||
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
function! s:ParseThrowParameters( lineBuffer, doc, throwPattern )
|
||||||
|
let l:throwParams = substitute( a:lineBuffer, a:throwPattern, '\1', "" )
|
||||||
|
for param in split( l:throwParams, "," )
|
||||||
|
call add( a:doc.throws, substitute( param, '[[:blank:]]', '', "" ) )
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
" Define start/end documentation format and backup generic parameters.
|
" Define start/end documentation format and backup generic parameters.
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
" License: This File is placed in the Public Domain.
|
" License: This File is placed in the Public Domain.
|
||||||
" Revision | Date [DD.MM.YY] | Changes
|
" Revision | Date [DD.MM.YY] | Changes
|
||||||
" 00.01.00 | 05.07.09 | 01. Revision
|
" 00.01.00 | 05.07.09 | 01. Revision
|
||||||
|
" 00.02.00 | 29.03.10 | Fun added, MakeSrecS5()
|
||||||
|
|
||||||
if exists("loaded_editsrec")
|
if exists("loaded_editsrec")
|
||||||
finish
|
finish
|
||||||
@ -61,6 +62,13 @@ endif
|
|||||||
noremap <unique> <script> <Plug>EditSrecPartCS <SID>AutoPartCS
|
noremap <unique> <script> <Plug>EditSrecPartCS <SID>AutoPartCS
|
||||||
noremap <SID>AutoPartCS <Esc>:call <SID>AutoPartCS()<CR>
|
noremap <SID>AutoPartCS <Esc>:call <SID>AutoPartCS()<CR>
|
||||||
|
|
||||||
|
" M5 = MakeS5
|
||||||
|
if !hasmapto('<Plug>MakeSrecLineS5')
|
||||||
|
map <unique> <Leader>m5 <Plug>MakeSrecLineS5
|
||||||
|
endif
|
||||||
|
noremap <unique> <script> <Plug>MakeSrecLineS5 <SID>MakeSrecS5
|
||||||
|
noremap <SID>MakeSrecS5 <Esc>:call <SID>MakeSrecS5()<CR>
|
||||||
|
|
||||||
" obsolete Mappings
|
" obsolete Mappings
|
||||||
"imap <F5> <Esc>:call <SID>AutoLineBC()<CR>a
|
"imap <F5> <Esc>:call <SID>AutoLineBC()<CR>a
|
||||||
"imap <F6> <Esc>:call <SID>AutoLineAD()<CR>a
|
"imap <F6> <Esc>:call <SID>AutoLineAD()<CR>a
|
||||||
@ -165,5 +173,16 @@ fun s:AutoPartCS()
|
|||||||
unlet s:ln
|
unlet s:ln
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
|
" make S5 record
|
||||||
|
fun s:MakeSrecS5()
|
||||||
|
let s:ln = getline(".")
|
||||||
|
|
||||||
|
let s:ln = s:ln . libsrec#MkS5(s:ln)
|
||||||
|
|
||||||
|
call setline(".", s:ln)
|
||||||
|
|
||||||
|
unlet s:ln
|
||||||
|
endfun
|
||||||
|
|
||||||
let &cpo = s:save_cpo
|
let &cpo = s:save_cpo
|
||||||
|
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
" License: This File is placed in the Public Domain.
|
" License: This File is placed in the Public Domain.
|
||||||
" Revision | Date [DD.MM.YY] | Changes
|
" Revision | Date [DD.MM.YY] | Changes
|
||||||
" 00.01.00 | 05.07.09 | 01. Revision
|
" 00.01.00 | 05.07.09 | 01. Revision
|
||||||
|
" 00.01.10 | 29.03.10 | BugFix, in libsrec#CrCS()
|
||||||
|
" | | leading Zeros in Result
|
||||||
|
" 00.02.00 | 29.03.10 | Fun added
|
||||||
|
|
||||||
" This File contains Test Cases for the Plugin 'editsrec.vim'
|
" This File contains Test Cases for the Plugin 'editsrec.vim'
|
||||||
" and its Library 'libsrec.vim'.
|
" and its Library 'libsrec.vim'.
|
||||||
@ -335,3 +338,19 @@ type "<Esc><Leader>pc"
|
|||||||
the following Line will be created
|
the following Line will be created
|
||||||
S9030000FC
|
S9030000FC
|
||||||
|
|
||||||
|
TestCase for leading Zeros -------
|
||||||
|
insert a new Line and type "S30F00000000000000000000000000EE"
|
||||||
|
type "<Esc><Leader>lc"
|
||||||
|
the following Line will be created
|
||||||
|
S30F00000000000000000000000000EE02
|
||||||
|
|
||||||
|
TestCase for Making S5 Record ----
|
||||||
|
insert
|
||||||
|
S30F00000000000000000000000000EE02
|
||||||
|
S30F00000000000000000000000000EE02
|
||||||
|
S30F00000000000000000000000000EE02
|
||||||
|
insert a new Line
|
||||||
|
type "<Esc><Leader>m5"
|
||||||
|
the following Line will be created
|
||||||
|
S5030003FC
|
||||||
|
|
||||||
|
255
vimfiles/plugin/tcomment.vim
Normal file
255
vimfiles/plugin/tcomment.vim
Normal file
@ -0,0 +1,255 @@
|
|||||||
|
" 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: 2010-10-02.
|
||||||
|
" @Revision: 709
|
||||||
|
"
|
||||||
|
" GetLatestVimScripts: 1173 1 tComment.vim
|
||||||
|
|
||||||
|
if &cp || exists('loaded_tcomment')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let loaded_tcomment = 201
|
||||||
|
|
||||||
|
if !exists("g:tcommentMapLeader1")
|
||||||
|
" g:tcommentMapLeader1 should be a shortcut that can be used with
|
||||||
|
" map, imap, vmap.
|
||||||
|
let g:tcommentMapLeader1 = '<c-_>'
|
||||||
|
endif
|
||||||
|
if !exists("g:tcommentMapLeader2")
|
||||||
|
" g:tcommentMapLeader2 should be a shortcut that can be used with
|
||||||
|
" map, xmap.
|
||||||
|
let g:tcommentMapLeader2 = '<Leader>_'
|
||||||
|
endif
|
||||||
|
if !exists("g:tcommentMapLeaderOp1")
|
||||||
|
let g:tcommentMapLeaderOp1 = 'gc'
|
||||||
|
endif
|
||||||
|
if !exists("g:tcommentMapLeaderOp2")
|
||||||
|
let g:tcommentMapLeaderOp2 = 'gC'
|
||||||
|
endif
|
||||||
|
if !exists("g:tcommentOpModeExtra")
|
||||||
|
let g:tcommentOpModeExtra = ''
|
||||||
|
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(<line1>, <line2>, 'G', "<bang>", <f-args>)
|
||||||
|
|
||||||
|
" :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(<line1>, <line2>, "<bang>", <f-args>)
|
||||||
|
|
||||||
|
" :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(<line1>, <line2>, 'R', "<bang>", <f-args>)
|
||||||
|
|
||||||
|
" :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(<line1>, <line2>, 'B', "<bang>", <f-args>)
|
||||||
|
|
||||||
|
" :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(<line1>, <line2>, 'I', "<bang>", <f-args>)
|
||||||
|
|
||||||
|
" :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(<line1>, <line2>, 'i', "<bang>", <f-args>)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (g:tcommentMapLeader1 != '')
|
||||||
|
exec 'noremap <silent> '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' :TComment<cr>'
|
||||||
|
exec 'vnoremap <silent> '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' :TCommentMaybeInline<cr>'
|
||||||
|
exec 'inoremap <silent> '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' <c-o>:TComment<cr>'
|
||||||
|
exec 'noremap <silent> '. g:tcommentMapLeader1 .'p m`vip:TComment<cr>``'
|
||||||
|
exec 'inoremap <silent> '. g:tcommentMapLeader1 .'p <c-o>:norm! m`vip<cr>:TComment<cr><c-o>``'
|
||||||
|
exec 'noremap '. g:tcommentMapLeader1 .'<space> :TComment '
|
||||||
|
exec 'inoremap '. g:tcommentMapLeader1 .'<space> <c-o>:TComment '
|
||||||
|
exec 'inoremap <silent> '. g:tcommentMapLeader1 .'r <c-o>:TCommentRight<cr>'
|
||||||
|
exec 'noremap <silent> '. g:tcommentMapLeader1 .'r :TCommentRight<cr>'
|
||||||
|
exec 'vnoremap <silent> '. g:tcommentMapLeader1 .'i :TCommentInline<cr>'
|
||||||
|
exec 'vnoremap <silent> '. g:tcommentMapLeader1 .'r :TCommentRight<cr>'
|
||||||
|
exec 'noremap '. g:tcommentMapLeader1 .'b :TCommentBlock<cr>'
|
||||||
|
exec 'inoremap '. g:tcommentMapLeader1 .'b <c-o>:TCommentBlock<cr>'
|
||||||
|
exec 'noremap '. g:tcommentMapLeader1 .'a :TCommentAs '
|
||||||
|
exec 'inoremap '. g:tcommentMapLeader1 .'a <c-o>:TCommentAs '
|
||||||
|
exec 'noremap '. g:tcommentMapLeader1 .'n :TCommentAs <c-r>=&ft<cr> '
|
||||||
|
exec 'inoremap '. g:tcommentMapLeader1 .'n <c-o>:TCommentAs <c-r>=&ft<cr> '
|
||||||
|
exec 'noremap '. g:tcommentMapLeader1 .'s :TCommentAs <c-r>=&ft<cr>_'
|
||||||
|
exec 'inoremap '. g:tcommentMapLeader1 .'s <c-o>:TCommentAs <c-r>=&ft<cr>_'
|
||||||
|
endif
|
||||||
|
if (g:tcommentMapLeader2 != '')
|
||||||
|
exec 'noremap <silent> '. g:tcommentMapLeader2 .'_ :TComment<cr>'
|
||||||
|
exec 'xnoremap <silent> '. g:tcommentMapLeader2 .'_ :TCommentMaybeInline<cr>'
|
||||||
|
exec 'noremap <silent> '. g:tcommentMapLeader2 .'p vip:TComment<cr>'
|
||||||
|
exec 'noremap '. g:tcommentMapLeader2 .'<space> :TComment '
|
||||||
|
exec 'xnoremap <silent> '. g:tcommentMapLeader2 .'i :TCommentInline<cr>'
|
||||||
|
exec 'noremap <silent> '. g:tcommentMapLeader2 .'r :TCommentRight<cr>'
|
||||||
|
exec 'xnoremap <silent> '. g:tcommentMapLeader2 .'r :TCommentRight<cr>'
|
||||||
|
exec 'noremap '. g:tcommentMapLeader2 .'b :TCommentBlock<cr>'
|
||||||
|
exec 'noremap '. g:tcommentMapLeader2 .'a :TCommentAs '
|
||||||
|
exec 'noremap '. g:tcommentMapLeader2 .'n :TCommentAs <c-r>=&ft<cr> '
|
||||||
|
exec 'noremap '. g:tcommentMapLeader2 .'s :TCommentAs <c-r>=&ft<cr>_'
|
||||||
|
endif
|
||||||
|
if (g:tcommentMapLeaderOp1 != '')
|
||||||
|
exec 'nnoremap <silent> '. g:tcommentMapLeaderOp1 .' :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#Operator<cr>g@'
|
||||||
|
exec 'nnoremap <silent> '. g:tcommentMapLeaderOp1 .'c :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLine<cr>g@$'
|
||||||
|
exec 'xnoremap <silent> '. g:tcommentMapLeaderOp1 .' :TCommentMaybeInline<cr>'
|
||||||
|
endif
|
||||||
|
if (g:tcommentMapLeaderOp2 != '')
|
||||||
|
exec 'nnoremap <silent> '. g:tcommentMapLeaderOp2 .' :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorAnyway<cr>g@'
|
||||||
|
exec 'nnoremap <silent> '. g:tcommentMapLeaderOp2 .'c :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLineAnyway<cr>g@$'
|
||||||
|
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
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user