diff --git a/vimfiles/GetLatest/GetLatestVimScripts.dat b/vimfiles/GetLatest/GetLatestVimScripts.dat index 688b9c9..8840396 100644 --- a/vimfiles/GetLatest/GetLatestVimScripts.dat +++ b/vimfiles/GetLatest/GetLatestVimScripts.dat @@ -8,7 +8,7 @@ ScriptID SourceID Filename 862 2635 cscope_quickfix.vim 51 171 cscope_macros.vim 102 16171 DirDiff.vim -1189 8687 matrix.vim +1189 18650 matrix.vim 948 2878 Scons Compiler plugin 1709 6421 Scons Syntax file 1772 7248 DAMOS.zip DAMOS tools (von Stefan) @@ -23,7 +23,7 @@ ScriptID SourceID Filename 39 8196 matchit.vim 2092 8095 reloaded.vim (matrix colorscheme) 848 14668 SrchRplcHiGrp.vim (Search/Replace on Syntax Group) -294 10110 Align.vim +294 18148 Align.vim 479 9276 MultipleSearch.vba 1066 7618 cecutil.vim 1173 17289 tComment.vim @@ -32,6 +32,6 @@ ScriptID SourceID Filename 642 15781 :AutoInstall: getscript.vim 1075 15782 :AutoInstall: netrw.vim 1502 15362 :AutoInstall: vimball.vim -3304 17406 Gundo +3304 18081 Gundo 90 17031 vcscommand diff --git a/vimfiles/autoload/Align.vim b/vimfiles/autoload/Align.vim index bce3542..e393584 100644 --- a/vimfiles/autoload/Align.vim +++ b/vimfiles/autoload/Align.vim @@ -1,10 +1,10 @@ " Align: tool to align multiple fields based on one or more separators " Author: Charles E. Campbell, Jr. -" Date: Mar 03, 2009 -" Version: 35 +" Date: Jun 18, 2012 +" Version: 36 " GetLatestVimScripts: 294 1 :AutoInstall: Align.vim " GetLatestVimScripts: 1066 1 :AutoInstall: cecutil.vim -" Copyright: Copyright (C) 1999-2007 Charles E. Campbell, Jr. {{{1 +" Copyright: Copyright (C) 1999-2012 Charles E. Campbell, Jr. {{{1 " Permission is hereby granted to use and distribute this code, " with or without modifications, provided that this copyright " notice is copied with it. Like anything else that's free, @@ -18,13 +18,14 @@ " the power of God for salvation for everyone who believes; for the Jew first, " and also for the Greek. For in it is revealed God's righteousness from " faith to faith. +"redraw!|call DechoSep()|call inputsave()|call input("Press to continue")|call inputrestore() " --------------------------------------------------------------------- " Load Once: {{{1 if exists("g:loaded_Align") || &cp finish endif -let g:loaded_Align = "v35" +let g:loaded_Align = "v36" if v:version < 700 echohl WarningMsg echo "***warning*** this version of Align needs vim 7.0" @@ -84,14 +85,13 @@ endif " | s:AlignSep fun! Align#AlignCtrl(...) -" call Dfunc("AlignCtrl(...) a:0=".a:0) +" call Dfunc("Align#AlignCtrl(...) a:0=".a:0) - " save options that will be changed - let keep_search = @/ - let keep_ic = &ic + " save options that may be changed later + call s:SaveUserOptions() " turn ignorecase off - set noic + setlocal noic " clear visual mode so that old visual-mode selections don't " get applied to new invocations of Align(). @@ -121,19 +121,20 @@ fun! Align#AlignCtrl(...) let ipat= 2 while ipat <= A[0] if "" =~ A[ipat] - echoerr "AlignCtrl: separator<".A[ipat]."> matches zero-length string" - let &ic= keep_ic -" call Dret("AlignCtrl") + echoerr "(AlignCtrl) separator<".A[ipat]."> matches zero-length string" + call s:RestoreUserOptions() +" call Dret("Align#AlignCtrl") return endif let ipat= ipat + 1 endwhile endif endif +" call Decho("(AlignCtrl) passed bad-separator pattern check (no zero-length matches)") -" call Decho("AlignCtrl() A[0]=".A[0]) +" call Decho("(AlignCtrl) A[0]=".A[0]) if !exists("s:AlignStyle") - let s:AlignStyle= "l" + let s:AlignStyle= 'l' endif if !exists("s:AlignPrePad") let s:AlignPrePad= 0 @@ -153,7 +154,7 @@ fun! Align#AlignCtrl(...) let s:AlignPatQty= 0 endif echo "AlignCtrl<".s:AlignCtrl."> qty=".s:AlignPatQty." AlignStyle<".s:AlignStyle."> Padding<".s:AlignPrePad."|".s:AlignPostPad."> LeadingWS=".s:AlignLeadKeep." AlignSep=".s:AlignSep -" call Decho("AlignCtrl<".s:AlignCtrl."> qty=".s:AlignPatQty." AlignStyle<".s:AlignStyle."> Padding<".s:AlignPrePad."|".s:AlignPostPad."> LeadingWS=".s:AlignLeadKeep." AlignSep=".s:AlignSep) +" call Decho("(AlignCtrl) AlignCtrl<".s:AlignCtrl."> qty=".s:AlignPatQty." AlignStyle<".s:AlignStyle."> Padding<".s:AlignPrePad."|".s:AlignPostPad."> LeadingWS=".s:AlignLeadKeep." AlignSep=".s:AlignSep) if exists("s:AlignGPat") && !exists("s:AlignVPat") echo "AlignGPat<".s:AlignGPat.">" elseif !exists("s:AlignGPat") && exists("s:AlignVPat") @@ -164,7 +165,7 @@ fun! Align#AlignCtrl(...) let ipat= 1 while ipat <= s:AlignPatQty echo "Pat".ipat."<".s:AlignPat_{ipat}.">" -" call Decho("Pat".ipat."<".s:AlignPat_{ipat}.">") +" call Decho("(AlignCtrl) Pat".ipat."<".s:AlignPat_{ipat}.">") let ipat= ipat + 1 endwhile @@ -190,9 +191,8 @@ fun! Align#AlignCtrl(...) call Align#AlignCtrl("g") call Align#AlignCtrl("v") let s:dovisclear = 1 - let &ic = keep_ic - let @/ = keep_search -" call Dret("AlignCtrl") + call s:RestoreUserOptions() +" call Dret("Align#AlignCtrl") return endif @@ -205,7 +205,7 @@ fun! Align#AlignCtrl(...) endif " = : record a list of alignment patterns that are equivalent - if style =~# "=" + if style =~# "=" || (A[0] >= 2 && style !~# "C" && s:AlignCtrl =~# '=') " call Decho("style case =: record list of equiv alignment patterns") let s:AlignCtrl = '=' if A[0] >= 2 @@ -221,7 +221,7 @@ fun! Align#AlignCtrl(...) endif "c : cycle through alignment pattern(s) - elseif style =~# 'C' + elseif style =~# 'C' || (A[0] >= 2 && s:AlignCtrl =~# '=') " call Decho("style case C: cycle through alignment pattern(s)") let s:AlignCtrl = 'C' if A[0] >= 2 @@ -239,10 +239,9 @@ fun! Align#AlignCtrl(...) let s:AlignPrePad= substitute(style,'^.*p\(\d\+\).*$','\1','') " call Decho("style case p".s:AlignPrePad.": pre-separator padding") if s:AlignPrePad == "" - echoerr "AlignCtrl: 'p' needs to be followed by a numeric argument' - let @/ = keep_search - let &ic= keep_ic -" call Dret("AlignCtrl") + echoerr "(AlignCtrl) 'p' needs to be followed by a numeric argument'" + call s:RestoreUserOptions() +" call Dret("Align#AlignCtrl") return endif endif @@ -251,10 +250,9 @@ fun! Align#AlignCtrl(...) let s:AlignPostPad= substitute(style,'^.*P\(\d\+\).*$','\1','') " call Decho("style case P".s:AlignPostPad.": post-separator padding") if s:AlignPostPad == "" - echoerr "AlignCtrl: 'P' needs to be followed by a numeric argument' - let @/ = keep_search - let &ic= keep_ic -" call Dret("AlignCtrl") + echoerr "(AlignCtrl) 'P' needs to be followed by a numeric argument'" + call s:RestoreUserOptions() +" call Dret("Align#AlignCtrl") return endif endif @@ -263,10 +261,10 @@ fun! Align#AlignCtrl(...) " call Decho("style case w: ignore leading whitespace") let s:AlignLeadKeep= 'w' elseif style =~# 'W' -" call Decho("style case w: keep leading whitespace") +" call Decho("style case W: keep leading whitespace") let s:AlignLeadKeep= 'W' elseif style =~# 'I' -" call Decho("style case w: retain initial leading whitespace") +" call Decho("style case I: retain initial leading whitespace") let s:AlignLeadKeep= 'I' endif @@ -274,8 +272,8 @@ fun! Align#AlignCtrl(...) " first list item is a "g" selector pattern " call Decho("style case g: global selector pattern") if A[0] < 2 - if exists("s:AlignGPat") - unlet s:AlignGPat + if exists("s:AlignVPat") + unlet s:AlignVPat " call Decho("unlet s:AlignGPat") endif else @@ -286,8 +284,8 @@ fun! Align#AlignCtrl(...) " first list item is a "v" selector pattern " call Decho("style case v: global selector anti-pattern") if A[0] < 2 - if exists("s:AlignVPat") - unlet s:AlignVPat + if exists("s:AlignGPat") + unlet s:AlignGPat " call Decho("unlet s:AlignVPat") endif else @@ -297,9 +295,9 @@ fun! Align#AlignCtrl(...) endif "[-lrc+:] : set up s:AlignStyle - if style =~# '[-lrc+:]' + if style =~# '[-lrc+:*]' " call Decho("style case [-lrc+:]: field justification") - let s:AlignStyle= substitute(style,'[^-lrc:+]','','g') + let s:AlignStyle= substitute(style,'[^-lrc:+*]','','g') " call Decho("AlignStyle<".s:AlignStyle.">") endif @@ -316,11 +314,9 @@ fun! Align#AlignCtrl(...) let s:AlignCtrl= '=' endif - " restore search and options - let @/ = keep_search - let &ic= keep_ic - -" call Dret("AlignCtrl ".s:AlignCtrl.'p'.s:AlignPrePad.'P'.s:AlignPostPad.s:AlignLeadKeep.s:AlignStyle) + " restore options and return + call s:RestoreUserOptions() +" call Dret("Align#AlignCtrl ".s:AlignCtrl.'p'.s:AlignPrePad.'P'.s:AlignPostPad.s:AlignLeadKeep.s:AlignStyle) return s:AlignCtrl.'p'.s:AlignPrePad.'P'.s:AlignPostPad.s:AlignLeadKeep.s:AlignStyle endfun @@ -355,6 +351,9 @@ fun! Align#Align(hasctrl,...) range return endif + " save user options + call s:SaveUserOptions() + " set up a list akin to an argument list if a:0 > 0 let A= s:QArgSplitter(a:1) @@ -384,7 +383,8 @@ fun! Align#Align(hasctrl,...) range let ipat= 1 + hasctrl while ipat <= A[0] if "" =~ A[ipat] - echoerr "Align: separator<".A[ipat]."> matches zero-length string" + echoerr "(Align) separator<".A[ipat]."> matches zero-length string" + call s:RestoreUserOptions() " call Dret("Align#Align") return endif @@ -392,10 +392,8 @@ fun! Align#Align(hasctrl,...) range endwhile " record current search pattern for subsequent restoration - let keep_search= @/ - let keep_ic = &ic - let keep_report= &report - set noic report=10000 + " (these are all global-only options) + set noic report=10000 nohls if A[0] > hasctrl " Align will accept a list of separator regexps @@ -447,17 +445,32 @@ fun! Align#Align(hasctrl,...) range let begline = a:lastline let endline = a:firstline endif + + " Expand range to cover align-able lines when the given range is only the current line. + " Look for the first line above the current line that matches the first separator pattern, and + " look for the last line below the current line that matches the first separator pattern. + if begline == endline +" call Decho("case begline == endline") + if !exists("s:AlignPat_{1}") + echohl Error|echo "(Align) no separators specified!"|echohl None + call s:RestoreUserOptions() +" call Dret("Align#Align") + return + endif + let seppat = s:AlignPat_{1} + let begline= search('^\%(\%('.seppat.'\)\@!.\)*$',"bnW") + if begline == 0|let begline= 1|else|let begline= begline + 1|endif + let endline= search('^\%(\%('.seppat.'\)\@!.\)*$',"nW") + if endline == 0|let endline= line("$")|else|let endline= endline - 1|endif +" call Decho("begline=".begline." endline=".endline." curline#".line(".")) + endif " call Decho("begline=".begline." endline=".endline) let fieldcnt = 0 if (begline == line("'>") && endline == line("'<")) || (begline == line("'<") && endline == line("'>")) let vmode= visualmode() " call Decho("vmode=".vmode) if vmode == "\" - if exists("g:Align_xstrlen") && g:Align_xstrlen - let ragged = ( col("'>") > s:Strlen(getline("'>")) || col("'<") > s:Strlen(getline("'<")) ) - else - let ragged = ( col("'>") > strlen(getline("'>")) || col("'<") > strlen(getline("'<")) ) - endif + let ragged = ( col("'>") > s:Strlen(getline("'>")) || col("'<") > s:Strlen(getline("'<")) ) else let ragged= 1 endif @@ -469,10 +482,14 @@ fun! Align#Align(hasctrl,...) range endif " call Decho("lines[".begline.",".endline."] col[".begcol.",".endcol."] ragged=".ragged." AlignCtrl<".s:AlignCtrl.">") - " Keep user options - let etkeep = &l:et - let pastekeep= &l:paste - setlocal et paste + " record initial whitespace + if s:AlignLeadKeep == 'W' + let wskeep = map(getline(begline,endline),"substitute(v:val,'^\\(\\s*\\).\\{-}$','\\1','')") + endif + + " Align needs these options + setl et + set paste " convert selected range of lines to use spaces instead of tabs " but if first line's initial white spaces are to be retained @@ -480,11 +497,30 @@ fun! Align#Align(hasctrl,...) range if begcol <= 0 && s:AlignLeadKeep == 'I' " retain first leading whitespace for all subsequent lines let bgntxt= substitute(getline(begline),'^\(\s*\).\{-}$','\1','') + + " exception: retain first leading whitespace predicated on g and v patterns + " if such a selected line exists + if exists("s:AlignGPat") + let firstgline= search(s:AlignGPat,"cnW",endline) + if firstgline > 0 + let bgntxt= substitute(getline(firstgline),'^\(\s*\).\{-}$','\1','') + endif + elseif exists("s:AlignVPat") + let firstvline= search(s:AlignVPat,"cnW",endline) + if firstvline > 0 + let bgntxt= substitute('^\%(\%('.getline(firstvline).')\@!\)*$','^\(\s*\).\{-}$','\1','') + endif + endif " call Decho("retaining 1st leading whitespace: bgntxt<".bgntxt.">") - set noet + let &l:et= s:keep_et endif exe begline.",".endline."ret" + " record transformed to spaces leading whitespace + if s:AlignLeadKeep == 'W' + let wsblanks = map(getline(begline,endline),"substitute(v:val,'^\\(\\s*\\).\\{-}$','\\1','')") + endif + " Execute two passes " First pass: collect alignment data (max field sizes) " Second pass: perform alignment @@ -528,11 +564,7 @@ fun! Align#Align(hasctrl,...) range endif " Extract visual-block selected text (init bgntxt, endtxt) - if exists("g:Align_xstrlen") && g:Align_xstrlen let txtlen= s:Strlen(txt) - else - let txtlen= strlen(txt) - endif if begcol > 0 " Record text to left of selected area let bgntxt= strpart(txt,0,begcol) @@ -557,7 +589,8 @@ fun! Align#Align(hasctrl,...) range " call Decho("Pass".pass.": txt<". txt .">") " call Decho("Pass".pass.": endtxt<".endtxt.">") if !exists("s:AlignPat_{1}") - echohl Error|echo "no separators specified!"|echohl None + echohl Error|echo "(Align) no separators specified!"|echohl None + call s:RestoreUserOptions() " call Dret("Align#Align") return endif @@ -575,7 +608,7 @@ fun! Align#Align(hasctrl,...) range let alignpostpad= s:AlignPostPad let alignsep = s:AlignSep let alignophold = " " - let alignop = "l" + let alignop = 'l' " call Decho("Pass".pass.": initial alignstyle<".alignstyle."> seppat<".seppat.">") " Process each field on the line @@ -606,23 +639,41 @@ fun! Align#Align(hasctrl,...) range endif endif - " cylic separator alignment specification handling + " cyclic separator alignment specification handling let alignsepop= strpart(alignsep,0,1) let alignsep = strpart(alignsep,1).alignsepop + " ------------------------------------------------------ " mark end-of-field and the subsequent end-of-separator. - " Extend field if alignop is '-' + " ------------------------------------------------------ let endfield = match(txt,seppat,bgnfield) let sepfield = matchend(txt,seppat,bgnfield) let skipfield= sepfield -" call Decho("Pass".pass.": endfield=match(txt<".txt.">,seppat<".seppat.">,bgnfield=".bgnfield.")=".endfield) +" call Decho("Pass".pass.": endfield=match(txt<".txt.">,seppat<".seppat.">,bgnfield=".bgnfield.")=".endfield." alignop=".alignop) + + " Mark eof: Extend field if alignop is '*' and AlignSkip() is true. + if alignop == '*' && exists("g:AlignSkip") && type(g:AlignSkip) == 2 +" call Decho("Pass".pass.": endfield=match(txt<".txt.">,seppat<".seppat.">,bgnfield=".bgnfield.")=".endfield." alignop=".alignop) + " a '*' acts like a '-' while the g:AlignSkip function reference is true except that alignop doesn't advance + while g:AlignSkip(line,endfield) && endfield != -1 + let endfield = match(txt,seppat,skipfield) + let sepfield = matchend(txt,seppat,skipfield) + let skipfield = sepfield +" call Decho("Pass".pass.": extend field: endfield<".strpart(txt,bgnfield,endfield-bgnfield)."> alignop<".alignop."> alignstyle<".alignstyle.">") + endwhile + let alignop = strpart(alignstyle,0,1) + let alignstyle= strpart(alignstyle,1).strpart(alignstyle,0,1) +" call Decho("Pass".pass.": endfield=match(txt<".txt.">,seppat<".seppat.">,bgnfield=".bgnfield.")=".endfield." alignop=".alignop." (after *)") + endif + + " Mark eof: Extend field if alignop is '-' while alignop == '-' && endfield != -1 let endfield = match(txt,seppat,skipfield) let sepfield = matchend(txt,seppat,skipfield) let skipfield = sepfield let alignop = strpart(alignstyle,0,1) let alignstyle= strpart(alignstyle,1).strpart(alignstyle,0,1) -" call Decho("Pass".pass.": extend field: endfield<".strpart(txt,bgnfield,endfield-bgnfield)."> alignop<".alignop."> alignstyle<".alignstyle.">") +" call Decho("Pass".pass.": extend field: endfield<".strpart(txt,bgnfield,endfield-bgnfield)."> alignop<".alignop."> alignstyle<".alignstyle.">") endwhile let seplen= sepfield - endfield " call Decho("Pass".pass.": seplen=[sepfield=".sepfield."] - [endfield=".endfield."]=".seplen) @@ -637,11 +688,7 @@ fun! Align#Align(hasctrl,...) range let field = bgntxt.field let bgntxt= "" endif - if exists("g:Align_xstrlen") && g:Align_xstrlen - let fieldlen = s:Strlen(field) - else - let fieldlen = strlen(field) - endif + let fieldlen = s:Strlen(field) let sFieldSize = "FieldSize_".ifield if !exists(sFieldSize) let FieldSize_{ifield}= fieldlen @@ -675,11 +722,7 @@ fun! Align#Align(hasctrl,...) range let prepad = 0 let postpad= 0 endif - if exists("g:Align_xstrlen") && g:Align_xstrlen - let fieldlen = s:Strlen(field) - else - let fieldlen = strlen(field) - endif + let fieldlen = s:Strlen(field) let sep = s:MakeSpace(prepad).strpart(txt,endfield,sepfield-endfield).s:MakeSpace(postpad) if seplen < SepSize_{ifield} if alignsepop == "<" @@ -695,7 +738,7 @@ fun! Align#Align(hasctrl,...) range let sep = s:MakeSpace(sepleft).sep.s:MakeSpace(sepright) endif endif - let spaces = FieldSize_{ifield} - fieldlen + let spaces = FieldSize_{ifield} - fieldlen " call Decho("Pass".pass.": Field #".ifield."<".field."> spaces=".spaces." be[".bgnfield.",".endfield."] pad=".prepad.','.postpad." FS_".ifield."<".FieldSize_{ifield}."> sep<".sep."> ragged=".ragged." doend=".doend." alignop<".alignop.">") " Perform alignment according to alignment style justification @@ -746,7 +789,7 @@ fun! Align#Align(hasctrl,...) range " call Decho("Pass".pass.": bgntxt<".bgntxt."> line=".line) " call Decho("Pass".pass.": newtxt<".newtxt.">") " call Decho("Pass".pass.": endtxt<".endtxt.">") - call setline(line,bgntxt.newtxt.endtxt) + keepj call setline(line,bgntxt.newtxt.endtxt) endif let line = line + 1 @@ -756,9 +799,18 @@ fun! Align#Align(hasctrl,...) range endwhile " pass loop " call Decho("end of two pass loop") - " Restore user options - let &l:et = etkeep - let &l:paste = pastekeep + " restore original leading whitespace + if s:AlignLeadKeep == 'W' + let iline= begline + let i = 0 +" call Decho("restore original leading whitespace") + while iline <= endline +" call Decho("exe ".iline."s/^".wsblanks[i]."/".wskeep[i]."/") + exe "keepj ".iline."s/^".wsblanks[i]."/".wskeep[i]."/" + let iline= iline + 1 + let i = i + 1 + endwhile + endif if exists("s:DoAlignPop") " AlignCtrl Map support @@ -766,11 +818,8 @@ fun! Align#Align(hasctrl,...) range unlet s:DoAlignPop endif - " restore current search pattern - let @/ = keep_search - let &ic = keep_ic - let &report = keep_report - + " restore user options and return + call s:RestoreUserOptions() " call Dret("Align#Align") return endfun @@ -778,7 +827,7 @@ endfun " --------------------------------------------------------------------- " Align#AlignPush: this command/function pushes an alignment control string onto a stack {{{1 fun! Align#AlignPush() -" call Dfunc("AlignPush()") +" call Dfunc("Align#AlignPush()") " initialize the stack if !exists("s:AlignCtrlStackQty") @@ -806,7 +855,7 @@ fun! Align#AlignPush() let s:AlignVPat_{s:AlignCtrlStackQty}= "" endif -" call Dret("AlignPush") +" call Dret("Align#AlignPush") endfun " --------------------------------------------------------------------- @@ -817,13 +866,13 @@ fun! Align#AlignPop() " sanity checks if !exists("s:AlignCtrlStackQty") - echoerr "AlignPush needs to be used prior to AlignPop" + echoerr "(AlignPop) AlignPush needs to be used prior to AlignPop" " call Dret("Align#AlignPop <> : AlignPush needs to have been called first") return "" endif if s:AlignCtrlStackQty <= 0 unlet s:AlignCtrlStackQty - echoerr "AlignPush needs to be used prior to AlignPop" + echoerr "(AlignPop) AlignPush needs to be used prior to AlignPop" " call Dret("Align#AlignPop <> : AlignPop needs to have been called first") return "" endif @@ -857,15 +906,11 @@ endfun " --------------------------------------------------------------------- " Align#AlignReplaceQuotedSpaces: {{{1 -fun! Align#AlignReplaceQuotedSpaces() -" call Dfunc("AlignReplaceQuotedSpaces()") +fun! Align#AlignReplaceQuotedSpaces() +" call Dfunc("Align#AlignReplaceQuotedSpaces()") let l:line = getline(line(".")) - if exists("g:Align_xstrlen") && g:Align_xstrlen - let l:linelen = s:Strlen(l:line) - else - let l:linelen = strlen(l:line) - endif + let l:linelen = s:Strlen(l:line) let l:startingPos = 0 let l:startQuotePos = 0 let l:endQuotePos = 0 @@ -875,28 +920,28 @@ fun! Align#AlignReplaceQuotedSpaces() " "call Decho("in replace spaces. line=" . line('.')) while (1) let l:startQuotePos = match(l:line, l:quoteRe, l:startingPos) - if (l:startQuotePos < 0) -" "call Decho("No more quotes to the end of line") - break + if (l:startQuotePos < 0) +" call Decho("No more quotes to the end of line") + break endif let l:endQuotePos = match(l:line, l:quoteRe, l:startQuotePos + 1) if (l:endQuotePos < 0) -" "call Decho("Mismatched quotes") - break +" call Decho("Mismatched quotes") + break endif let l:spaceReplaceRe = '^.\{' . (l:startQuotePos + 1) . '}.\{-}\zs\s\ze.*.\{' . (linelen - l:endQuotePos) . '}$' -" "call Decho('spaceReplaceRe="' . l:spaceReplaceRe . '"') +" call Decho('spaceReplaceRe="' . l:spaceReplaceRe . '"') let l:newStr = substitute(l:line, l:spaceReplaceRe, '%', '') while (l:newStr != l:line) -" "call Decho('newstr="' . l:newStr . '"') +" call Decho('newstr="' . l:newStr . '"') let l:line = l:newStr let l:newStr = substitute(l:line, l:spaceReplaceRe, '%', '') endwhile let l:startingPos = l:endQuotePos + 1 endwhile - call setline(line('.'), l:line) + keepj call setline(line('.'), l:line) -" call Dret("AlignReplaceQuotedSpaces") +" call Dret("Align#AlignReplaceQuotedSpaces") endfun " --------------------------------------------------------------------- @@ -923,19 +968,20 @@ fun! s:QArgSplitter(qarg) while args != "" let iarg = 0 let arglen = strlen(args) -" call Decho("args[".iarg."]<".args[iarg]."> arglen=".arglen) +" call Decho(".args[".iarg."]<".args[iarg]."> arglen=".arglen) " find index to first not-escaped '"' +" call Decho("find index to first not-escaped \"") while args[iarg] != '"' && iarg < arglen if args[iarg] == '\' let args= strpart(args,1) endif let iarg= iarg + 1 endwhile -" call Decho("args<".args."> iarg=".iarg." arglen=".arglen) +" call Decho(".args<".args."> iarg=".iarg." arglen=".arglen) if iarg > 0 " handle left of quote or remaining section -" call Decho("handle left of quote or remaining section") +" call Decho(".handle left of quote or remaining section") if args[iarg] == '"' let qarglist= qarglist + split(strpart(args,0,iarg-1)) else @@ -946,7 +992,7 @@ fun! s:QArgSplitter(qarg) elseif iarg < arglen && args[0] == '"' " handle "quoted" section -" call Decho("handle quoted section") +" call Decho(".handle quoted section") let iarg= 1 while args[iarg] != '"' && iarg < arglen if args[iarg] == '\' @@ -954,7 +1000,7 @@ fun! s:QArgSplitter(qarg) endif let iarg= iarg + 1 endwhile -" call Decho("args<".args."> iarg=".iarg." arglen=".arglen) +" call Decho(".args<".args."> iarg=".iarg." arglen=".arglen) if args[iarg] == '"' call add(qarglist,strpart(args,1,iarg-1)) let args= strpart(args,iarg+1) @@ -963,12 +1009,14 @@ fun! s:QArgSplitter(qarg) let args = "" endif endif -" call Decho("qarglist".string(qarglist)." iarg=".iarg." args<".args.">") +" call Decho(".qarglist".string(qarglist)." iarg=".iarg." args<".args.">") endwhile +" call Decho("end of loop (handling quoted arguments)") else " split at all whitespace - let qarglist= split(a:qarg) +" call Decho("split at all whitespace") + let qarglist= split(a:qarg,"[ \t]") endif let qarglistlen= len(qarglist) @@ -984,21 +1032,26 @@ endfun " nonzero value. Solution from Nicolai Weibull, vim docs " (:help strlen()), Tony Mechelynck, and my own invention. fun! s:Strlen(x) -" call Dfunc("s:Strlen(x<".a:x.">") - if g:Align_xstrlen == 1 +" call Dfunc("s:Strlen(x<".a:x."> g:Align_xstrlen=".g:Align_xstrlen) + + if type(g:Align_xstrlen) == 1 + " allow user to specify a function to compute the string length + exe "let ret= ".g:Align_xstrlen."('".substitute(a:x,"'","''","g")."')" + + elseif g:Align_xstrlen == 1 " number of codepoints (Latin a + combining circumflex is two codepoints) " (comment from TM, solution from NW) let ret= strlen(substitute(a:x,'.','c','g')) elseif g:Align_xstrlen == 2 - " number of spacing codepoints (Latin a + combining circumflex is one spacing + " number of spacing codepoints (Latin a + combining circumflex is one spacing " codepoint; a hard tab is one; wide and narrow CJK are one each; etc.) " (comment from TM, solution from TM) - let ret=strlen(substitute(a:x, '.\Z', 'x', 'g')) + let ret=strlen(substitute(a:x, '.\Z', 'x', 'g')) elseif g:Align_xstrlen == 3 - " virtual length (counting, for instance, tabs as anything between 1 and - " 'tabstop', wide CJK as 2 rather than 1, Arabic alif as zero when immediately + " virtual length (counting, for instance, tabs as anything between 1 and + " 'tabstop', wide CJK as 2 rather than 1, Arabic alif as zero when immediately " preceded by lam, one otherwise, etc.) " (comment from TM, solution from me) let modkeep= &l:mod @@ -1010,12 +1063,58 @@ fun! s:Strlen(x) else " at least give a decent default - ret= strlen(a:x) + if v:version >= 703 + let ret= strdisplaywidth(a:x) + else + let ret= strlen(a:x) + endif endif " call Dret("s:Strlen ".ret) return ret endfun +" --------------------------------------------------------------------- +" s:SaveUserOptions: {{{1 +fun! s:SaveUserOptions() +" call Dfunc("s:SaveUserOptions() s:saved_user_options=".(exists("s:saved_user_options")? s:saved_user_options : 'n/a')) + if !exists("s:saved_user_options") + let s:saved_user_options = 1 + let s:keep_search = @/ + let s:keep_et = &l:et + let s:keep_hls = &hls + let s:keep_ic = &ic + let s:keep_paste = &paste + let s:keep_report = &report + else + let s:saved_user_options = s:saved_user_options + 1 + endif +" call Dret("s:SaveUserOptions : s:saved_user_options=".s:saved_user_options) +endfun + +" --------------------------------------------------------------------- +" s:RestoreUserOptions: {{{1 +fun! s:RestoreUserOptions() +" call Dfunc("s:RestoreUserOptions() s:saved_user_options=".(exists("s:saved_user_options")? s:saved_user_options : 'n/a')) + if exists("s:saved_user_options") && s:saved_user_options == 1 + let @/ = s:keep_search + let &l:et = s:keep_et + let &hls = s:keep_hls + let &ic = s:keep_ic + let &paste = s:keep_paste + let &report = s:keep_report + unlet s:keep_search + unlet s:keep_et + unlet s:keep_hls + unlet s:keep_ic + unlet s:keep_paste + unlet s:keep_report + unlet s:saved_user_options + elseif exists("s:saved_user_options") + let s:saved_user_options= s:saved_user_options - 1 + endif +" call Dret("s:RestoreUserOptions : s:saved_user_options=".(exists("s:saved_user_options")? s:saved_user_options : 'n/a')) +endfun + " --------------------------------------------------------------------- " Set up default values: {{{1 "call Decho("-- Begin AlignCtrl Initialization --") diff --git a/vimfiles/autoload/AlignMaps.vim b/vimfiles/autoload/AlignMaps.vim index ace2de8..9b0f3bc 100644 --- a/vimfiles/autoload/AlignMaps.vim +++ b/vimfiles/autoload/AlignMaps.vim @@ -1,15 +1,25 @@ " AlignMaps.vim : support functions for AlignMaps " Author: Charles E. Campbell, Jr. -" Date: Mar 03, 2009 -" Version: 41 +" Date: Jun 18, 2012 +" Version: 42 +" Copyright: Copyright (C) 1999-2012 Charles E. Campbell, Jr. {{{1 +" Permission is hereby granted to use and distribute this code, +" with or without modifications, provided that this copyright +" notice is copied with it. Like anything else that's free, +" Align.vim is provided *as is* and comes with no warranty +" of any kind, either expressed or implied. By using this +" plugin, you agree that in no event will the copyright +" holder be liable for any damages resulting from the use +"redraw!|call DechoSep()|call inputsave()|call input("Press to continue")|call inputrestore() " --------------------------------------------------------------------- " Load Once: {{{1 if &cp || exists("g:loaded_AlignMaps") finish endif -let g:loaded_AlignMaps= "v41" +let g:loaded_AlignMaps= "v42" let s:keepcpo = &cpo set cpo&vim +"DechoTabOn " ===================================================================== " Functions: {{{1 @@ -20,7 +30,7 @@ fun! AlignMaps#WrapperStart(vis) range " call Dfunc("AlignMaps#WrapperStart(vis=".a:vis.")") if a:vis - norm! ' + keepj norm! ' endif if line("'y") == 0 || line("'z") == 0 || !exists("s:alignmaps_wrapcnt") || s:alignmaps_wrapcnt <= 0 @@ -34,22 +44,22 @@ fun! AlignMaps#WrapperStart(vis) range let s:alignmaps_posn = SaveWinPosn(0) " set up fencepost blank lines put ='' - norm! mz'a + keepj norm! mz'a put! ='' ky let s:alignmaps_zline = line("'z") - exe "'y,'zs/@/\177/ge" + exe "keepj 'y,'zs/@/\177/ge" else " call Decho("embedded wrapper") let s:alignmaps_wrapcnt = s:alignmaps_wrapcnt + 1 - norm! 'yjma'zk + keepj norm! 'yjma'zk endif " change some settings to align-standard values set nogd set ch=2 AlignPush - norm! 'zk + keepj norm! 'zk " call Dret("AlignMaps#WrapperStart : alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z")) endfun @@ -59,7 +69,7 @@ fun! AlignMaps#WrapperEnd() range " call Dfunc("AlignMaps#WrapperEnd() alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z")) " remove trailing white space introduced by whatever in the modification zone - 'y,'zs/ \+$//e + keepj 'y,'zs/ \+$//e " restore AlignCtrl settings AlignPop @@ -67,14 +77,14 @@ fun! AlignMaps#WrapperEnd() range let s:alignmaps_wrapcnt= s:alignmaps_wrapcnt - 1 if s:alignmaps_wrapcnt <= 0 " initial wrapper ending - exe "'y,'zs/\177/@/ge" + exe "keepj 'y,'zs/\177/@/ge" " if the 'z line hasn't moved, then go ahead and restore window position let zstationary= s:alignmaps_zline == line("'z") " remove fencepost blank lines. " restore 'a - norm! 'yjmakdd'zdd + keepj norm! 'yjmakdd'zdd " restore original 'y, 'z, and window positioning call RestoreMark(s:alignmaps_keepmy) @@ -135,10 +145,10 @@ fun! AlignMaps#CharJoiner(chr) let aline = line("'a") let rep = line(".") - aline while rep > 0 - norm! 'a + keepj norm! 'a while match(getline(aline),a:chr . "\s*$") != -1 && rep >= 0 " while = at end-of-line, delete it and join with next - norm! 'a$ + keepj norm! 'a$ j! let rep = rep - 1 endwhile @@ -149,7 +159,7 @@ fun! AlignMaps#CharJoiner(chr) break endif " prepare for next line - norm! jma + keepj norm! jma let aline = line("'a") endwhile " call Dret("AlignMaps#CharJoiner") @@ -159,31 +169,32 @@ endfun " AlignMaps#Equals: supports \t= and \T= {{{2 fun! AlignMaps#Equals() range " call Dfunc("AlignMaps#Equals()") - 'a,'zs/\s\+\([*/+\-%|&\~^]\==\)/ \1/e - 'a,'zs@ \+\([*/+\-%|&\~^]\)=@\1=@ge - 'a,'zs/==/\="\\"/ge - 'a,'zs/\([!<>:]\)=/\=submatch(1)."\"/ge - norm g'zk + keepj 'a,'zs/\s\+\([*/+\-%|&\~^]\==\)/ \1/e + keepj 'a,'zs@ \+\([*/+\-%|&\~^]\)=@\1=@ge + keepj 'a,'zs/==/\="\\"/ge + keepj 'a,'zs/\([!<>:]\)=/\=submatch(1)."\"/ge + keepj norm g'zk AlignCtrl mIp1P1=l = AlignCtrl g = - 'a,'z-1Align - 'a,'z-1s@\([*/+\-%|&\~^!=]\)\( \+\)=@\2\1=@ge - 'a,'z-1s/\( \+\);/;\1/ge + keepj 'a,'z-1Align + keepj 'a,'z-1s@\([*/%|&\~^!=]\)\( \+\)=@\2\1=@ge + keepj 'a,'z-1s@[^+\-]\zs\([+\-]\)\( \+\)=@\2\1=@ge + keepj 'a,'z-1s/\( \+\);/;\1/ge if &ft == "c" || &ft == "cpp" " call Decho("exception for ".&ft) - 'a,'z-1v/^\s*\/[*/]/s/\/[*/]/@&@/e - 'a,'z-1v/^\s*\/[*/]/s/\*\//@&/e + keepj 'a,'z-1v/^\s*\/[*/]/s/\/[*/]/@&@/e + keepj 'a,'z-1v/^\s*\/[*/]/s/\*\//@&/e if exists("g:mapleader") - exe "norm 'zk" + exe "keepj norm 'zk" call AlignMaps#StdAlign(1) else - exe "norm 'zk" + exe "keepj norm 'zk" call AlignMaps#StdAlign(1) endif - 'y,'zs/^\(\s*\) @/\1/e + keepj 'y,'zs/^\(\s*\) @/\1/e endif - 'a,'z-1s/\%x0f/=/ge - 'y,'zs/ @//eg + keepj 'a,'z-1s/\%x0f/=/ge + keepj 'y,'zs/ @//eg " call Dret("AlignMaps#Equals") endfun @@ -194,10 +205,11 @@ fun! AlignMaps#Afnc() " call Dfunc("AlignMaps#Afnc()") " keep display quiet - let chkeep = &ch - let gdkeep = &gd - let vekeep = &ve - set ch=2 nogd ve= + let chkeep = &l:ch + let gdkeep = &l:gd + let wwkeep = &l:ww + let vekeep = &l:ve + setlocal ch=2 nogd ve= ww=b,s,<,>,[,] " will use marks y,z ; save current values let mykeep = SaveMark("'y") @@ -206,7 +218,7 @@ fun! AlignMaps#Afnc() " Find beginning of function -- be careful to skip over comments let cmmntid = synIDtrans(hlID("Comment")) let stringid = synIDtrans(hlID("String")) - exe "norm! ]]" + exe "keepj norm! ]]" while search(")","bW") != 0 " call Decho("line=".line(".")." col=".col(".")) let parenid= synIDtrans(synID(line("."),col("."),1)) @@ -214,23 +226,23 @@ fun! AlignMaps#Afnc() break endif endwhile - norm! %my - s/(\s*\(\S\)/(\r \1/e - exe "norm! `y%" - s/)\s*\(\/[*/]\)/)\r\1/e - exe "norm! `y%mz" - 'y,'zs/\s\+$//e - 'y,'zs/^\s\+//e - 'y+1,'zs/^/ / + keepj norm! %my + keepj s/(\s*\(\S\)/(\r \1/e + exe "keepj norm! `y%" + keepj s/)\s*\(\/[*/]\)/)\r\1/e + exe "keepj norm! `y%mz" + keepj 'y,'zs/\s\+$//e + keepj 'y,'zs/^\s\+//e + keepj 'y+1,'zs/^/ / " insert newline after every comma only one parenthesis deep - sil! exe "norm! `y\h" + exe "sil! keepj norm! `y\h" let parens = 1 let cmmnt = 0 let cmmntline= -1 while parens >= 1 -" call Decho("parens=".parens." @a=".@a) - exe 'norm! ma "ay`a ' + exe 'keepj norm! ma "ay`a ' +" call Decho("parens=".parens." cmmnt=".cmmnt." cmmntline=".cmmntline." line(.)=".line(".")." @a<".@a."> line<".getline(".").">") if @a == "(" let parens= parens + 1 elseif @a == ")" @@ -261,41 +273,42 @@ fun! AlignMaps#Afnc() endif elseif @a == "," && parens == 1 && cmmnt == 0 - exe "norm! i\\" + exe "keepj norm! i\\" endif endwhile - norm! `y%mz% - sil! 'y,'zg/^\s*$/d + sil! keepj norm! `y%mz% + sil! keepj 'y,'zg/^\s*$/d " perform substitutes to mark fields for Align - sil! 'y+1,'zv/^\//s/^\s\+\(\S\)/ \1/e - sil! 'y+1,'zv/^\//s/\(\S\)\s\+/\1 /eg - sil! 'y+1,'zv/^\//s/\* \+/*/ge - sil! 'y+1,'zv/^\//s/\w\zs\s*\*/ */ge + sil! keepj 'y+1,'zv/^\//s/^\s\+\(\S\)/ \1/e + sil! keepj 'y+1,'zv/^\//s/\(\S\)\s\+/\1 /eg + sil! keepj 'y+1,'zv/^\//s/\* \+/*/ge + sil! keepj 'y+1,'zv/^\//s/\w\zs\s*\*/ */ge " func " ws <- declaration -> <-ptr -> <-var-> <-[array][] -> <-glop-> <-end-> - sil! 'y+1,'zv/^\//s/^\s*\(\(\K\k*\s*\)\+\)\s\+\([(*]*\)\s*\(\K\k*\)\s*\(\(\[.\{-}]\)*\)\s*\(.\{-}\)\=\s*\([,)]\)\s*$/ \1@#\3@\4\5@\7\8/e - sil! 'y+1,'z+1g/^\s*\/[*/]/norm! kJ - sil! 'y+1,'z+1s%/[*/]%@&@%ge - sil! 'y+1,'z+1s%*/%@&%ge + sil! keepj 'y+1,'zv/^\//s/^\s*\(\(\K\k*\s*\)\+\)\s\+\([(*]*\)\s*\(\K\k*\)\s*\(\(\[.\{-}]\)*\)\s*\(.\{-}\)\=\s*\([,)]\)\s*$/ \1@#\3@\4\5@\7\8/e + sil! keepj 'y+1,'z+1g/^\s*\/[*/]/norm! kJ + sil! keepj 'y+1,'z+1s%/[*/]%@&@%ge + sil! keepj 'y+1,'z+1s%*/%@&%ge AlignCtrl mIp0P0=l @ - sil! 'y+1,'zAlign - sil! 'y,'zs%@\(/[*/]\)@%\t\1 %e - sil! 'y,'zs%@\*/% */%e - sil! 'y,'zs/@\([,)]\)/\1/ - sil! 'y,'zs/@/ / + sil! keepj 'y+1,'zAlign + sil! keepj 'y,'zs%@\(/[*/]\)@%\t\1 %e + sil! keepj 'y,'zs%@\*/% */%e + sil! keepj 'y,'zs/@\([,)]\)/\1/ + sil! keepj 'y,'zs/@/ / AlignCtrl mIlrp0P0= # @ - sil! 'y+1,'zAlign - sil! 'y+1,'zs/#/ / - sil! 'y+1,'zs/@// - sil! 'y+1,'zs/\(\s\+\)\([,)]\)/\2\1/e + sil! keepj 'y+1,'zAlign + sil! keepj 'y+1,'zs/#/ / + sil! keepj 'y+1,'zs/@// + sil! keepj 'y+1,'zs/\(\s\+\)\([,)]\)/\2\1/e " Restore call RestoreMark(mykeep) call RestoreMark(mzkeep) - let &ch= chkeep - let &gd= gdkeep - let &ve= vekeep + let &l:ch= chkeep + let &l:gd= gdkeep + let &l:ww= wwkeep + let &l:ve= vekeep " call Dret("AlignMaps#Afnc") endfun @@ -310,12 +323,42 @@ fun! AlignMaps#FixMultiDec() let curline = getline(".") " call Decho("curline<".curline.">") +" " Attempt to ignore function calls (ie. double x=pow(2.,3.),... +" let leader= substitute(curline,'^\s*\([a-zA-Z_ \t][a-zA-Z0-9<>_ \t]*\)\s\+.*$','\1','') +" let i = strlen(leader) +" let paren = 0 +" let fmd = strpart(curline,i) +" let ifmd = i +" call Decho("fmd<".fmd."> ifmd=".ifmd) +" while i < strlen(curline) +" if strpart(curline,i,1) == '(' +" let paren= paren+1 +" elseif strpart(curline,i,1) == ')' && paren > 0 +" let paren= paren-1 +" elseif strpart(curline,i,1) == '=' +" let eq= 1 +" elseif strpart(curline,i,1) == ';' +" let paren = 0 +" let eq = 0 +" let fmd = fmd.strpart(fmd,ifmd,i-ifmd).";\" +" let ifmd = i + 2 +" let i = i + 1 +" let leader= substitute(curline,'^\s*\([a-zA-Z_ \t][a-zA-Z0-9<>_ \t]*\)\s\+.*$','\1','') +" elseif strpart(curline,i,1) == ',' +" if paren == 0 +" let fmd = fmd.strpart(fmd,ifmd,i-ifmd).";\" +" let ifmd = i + 2 +" let i = i + 1 +" endif +" endif +" let i= i + 1 +" endwhile " Get the type. I'm assuming one type per line (ie. int x; double y; on one line will not be handled properly) - let @x=substitute(curline,'^\(\s*[a-zA-Z_ \t][a-zA-Z0-9_ \t]*\)\s\+[(*]*\h.*$','\1','') + let @x=substitute(curline,'^\(\s*[a-zA-Z_ \t][a-zA-Z0-9<>_ \t]*\)\s\+[(*]*\h.*$','\1','') " call Decho("@x<".@x.">") " transform line - exe 's/,/;\r'.@x.' /ge' + exe 'keepj s/,/;\r'.@x.' /ge' "restore register x let @x= xkeep @@ -323,6 +366,26 @@ fun! AlignMaps#FixMultiDec() " call Dret("AlignMaps#FixMultiDec : my=".line("'y")." mz=".line("'z")) endfun +" --------------------------------------------------------------------- +" AlignMaps#AlignMapsClean: this function removes the AlignMaps plugin {{{2 +fun! AlignMaps#AlignMapsClean() +" call Dfunc("AlignMaps#AlignMapsClean()") + for home in split(&rtp,',') + [''] +" call Decho("considering home<".home.">") + if isdirectory(home) + if filereadable(home."/autoload/AlignMaps.vim") +" call Decho("deleting ".home."/autoload/AlignMaps.vim") + call delete(home."/autoload/AlignMaps.vim") + endif + if filereadable(home."/plugin/AlignMapsPlugin.vim") +" call Decho("deleting ".home."/plugin/AlignMapsPlugin.vim") + call delete(home."/plugin/AlignMapsPlugin.vim") + endif + endif + endfor +" call Dret("AlignMaps#AlignMapsClean") +endfun + " --------------------------------------------------------------------- " Restore: {{{1 let &cpo= s:keepcpo diff --git a/vimfiles/autoload/gundo.vim b/vimfiles/autoload/gundo.vim index c0033a6..9a9e5f9 100644 --- a/vimfiles/autoload/gundo.vim +++ b/vimfiles/autoload/gundo.vim @@ -46,6 +46,9 @@ endif"}}} if !exists("g:gundo_prefer_python3")"{{{ let g:gundo_prefer_python3 = 0 endif"}}} +if !exists("g:gundo_auto_preview")"{{{ + let g:gundo_auto_preview = 1 +endif"}}} let s:has_supported_python = 0 if g:gundo_prefer_python3 && has('python3')"{{{ @@ -111,6 +114,7 @@ function! s:GundoMapGraph()"{{{ nnoremap