GetLatestVimScripts

git-svn-id: https://vimsuite.svn.sourceforge.net/svnroot/vimsuite/trunk@192 eb2d0018-73a3-4aeb-bfe9-1def61c9ec69
This commit is contained in:
alterdepp 2010-10-19 07:56:33 +00:00
parent 08fed3134c
commit fa46615dad
12 changed files with 1304 additions and 178 deletions

View File

@ -7,14 +7,14 @@ ScriptID SourceID Filename
670 8073 visincr.vim (Visual Increment)
862 2635 cscope_quickfix.vim
51 171 cscope_macros.vim
102 9375 DirDiff.vim
102 13435 DirDiff.vim
1189 8687 matrix.vim
1173 11513 tcomment
1173 13972 tcomment
948 2878 Scons Compiler plugin
1709 6421 Scons Syntax file
1772 7248 DAMOS.zip DAMOS tools (von Stefan)
987 11878 DoxygenToolkit.vim
1397 11713 xml.vim
987 14064 DoxygenToolkit.vim
1397 14039 xml.vim
1290 5190 LogiPat.vim
1462 5612 dtd2xml
1046 4249 Lusty Explorer
@ -27,8 +27,8 @@ ScriptID SourceID Filename
294 10110 Align.vim
479 9276 MultipleSearch.vba
1066 7618 cecutil.vim
1173 11513 tComment.vim
2701 10950 editsrec
1173 13972 tComment.vim
2701 13194 editsrec
642 8136 :AutoInstall: getscript.vim
1075 11979 :AutoInstall: netrw.vim
1502 11981 :AutoInstall: vimball.vim

View File

@ -4,6 +4,11 @@
" License: This File is placed in the Public Domain.
" Revision | Date [DD.MM.YY] | Changes
" 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
fun libsrec#CrBC(line)
@ -141,6 +146,15 @@ fun libsrec#CrCS(line)
let s:csby = s:csby / 16
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:csby
endif
@ -150,3 +164,50 @@ fun libsrec#CrCS(line)
return s:chsu
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

View File

@ -3,13 +3,237 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-09-17.
" @Last Change: 2009-02-15.
" @Revision: 0.0.66
" @Last Change: 2010-09-29.
" @Revision: 0.0.249
if &cp || exists("loaded_tcomment_autoload")
finish
" call tlog#Log('Load: '. expand('<sfile>')) " vimtlib-sfile
" If true, comment blank lines too
if !exists("g:tcommentBlankLines")
let g:tcommentBlankLines = 1
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)
@ -24,26 +248,124 @@ let s:defaultComments = s:DefaultValue('comments')
let s:defaultCommentString = s:DefaultValue('commentstring')
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:
" G ... guess
" B ... block
" G ... guess the value of commentMode
" B ... block (use extra lines for the comment markers)
" i ... maybe inline, guess
" I ... inline
" R ... right
" 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.
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 commentAnyway = a:0 >= 2 ? (a:2 == '!') : 0
" TLogVAR a:beg, a:end, a:1, commentMode, commentAnyway
" save the cursor position
let pos = getpos('.')
let s:pos_end = getpos("'>")
if commentMode =~# 'i'
let commentMode = substitute(commentMode, '\Ci', line("'<") == line("'>") ? 'I' : 'G', 'g')
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'
let cstart = col("'<")
if cstart == 0
@ -62,54 +384,49 @@ function! tcomment#Comment(beg, end, ...)
let cstart = 0
let cend = 0
endif
" TLogVAR commentMode, 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
return [cstart, cend]
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
let commentMode = a:0 >= 1 ? a:1 : ''
let bang = a:0 >= 2 ? a:2 : ''
@ -168,10 +485,13 @@ function! tcomment#OperatorLineAnyway(type) "{{{3
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
function! tcomment#CommentAs(beg, end, commentAnyway, filetype, ...)
let ccount = a:0 >= 1 ? a:1 : 1
" TLogVAR ccount
if a:filetype =~ '_block$'
let commentMode = 'B'
let ft = substitute(a:filetype, '_block$', '', '')
@ -182,74 +502,90 @@ function! tcomment#CommentAs(beg, end, commentAnyway, filetype, ...)
let commentMode = 'G'
let ft = a:filetype
endif
let [cms, commentMode] = s:GetCommentString(a:beg, a:end, commentMode, ft)
let pre = substitute(cms, '%s.*$', '', '')
let pre = substitute(pre, '%%', '%', 'g')
let post = substitute(cms, '^.\{-}%s', '', '')
let post = substitute(post, '%%', '%', 'g')
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
let post_l = matchlist(post, '^\(\s*\)\(.\+\)$')
" TLogVAR post_l
if !empty(get(post_l, 2))
let post = post_l[1] . repeat(post_l[2], ccount)
if a:0 >= 1
if type(a:1) == 0
let cdef = {'count': a:0 >= 1 ? a:1 : 1}
else
let cdef = s:ParseArgs(a:beg, a:end, commentMode, a:000)
endif
else
let cdef = {}
endif
keepjumps call tcomment#Comment(a:beg, a:end, commentMode, a:commentAnyway, pre, post)
" echom "DBG" string(cdef)
call extend(cdef, s:GetCommentDefinitionForType(a:beg, a:end, commentMode, ft))
keepjumps call tcomment#Comment(a:beg, a:end, commentMode, a:commentAnyway, cdef)
endf
" ----------------------------------------------------------------
" collect all variables matching ^tcomment_
" collect all known comment types
function! tcomment#CollectFileTypes()
if g:tcommentFileTypesDirty
redir => vars
silent let
redir END
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
if s:typesDirty
let s:types = keys(s:definitions)
let s:typesRx = '\V\^\('. join(s:types, '\|') .'\)\(\u\.\*\)\?\$'
let s:typesDirty = 0
endif
endf
call tcomment#CollectFileTypes()
" return a list of filetypes for which a tcomment_{&ft} is defined
function! tcomment#FileTypes(ArgLead, CmdLine, CursorPos)
" TLogVAR a:ArgLead, a:CmdLine, a:CursorPos
function! tcomment#Complete(ArgLead, CmdLine, CursorPos) "{{{3
call tcomment#CollectFileTypes()
let types = copy(g:tcommentFileTypes)
if index(g:tcommentFileTypes, &filetype) != -1
let completions = copy(s:types)
if index(completions, &filetype) != -1
" TLogVAR &filetype
call insert(types, &filetype)
call insert(completions, &filetype)
endif
if empty(a:ArgLead)
return types
else
return filter(types, 'v:val =~ ''\V''.a:ArgLead')
if !empty(a:ArgLead)
call filter(completions, 'v:val =~ ''\V\^''.a:ArgLead')
endif
let completions += tcomment#CompleteArgs(a:ArgLead, a:CmdLine, a:CursorPos)
return completions
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)
return substitute(a:string, '%', '%%', 'g')
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 : ''
if ft != ''
let [cms, commentMode] = s:GetCustomCommentString(ft, a:commentMode)
let cdef = s:GetCustomCommentString(ft, a:commentMode)
else
let cms = ''
let commentMode = a:commentMode
let cdef = {'mode': a:commentMode}
endif
let cms = get(cdef, 'commentstring', '')
if empty(cms)
if exists('b:commentstring')
let cms = b:commentstring
@ -271,8 +607,9 @@ function! s:GetCommentString(beg, end, commentMode, ...)
else
return s:GetCustomCommentString(&filetype, a:commentMode, s:GuessCurrentCommentString(a:commentMode))
endif
let cdef.commentstring = cms
endif
return [cms, commentMode]
return cdef
endf
" 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)
endif
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 n = a:beg + 1
while n <= a:end
if getline(n) =~ '\S'
let jl = indent(n)
if jl < il
let it = s:GetIndentString(n, a:cstart)
let indentStr = s:GetIndentString(n, a:cstart)
let il = jl
endif
if a:commentMode =~# 'G'
@ -365,10 +702,11 @@ function! s:CommentDef(beg, end, checkRx, commentMode, cstart, cend)
let @t = t
endtry
endif
return [it, uncomment]
return [indentStr, uncomment]
endf
function! s:ProcessedLine(uncomment, match, checkRx, replace)
" TLogVAR a:uncomment, a:match, a:checkRx, a:replace
if !(a:match =~ '\S' || g:tcommentBlankLines)
return a:match
endif
@ -378,11 +716,16 @@ function! s:ProcessedLine(uncomment, match, checkRx, replace)
else
let rv = s:SPrintF(a:replace, a:match)
endif
" TLogVAR rv
" let md = len(rv) - ml
let s:pos_end = getpos('.')
let s:pos_end[2] += len(rv)
" TLogVAR pe, md, a:match
let rv = escape(rv, '\ ')
if v:version > 702 || (v:version == 702 && has('patch407'))
let rv = escape(rv, ' ')
else
let rv = escape(rv, '\ ')
endif
let rv = substitute(rv, '\n', '\\\n', 'g')
return rv
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'
endf
function! s:CommentBlock(beg, end, uncomment, checkRx, replace, indentStr)
function! s:CommentBlock(beg, end, uncomment, checkRx, cdef, indentStr)
let t = @t
try
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, '\')
if a:uncomment
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\s*$', '', '')
else
let cs = s:BlockGetCommentString(a:replace)
let cs = s:BlockGetCommentString(a:cdef)
let cs = a:indentStr . substitute(cs, '%s', '%s'. a:indentStr, '')
if ms != ''
let ms = a:indentStr . ms
@ -433,13 +776,12 @@ endf
" s:GuessFileType(beg, end, commentMode, filetype, ?fallbackFiletype)
function! s:GuessFileType(beg, end, commentMode, filetype, ...)
if a:0 >= 1 && a:1 != ''
let [cms, commentMode] = s:GetCustomCommentString(a:1, a:commentMode)
if cms == ''
let cms = s:GuessCurrentCommentString(a:commentMode)
let cdef = s:GetCustomCommentString(a:1, a:commentMode)
if empty(get(cdef, 'commentstring', ''))
let cdef.commentstring = s:GuessCurrentCommentString(a:commentMode)
endif
else
let commentMode = s:CommentMode(a:commentMode, 'G')
let cms = s:GuessCurrentCommentString(0)
let cdef = {'commentstring': s:GuessCurrentCommentString(0), 'mode': s:CommentMode(a:commentMode, 'G')}
endif
let n = a:beg
" TLogVAR n, a:beg, a:end
@ -453,14 +795,14 @@ function! s:GuessFileType(beg, end, commentMode, filetype, ...)
let ftypeMap = get(g:tcommentSyntaxMap, syntaxName)
if !empty(ftypeMap)
" TLogVAR ftypeMap
return s:GetCustomCommentString(ftypeMap, a:commentMode, cms)
elseif syntaxName =~ g:tcommentFileTypesRx
let ft = substitute(syntaxName, g:tcommentFileTypesRx, '\1', '')
return s:GetCustomCommentString(ftypeMap, a:commentMode, cdef.commentstring)
elseif syntaxName =~ s:typesRx
let ft = substitute(syntaxName, s:typesRx, '\1', '')
" TLogVAR ft
if exists('g:tcommentIgnoreTypes_'. a:filetype) && g:tcommentIgnoreTypes_{a:filetype} =~ '\<'.ft.'\>'
let m += 1
else
return s:GetCustomCommentString(ft, a:commentMode, cms)
return s:GetCustomCommentString(ft, a:commentMode, cdef.commentstring)
endif
elseif syntaxName == '' || syntaxName == 'None' || syntaxName =~ '^\u\+$' || syntaxName =~ '^\u\U*$'
let m += 1
@ -470,7 +812,7 @@ function! s:GuessFileType(beg, end, commentMode, filetype, ...)
endwh
let n += 1
endwh
return [cms, commentMode]
return cdef
endf
function! s:CommentMode(commentMode, newmode) "{{{3
@ -509,15 +851,7 @@ function! s:ConstructFromComments(commentMode)
exec s:ExtractCommentsPart('s')
if s != ''
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
" endif
endif
if line != ''
return line .' %s'
@ -542,33 +876,40 @@ endf
" s:GetCustomCommentString(ft, commentMode, ?default="")
function! s:GetCustomCommentString(ft, commentMode, ...)
let commentMode = a:commentMode
let customComment = exists('g:tcomment_'. a:ft)
if commentMode =~# 'B' && exists('g:tcomment_'. a:ft .'_block')
let cms = g:tcomment_{a:ft}_block
elseif commentMode =~? 'I' && exists('g:tcomment_'. a:ft .'_inline')
let cms = g:tcomment_{a:ft}_inline
let customComment = tcomment#TypeExists(a:ft)
if commentMode =~# 'B' && tcomment#TypeExists(a:ft .'_block')
let def = s:definitions[a:ft .'_block']
elseif commentMode =~? 'I' && tcomment#TypeExists(a:ft .'_inline')
let def = s:definitions[a:ft .'_inline']
elseif customComment
let cms = g:tcomment_{a:ft}
let def = s:definitions[a:ft]
let commentMode = s:CommentMode(commentMode, 'G')
elseif a:0 >= 1
let cms = a:1
let def = {'commentstring': a:1}
let commentMode = s:CommentMode(commentMode, 'G')
else
let cms = ''
let def = {}
let commentMode = s:CommentMode(commentMode, 'G')
endif
return [cms, commentMode]
let cdef = copy(def)
let cdef.mode = commentMode
return cdef
endf
function! s:BlockGetCommentString(cms)
" return substitute(a:cms, '\n.*$', '', '')
return matchstr(a:cms, '^.\{-}\ze\(\n\|$\)')
function! s:BlockGetCommentString(cdef)
if has_key(a:cdef, 'middle')
return a:cdef.commentstring
else
return matchstr(a:cdef.commentstring, '^.\{-}\ze\(\n\|$\)')
endif
endf
function! s:BlockGetMiddleString(cms)
" let rv = substitute(a:cms, '^.\{-}\n\([^\n]*\)', '\1', '')
let rv = matchstr(a:cms, '\n\zs.*')
return rv == a:cms ? '' : rv
function! s:BlockGetMiddleString(cdef)
if has_key(a:cdef, 'middle')
return a:cdef.middle
else
return matchstr(a:cdef.commentstring, '\n\zs.*')
endif
endf

View File

@ -4,6 +4,7 @@
" License: This File is placed in the Public Domain.
" Revision | Date [DD.MM.YY] | Changes
" 00.01.00 | 05.07.09 | 01. Revision
" 00.02.00 | 29.03.10 | Description added
*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,
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

View File

@ -33,10 +33,16 @@
:SearchBuffers MultipleSearch.txt /*:SearchBuffers*
:Sexplore pi_netrw.txt /*:Sexplore*
:TComment tComment.txt /*:TComment*
:TComment tcomment.txt /*:TComment*
:TCommentAs tComment.txt /*:TCommentAs*
:TCommentAs tcomment.txt /*:TCommentAs*
:TCommentBlock tComment.txt /*:TCommentBlock*
:TCommentBlock tcomment.txt /*:TCommentBlock*
:TCommentInline tComment.txt /*:TCommentInline*
:TCommentInline tcomment.txt /*:TCommentInline*
:TCommentMaybeInline tcomment.txt /*:TCommentMaybeInline*
:TCommentRight tComment.txt /*:TCommentRight*
:TCommentRight tcomment.txt /*:TCommentRight*
:Texplore pi_netrw.txt /*:Texplore*
:UseVimball pi_vimball.txt /*:UseVimball*
:Vexplore pi_netrw.txt /*:Vexplore*
@ -1413,6 +1419,7 @@ davs pi_netrw.txt /*davs*
drv-dtArrayInit crefvim.txt /*drv-dtArrayInit*
drv-dtIncompleteArrayDecl crefvim.txt /*drv-dtIncompleteArrayDecl*
editsrec.txt editsrec.txt /*editsrec.txt*
editsrec_test.txt editsrec.txt /*editsrec_test.txt*
ex-visincr-I visincr.txt /*ex-visincr-I*
ex-visincr-IA visincr.txt /*ex-visincr-IA*
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:tcommentMapLeader2 tComment.txt /*g:tcommentMapLeader2*
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:tcommentOpModeExtra tComment.txt /*g:tcommentOpModeExtra*
g:tcommentOpModeExtra tcomment.txt /*g:tcommentOpModeExtra*
g:vimball_home pi_vimball.txt /*g:vimball_home*
g:vimball_mkdir pi_vimball.txt /*g:vimball_mkdir*
g:visincr_datedivset visincr.txt /*g:visincr_datedivset*
@ -1762,6 +1772,19 @@ tComment-Key-Bindings tComment.txt /*tComment-Key-Bindings*
tComment-Usage tComment.txt /*tComment-Usage*
tComment-commands tComment.txt /*tComment-commands*
tComment.txt tComment.txt /*tComment.txt*
tcomment#CollectFileTypes() tcomment.txt /*tcomment#CollectFileTypes()*
tcomment#Comment() tcomment.txt /*tcomment#Comment()*
tcomment#CommentAs() tcomment.txt /*tcomment#CommentAs()*
tcomment#Complete() tcomment.txt /*tcomment#Complete()*
tcomment#CompleteArgs() tcomment.txt /*tcomment#CompleteArgs()*
tcomment#DefineType() tcomment.txt /*tcomment#DefineType()*
tcomment#Operator() tcomment.txt /*tcomment#Operator()*
tcomment#OperatorAnyway() tcomment.txt /*tcomment#OperatorAnyway()*
tcomment#OperatorLine() tcomment.txt /*tcomment#OperatorLine()*
tcomment#OperatorLineAnyway() tcomment.txt /*tcomment#OperatorLineAnyway()*
tcomment#TypeExists() tcomment.txt /*tcomment#TypeExists()*
tcomment-maps tcomment.txt /*tcomment-maps*
tcomment.txt tcomment.txt /*tcomment.txt*
v_[% matchit.txt /*v_[%*
v_]% matchit.txt /*v_]%*
v_a% matchit.txt /*v_a%*

237
vimfiles/doc/tcomment.txt Normal file
View 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:

View File

@ -64,7 +64,7 @@ let s:SpaceInfront = '^\s*<'
let s:EndofName = '\($\|\s\|>\)'
" 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:html_mode =((&filetype =~ 'x\?html') && !exists("g:xml_no_html"))
let b:haveAtt = 0
@ -607,7 +607,11 @@ fun! s:CloseTagFun()
normal! h
if s:TagUnderCursor()
if b:firstWasEndTag == 0
exe "normal! 2f>s\<Cr>\<Esc>Ox\<Esc>>>$x"
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"
en
start!
retu
en

View File

@ -2,8 +2,8 @@
" FILE: "/home/wlee/.vim/plugin/DirDiff.vim" {{{
" LAST MODIFICATION: "Mon, 20 Oct 2008 09:04:59 -0500 (wlee)"
" HEADER MAINTAINED BY: N/A
" VERSION: 1.1.2
" (C) 2001-2006 by William Lee, <wl1012@yahoo.com>
" VERSION: 1.1.3
" (C) 2001-2010 by William Lee, <wl1012@yahoo.com>
" }}}
@ -147,9 +147,12 @@
"
" Florian Delizy for the i18n diff patch
" Robert Webb for his sorting function
" Wu WeiWei for his Chinese diff patch
" Salman Halim, Yosuke Kimura, and others for their suggestions
"
" 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.1
" 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 "
endif
" String used for the English equivalent ": ")
if !exists("g:DirDiffTextOnlyInCenter")
let g:DirDiffTextOnlyInCenter = ": "
endif
" Set some script specific variables:
"
let s:DirDiffFirstDiffLine = 6
@ -778,11 +786,11 @@ endfunction
"Returns the source (A or B) of the "Only" line
function! <SID>ParseOnlySrc(line)
return substitute(a:line, '^.*' . s:DirDiffDiffOnlyLine . '\[\(.\)\].*:.*', '\1', '')
return substitute(a:line, '^.*' . s:DirDiffDiffOnlyLine . '\[\(.\)\].*' . s:DirDiffDiffOnlyLineCenter . '.*', '\1', '')
endfunction
function! <SID>ParseOnlyFile(line)
let regex = '^.*' . s:DirDiffDiffOnlyLine . '\[.\]\(.*\): \(.*\)'
let regex = '^.*' . s:DirDiffDiffOnlyLine . '\[.\]\(.*\)' . s:DirDiffDiffOnlyLineCenter . '\(.*\)'
let root = substitute(a:line, regex , '\1', '')
let file = root . s:sep . substitute(a:line, regex , '\2', '')
return file
@ -1006,6 +1014,7 @@ function! <SID>GetDiffStrings()
" what's set in the global variables
if (g:DirDiffDynamicDiffText == 0)
let s:DirDiffDiffOnlyLineCenter = g:DirDiffTextOnlyInCenter
let s:DirDiffDiffOnlyLine = g:DirDiffTextOnlyIn
let s:DirDiffDifferLine = g:DirDiffTextFiles
let s:DirDiffDifferAndLine = g:DirDiffTextAnd
@ -1032,7 +1041,9 @@ function! <SID>GetDiffStrings()
"echo "First line: " . getline(1)
"echo "tmp1: " . tmp1
"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
q
@ -1067,4 +1078,12 @@ function! <SID>GetDiffStrings()
call <SID>Delete(tmp2)
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

View File

@ -1,13 +1,46 @@
" DoxygenToolkit.vim
" Brief: Usefull tools for Doxygen (comment, author, license).
" Version: 0.2.7
" Date: 12/06/09
" Version: 0.2.13
" Date: 2010/10/16
" Author: Mathias Lorente
"
" TODO: add automatically (option controlled) in/in out flags to function
" parameters
" 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: Bug correction and improve compatibility with c/c++ IDE
@ -227,8 +260,8 @@
" Verify if already loaded
"if exists("loaded_DoxygenToolkit")
" echo 'DoxygenToolkit Already Loaded.'
" finish
" echo 'DoxygenToolkit Already Loaded.'
" finish
"endif
let loaded_DoxygenToolkit = 1
"echo 'Loading DoxygenToolkit...'
@ -252,6 +285,12 @@ endif
if !exists("g:DoxygenToolkit_briefTag_post")
let g:DoxygenToolkit_briefTag_post = ""
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")
let g:DoxygenToolkit_paramTag_pre = "@param "
endif
@ -261,6 +300,12 @@ endif
if !exists("g:DoxygenToolkit_returnTag")
let g:DoxygenToolkit_returnTag = "@return "
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")
let g:DoxygenToolkit_blockHeader = ""
endif
@ -343,7 +388,7 @@ if !exists("g:DoxygenToolkit_compactDoc")
endif
" 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")
let g:DoxygenToolkit_ignoreForReturn = s:ignoreForReturn[:]
else
@ -517,6 +562,7 @@ function! <SID>DoxygenCommentFunc()
let l:endDocPattern = ';\|{\|\%([^:]\zs:\ze\%([^:]\|$\)\)'
let l:commentPattern = '\%(/*\)\|\%(//\)\'
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:structPattern = '\<struct\>[[:blank:]]\+\zs'.l:someNameWithNamespacePattern.'\ze[^(),]*\%('.l:endDocPattern.'\)'
@ -539,7 +585,7 @@ function! <SID>DoxygenCommentFunc()
let l:count = 1
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 d
@ -566,13 +612,28 @@ function! <SID>DoxygenCommentFunc()
" Look for the end of the function/class/... to document
" 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:throwCompleted = 0
let l:endReadPattern = l:endDocPattern
while( l:endDocFound == 0 && l:count < g:DoxygenToolkit_maxFunctionProtoLines )
let l:lineBuffer = s:RemoveComments( l:lineBuffer )
" Valid only for cpp. For Python it must be 'class ...:' or 'def ...:' or
" '... EOL'.
if( match( l:lineBuffer, l:endDocPattern ) != -1 )
let l:endDocFound = 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
endif
else
let l:endDocFound = 1
endif
continue
endif
exec "normal j"
@ -585,7 +646,7 @@ function! <SID>DoxygenCommentFunc()
" Fall here when only comments have been found.
call s:WarnMsg( "Nothing to document here!" )
else
call s:WarnMsg( "Cannot reach end of function/class/... declaration!" )
call s:WarnMsg( l:readError )
endif
exec "normal `d"
return
@ -594,6 +655,8 @@ function! <SID>DoxygenCommentFunc()
" Trim the buffer
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.
if( s:CheckFileType() == "cpp" )
while( match( l:lineBuffer, l:templateParameterPattern ) != -1 )
@ -637,6 +700,9 @@ function! <SID>DoxygenCommentFunc()
else
let l:doc.type = 'function'
call s:ParseFunctionParameters( l:lineBuffer, l:doc )
if( l:throwCompleted == 1 )
call s:ParseThrowParameters( l:lineBuffer, l:doc, l:throwPattern )
endif
endif
" This is an attribute for Python
@ -673,17 +739,17 @@ function! <SID>DoxygenCommentFunc()
" Brief
if( g:DoxygenToolkit_compactOneLineDoc =~ "yes" && l:doc.returns != "yes" && len( l:doc.params ) == 0 )
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 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
let s:compactOneLineDoc = "no"
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
if( l:doc.name != "None" )
exec "normal A".l:doc.name." "
endif
exec "normal A".g:DoxygenToolkit_briefTag_post
" Mark the line where the cursor will be positionned.
mark d
@ -694,26 +760,51 @@ function! <SID>DoxygenCommentFunc()
else
let s:insertEmptyLine = 1
endif
for param in l:doc.params
for param in l:doc.templates
if( s:insertEmptyLine == 1 )
exec "normal o".s:interCommentTag
exec "normal o".substitute( s:interCommentTag, "[[:blank:]]*$", "", "" )
let s:insertEmptyLine = 0
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
" Returned value
if( l:doc.returns == "yes" )
if( g:DoxygenToolkit_compactDoc != "yes" )
exec "normal o".s:interCommentTag
exec "normal o".substitute( s:interCommentTag, "[[:blank:]]*$", "", "" )
endif
exec "normal o".s:interCommentTag.g:DoxygenToolkit_returnTag
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.
if( s:endCommentTag != "" )
if( s:compactOneLineDoc =~ "yes" )
let s:execCommand = "A "
let s:execCommand = "A"
exec "normal A "
exec "normal $md"
else
let s:execCommand = "o"
endif
@ -728,7 +819,11 @@ function! <SID>DoxygenCommentFunc()
exec "normal `d"
call s:RestoreParameters()
startinsert!
if( s:compactOneLineDoc =~ "yes" && s:endCommentTag != "" )
startinsert
else
startinsert!
endif
" DEBUG purpose only
"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 )
"exec "normal O".s:startCommentTag
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"
else
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.
if( s:CheckFileType() == "cpp" )
let l:functionBuffer = strpart( a:lineBuffer, 0, l:paramPosition )
" Remove unnecessary elements
for ignored in g:DoxygenToolkit_ignoreForReturn
let l:functionBuffer = substitute( l:functionBuffer, '\<'.ignored.'\>', '', 'g' )
endfor
@ -839,7 +935,7 @@ function! s:ParseFunctionParameters( lineBuffer, doc )
let l:parametersBuffer = strpart( a:lineBuffer, l:paramPosition + 1 )
" Remove trailing closing bracket and everything that follows and trim.
if( s:CheckFileType() == "cpp" )
let l:parametersBuffer = substitute( l:parametersBuffer, ')[^)]*\%(;\|{\|\%([^:]:\%([^:]\|$\)\)\).*', '', '' )
let l:parametersBuffer = substitute( l:parametersBuffer, ')[^)]*\%(;\|{\|\%([^:]:\%([^:]\|$\)\)\|\%(\<throw\>\)\).*', '', '' )
else
let l:parametersBuffer = substitute( l:parametersBuffer, ')[^)]*:.*', '', '' )
endif
@ -941,6 +1037,38 @@ function! s:ParseParameter( param )
return l:paramName
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.

View File

@ -4,6 +4,7 @@
" License: This File is placed in the Public Domain.
" Revision | Date [DD.MM.YY] | Changes
" 00.01.00 | 05.07.09 | 01. Revision
" 00.02.00 | 29.03.10 | Fun added, MakeSrecS5()
if exists("loaded_editsrec")
finish
@ -61,6 +62,13 @@ endif
noremap <unique> <script> <Plug>EditSrecPartCS <SID>AutoPartCS
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
"imap <F5> <Esc>:call <SID>AutoLineBC()<CR>a
"imap <F6> <Esc>:call <SID>AutoLineAD()<CR>a
@ -165,5 +173,16 @@ fun s:AutoPartCS()
unlet s:ln
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

View File

@ -4,6 +4,9 @@
" License: This File is placed in the Public Domain.
" Revision | Date [DD.MM.YY] | Changes
" 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'
" and its Library 'libsrec.vim'.
@ -335,3 +338,19 @@ type "<Esc><Leader>pc"
the following Line will be created
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

View 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