diff --git a/vimfiles/GetLatest/GetLatestVimScripts.dat b/vimfiles/GetLatest/GetLatestVimScripts.dat index 0cd0567..8e35967 100644 --- a/vimfiles/GetLatest/GetLatestVimScripts.dat +++ b/vimfiles/GetLatest/GetLatestVimScripts.dat @@ -1,12 +1,12 @@ ScriptID SourceID Filename -------------------------- -1075 8042 netrw.vim +1075 8351 netrw.vim 1502 7078 vimball.vim 1008 3118 srec.vim (ftplugin) 1009 3119 srec.vim (syntax file) 475 2535 latex-suite (install in vimfiles.latex) 614 3666 C-Referenz -670 6208 visincr.vim (Visual Increment) +670 8073 visincr.vim (Visual Increment) 862 2635 cscope_quickfix.vim 51 171 cscope_macros.vim 102 5306 DirDiff.vim @@ -18,13 +18,15 @@ ScriptID SourceID Filename 987 6978 DoxygenToolkit.vim 1397 6887 xml.vim 1290 5190 LogiPat.vim -1881 7505 svndiff +1881 8355 svndiff 1462 5612 dtd2xml 1046 4249 Lusty Explorer 2043 7805 VimPdb (debugging python) 1776 7902 Vimgrep Replace 2048 7817 BlockDiff -39 7637 matchit.vim -2092 8041 reloaded.vim (matrix colorscheme) -642 7080 getscript.vim -642 7080 :AutoInstall: GetLatestVimScripts.vim +39 8196 matchit.vim +2092 8095 reloaded.vim (matrix colorscheme) +848 8203 SrchRplcHiGrp.vim (Search/Replace on Syntax Group) +294 8407 Align.vim +642 8136 getscript.vim +642 8136 :AutoInstall: GetLatestVimScripts.vim diff --git a/vimfiles/autoload/Align.vim b/vimfiles/autoload/Align.vim new file mode 100644 index 0000000..66751bd --- /dev/null +++ b/vimfiles/autoload/Align.vim @@ -0,0 +1,1007 @@ +" Align: tool to align multiple fields based on one or more separators +" Author: Charles E. Campbell, Jr. +" Date: Mar 06, 2008 +" Version: 33 +" GetLatestVimScripts: 294 1 :AutoInstall: Align.vim +" GetLatestVimScripts: 1066 1 :AutoInstall: cecutil.vim +" Copyright: Copyright (C) 1999-2007 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 +" of this software. +" +" Romans 1:16,17a : For I am not ashamed of the gospel of Christ, for it is {{{1 +" 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. + +" --------------------------------------------------------------------- +" Load Once: {{{1 +if exists("g:loaded_align") || &cp + finish +endif +let g:loaded_align = "v33" +let s:keepcpo = &cpo +set cpo&vim +"DechoTabOn + +" --------------------------------------------------------------------- +" Debugging Support: +"if !exists("g:loaded_Decho") "Decho +" runtime plugin/Decho.vim +"endif " Decho + +" --------------------------------------------------------------------- +" AlignCtrl: enter alignment patterns here {{{1 +" +" Styles = all alignment-break patterns are equivalent +" C cycle through alignment-break pattern(s) +" l left-justified alignment +" r right-justified alignment +" c center alignment +" - skip separator, treat as part of field +" : treat rest of line as field +" + repeat previous [lrc] style +" < left justify separators +" > right justify separators +" | center separators +" +" Builds = s:AlignPat s:AlignCtrl s:AlignPatQty +" C s:AlignPat s:AlignCtrl s:AlignPatQty +" p s:AlignPrePad +" P s:AlignPostPad +" w s:AlignLeadKeep +" W s:AlignLeadKeep +" I s:AlignLeadKeep +" l s:AlignStyle +" r s:AlignStyle +" - s:AlignStyle +" + s:AlignStyle +" : s:AlignStyle +" c s:AlignStyle +" g s:AlignGPat +" v s:AlignVPat +" < s:AlignSep +" > s:AlignSep +" | s:AlignSep +fun! Align#AlignCtrl(...) + +" call Dfunc("AlignCtrl(...) a:0=".a:0) + + " save options that will be changed + let keep_search = @/ + let keep_ic = &ic + + " turn ignorecase off + set noic + + " clear visual mode so that old visual-mode selections don't + " get applied to new invocations of Align(). + if v:version < 602 + if !exists("s:Align_gavemsg") + let s:Align_gavemsg= 1 + echomsg "Align needs at least Vim version 6.2 to clear visual-mode selection" + endif + elseif exists("s:dovisclear") +" call Decho("clearing visual mode a:0=".a:0." a:1<".a:1.">") + let clearvmode= visualmode(1) + endif + + " set up a list akin to an argument list + if a:0 > 0 + let A= s:QArgSplitter(a:1) + else + let A=[0] + endif + + if A[0] > 0 + let style = A[1] + + " Check for bad separator patterns (zero-length matches) + " (but zero-length patterns for g/v is ok) + if style !~# '[gv]' + 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") + return + endif + let ipat= ipat + 1 + endwhile + endif + endif + +" call Decho("AlignCtrl() A[0]=".A[0]) + if !exists("s:AlignStyle") + let s:AlignStyle= "l" + endif + if !exists("s:AlignPrePad") + let s:AlignPrePad= 0 + endif + if !exists("s:AlignPostPad") + let s:AlignPostPad= 0 + endif + if !exists("s:AlignLeadKeep") + let s:AlignLeadKeep= 'w' + endif + + if A[0] == 0 + " ---------------------- + " List current selection + " ---------------------- + 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) + if exists("s:AlignGPat") && !exists("s:AlignVPat") + echo "AlignGPat<".s:AlignGPat.">" + elseif !exists("s:AlignGPat") && exists("s:AlignVPat") + echo "AlignVPat<".s:AlignVPat.">" + elseif exists("s:AlignGPat") && exists("s:AlignVPat") + echo "AlignGPat<".s:AlignGPat."> AlignVPat<".s:AlignVPat.">" + endif + let ipat= 1 + while ipat <= s:AlignPatQty + echo "Pat".ipat."<".s:AlignPat_{ipat}.">" +" call Decho("Pat".ipat."<".s:AlignPat_{ipat}.">") + let ipat= ipat + 1 + endwhile + + else + " ---------------------------------- + " Process alignment control settings + " ---------------------------------- +" call Decho("process the alignctrl settings") +" call Decho("style<".style.">") + + if style ==? "default" + " Default: preserve initial leading whitespace, left-justified, + " alignment on '=', one space padding on both sides + if exists("s:AlignCtrlStackQty") + " clear AlignCtrl stack + while s:AlignCtrlStackQty > 0 + call Align#AlignPop() + endwhile + unlet s:AlignCtrlStackQty + endif + " Set AlignCtrl to its default value + call Align#AlignCtrl("Ilp1P1=<",'=') + call Align#AlignCtrl("g") + call Align#AlignCtrl("v") + let s:dovisclear = 1 + let &ic = keep_ic + let @/ = keep_search +" call Dret("AlignCtrl") + return + endif + + if style =~# 'm' + " map support: Do an AlignPush now and the next call to Align() + " will do an AlignPop at exit +" call Decho("style case m: do AlignPush") + call Align#AlignPush() + let s:DoAlignPop= 1 + endif + + " = : record a list of alignment patterns that are equivalent + if style =~# "=" +" call Decho("style case =: record list of equiv alignment patterns") + let s:AlignCtrl = '=' + if A[0] >= 2 + let s:AlignPatQty= 1 + let s:AlignPat_1 = A[2] + let ipat = 3 + while ipat <= A[0] + let s:AlignPat_1 = s:AlignPat_1.'\|'.A[ipat] + let ipat = ipat + 1 + endwhile + let s:AlignPat_1= '\('.s:AlignPat_1.'\)' +" call Decho("AlignCtrl<".s:AlignCtrl."> AlignPat<".s:AlignPat_1.">") + endif + + "c : cycle through alignment pattern(s) + elseif style =~# 'C' +" call Decho("style case C: cycle through alignment pattern(s)") + let s:AlignCtrl = 'C' + if A[0] >= 2 + let s:AlignPatQty= A[0] - 1 + let ipat = 1 + while ipat < A[0] + let s:AlignPat_{ipat}= A[ipat+1] +" call Decho("AlignCtrl<".s:AlignCtrl."> AlignQty=".s:AlignPatQty." AlignPat_".ipat."<".s:AlignPat_{ipat}.">") + let ipat= ipat + 1 + endwhile + endif + endif + + if style =~# 'p' + 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") + return + endif + endif + + if style =~# 'P' + 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") + return + endif + endif + + if style =~# 'w' +" call Decho("style case w: ignore leading whitespace") + let s:AlignLeadKeep= 'w' + elseif style =~# 'W' +" call Decho("style case w: keep leading whitespace") + let s:AlignLeadKeep= 'W' + elseif style =~# 'I' +" call Decho("style case w: retain initial leading whitespace") + let s:AlignLeadKeep= 'I' + endif + + if style =~# 'g' + " 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 +" call Decho("unlet s:AlignGPat") + endif + else + let s:AlignGPat= A[2] +" call Decho("s:AlignGPat<".s:AlignGPat.">") + endif + elseif style =~# 'v' + " 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 +" call Decho("unlet s:AlignVPat") + endif + else + let s:AlignVPat= A[2] +" call Decho("s:AlignVPat<".s:AlignVPat.">") + endif + endif + + "[-lrc+:] : set up s:AlignStyle + if style =~# '[-lrc+:]' +" call Decho("style case [-lrc+:]: field justification") + let s:AlignStyle= substitute(style,'[^-lrc:+]','','g') +" call Decho("AlignStyle<".s:AlignStyle.">") + endif + + "[<>|] : set up s:AlignSep + if style =~# '[<>|]' +" call Decho("style case [-lrc+:]: separator justification") + let s:AlignSep= substitute(style,'[^<>|]','','g') +" call Decho("AlignSep ".s:AlignSep) + endif + endif + + " sanity + if !exists("s: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) + return s:AlignCtrl.'p'.s:AlignPrePad.'P'.s:AlignPostPad.s:AlignLeadKeep.s:AlignStyle +endfun + +" --------------------------------------------------------------------- +" MakeSpace: returns a string with spacecnt blanks {{{1 +fun! s:MakeSpace(spacecnt) +" call Dfunc("MakeSpace(spacecnt=".a:spacecnt.")") + let str = "" + let spacecnt = a:spacecnt + while spacecnt > 0 + let str = str . " " + let spacecnt = spacecnt - 1 + endwhile +" call Dret("MakeSpace <".str.">") + return str +endfun + +" --------------------------------------------------------------------- +" Align#Align: align selected text based on alignment pattern(s) {{{1 +fun! Align#Align(hasctrl,...) range +" call Dfunc("Align#Align(hasctrl=".a:hasctrl.",...) a:0=".a:0) + + " sanity check + if string(a:hasctrl) != "0" && string(a:hasctrl) != "1" + echohl Error|echo 'usage: Align#Align(hasctrl<'.a:hasctrl.'> (should be 0 or 1),"separator(s)" (you have '.a:0.') )'|echohl None +" call Dret("Align#Align") + return + endif + + " set up a list akin to an argument list + if a:0 > 0 + let A= s:QArgSplitter(a:1) + else + let A=[0] + endif + + " if :Align! was used, then the first argument is (should be!) an AlignCtrl string + " Note that any alignment control set this way will be temporary. + let hasctrl= a:hasctrl +" call Decho("hasctrl=".hasctrl) + if a:hasctrl && A[0] >= 1 +" call Decho("Align! : using A[1]<".A[1]."> for AlignCtrl") + if A[1] =~ '[gv]' + let hasctrl= hasctrl + 1 + call Align#AlignCtrl('m') + call Align#AlignCtrl(A[1],A[2]) +" call Decho("Align! : also using A[2]<".A[2]."> for AlignCtrl") + elseif A[1] !~ 'm' + call Align#AlignCtrl(A[1]."m") + else + call Align#AlignCtrl(A[1]) + endif + endif + + " Check for bad separator patterns (zero-length matches) + let ipat= 1 + hasctrl + while ipat <= A[0] + if "" =~ A[ipat] + echoerr "Align: separator<".A[ipat]."> matches zero-length string" +" call Dret("Align#Align") + return + endif + let ipat= ipat + 1 + endwhile + + " record current search pattern for subsequent restoration + let keep_search= @/ + let keep_ic = &ic + let keep_report= &report + set noic report=10000 + + if A[0] > hasctrl + " Align will accept a list of separator regexps +" call Decho("A[0]=".A[0].": accepting list of separator regexp") + + if s:AlignCtrl =~# "=" + "= : consider all separators to be equivalent +" call Decho("AlignCtrl: record list of equivalent alignment patterns") + let s:AlignCtrl = '=' + let s:AlignPat_1 = A[1 + hasctrl] + let s:AlignPatQty= 1 + let ipat = 2 + hasctrl + while ipat <= A[0] + let s:AlignPat_1 = s:AlignPat_1.'\|'.A[ipat] + let ipat = ipat + 1 + endwhile + let s:AlignPat_1= '\('.s:AlignPat_1.'\)' +" call Decho("AlignCtrl<".s:AlignCtrl."> AlignPat<".s:AlignPat_1.">") + + elseif s:AlignCtrl =~# 'C' + "c : cycle through alignment pattern(s) +" call Decho("AlignCtrl: cycle through alignment pattern(s)") + let s:AlignCtrl = 'C' + let s:AlignPatQty= A[0] - hasctrl + let ipat = 1 + while ipat <= s:AlignPatQty + let s:AlignPat_{ipat}= A[(ipat + hasctrl)] +" call Decho("AlignCtrl<".s:AlignCtrl."> AlignQty=".s:AlignPatQty." AlignPat_".ipat."<".s:AlignPat_{ipat}.">") + let ipat= ipat + 1 + endwhile + endif + endif + + " Initialize so that begline + " is greater than the line's string length -> ragged right. + " Have to be careful about visualmode() -- it returns the last visual + " mode used whether or not it was used currently. + let begcol = virtcol("'<")-1 + let endcol = virtcol("'>")-1 + if begcol > endcol + let begcol = virtcol("'>")-1 + let endcol = virtcol("'<")-1 + endif +" call Decho("begcol=".begcol." endcol=".endcol) + let begline = a:firstline + let endline = a:lastline + if begline > endline + let begline = a:lastline + let endline = a:firstline + 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 + else + let ragged= 1 + endif + else + let ragged= 1 + endif + if ragged + let begcol= 0 + endif +" call Decho("lines[".begline.",".endline."] col[".begcol.",".endcol."] ragged=".ragged." AlignCtrl<".s:AlignCtrl.">") + + " Keep user options + let etkeep = &et + let pastekeep= &paste + setlocal et paste + + " convert selected range of lines to use spaces instead of tabs + " but if first line's initial white spaces are to be retained + " then use 'em + if begcol <= 0 && s:AlignLeadKeep == 'I' + " retain first leading whitespace for all subsequent lines + let bgntxt= substitute(getline(begline),'^\(\s*\).\{-}$','\1','') +" call Decho("retaining 1st leading whitespace: bgntxt<".bgntxt.">") + set noet + endif + exe begline.",".endline."ret" + + " Execute two passes + " First pass: collect alignment data (max field sizes) + " Second pass: perform alignment + let pass= 1 + while pass <= 2 +" call Decho(" ") +" call Decho("---- Pass ".pass.": ----") + + let line= begline + while line <= endline + " Process each line + let txt = getline(line) +" call Decho(" ") +" call Decho("Pass".pass.": Line ".line." <".txt.">") + + " AlignGPat support: allows a selector pattern (akin to g/selector/cmd ) + if exists("s:AlignGPat") +" call Decho("Pass".pass.": AlignGPat<".s:AlignGPat.">") + if match(txt,s:AlignGPat) == -1 +" call Decho("Pass".pass.": skipping") + let line= line + 1 + continue + endif + endif + + " AlignVPat support: allows a selector pattern (akin to v/selector/cmd ) + if exists("s:AlignVPat") +" call Decho("Pass".pass.": AlignVPat<".s:AlignVPat.">") + if match(txt,s:AlignVPat) != -1 +" call Decho("Pass".pass.": skipping") + let line= line + 1 + continue + endif + endif + + " Always skip blank lines + if match(txt,'^\s*$') != -1 +" call Decho("Pass".pass.": skipping") + let line= line + 1 + continue + 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) +" call Decho("Pass".pass.": record text to left: bgntxt<".bgntxt.">") + elseif s:AlignLeadKeep == 'W' + let bgntxt= substitute(txt,'^\(\s*\).\{-}$','\1','') +" call Decho("Pass".pass.": retaining all leading ws: bgntxt<".bgntxt.">") + elseif s:AlignLeadKeep == 'w' || !exists("bgntxt") + " No beginning text + let bgntxt= "" +" call Decho("Pass".pass.": no beginning text") + endif + if ragged + let endtxt= "" + else + " Elide any text lying outside selected columnar region + let endtxt= strpart(txt,endcol+1,txtlen-endcol) + let txt = strpart(txt,begcol,endcol-begcol+1) + endif +" call Decho(" ") +" call Decho("Pass".pass.": bgntxt<".bgntxt.">") +" 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 +" call Dret("Align#Align") + return + endif + + " Initialize for both passes + let seppat = s:AlignPat_{1} + let ifield = 1 + let ipat = 1 + let bgnfield = 0 + let endfield = 0 + let alignstyle = s:AlignStyle + let doend = 1 + let newtxt = "" + let alignprepad = s:AlignPrePad + let alignpostpad= s:AlignPostPad + let alignsep = s:AlignSep + let alignophold = " " + let alignop = "l" +" call Decho("Pass".pass.": initial alignstyle<".alignstyle."> seppat<".seppat.">") + + " Process each field on the line + while doend > 0 + + " C-style: cycle through pattern(s) + if s:AlignCtrl == 'C' && doend == 1 + let seppat = s:AlignPat_{ipat} +" call Decho("Pass".pass.": processing field: AlignCtrl=".s:AlignCtrl." ipat=".ipat." seppat<".seppat.">") + let ipat = ipat + 1 + if ipat > s:AlignPatQty + let ipat = 1 + endif + endif + + " cyclic alignment/justification operator handling + let alignophold = alignop + let alignop = strpart(alignstyle,0,1) + if alignop == '+' || doend == 2 + let alignop= alignophold + else + let alignstyle = strpart(alignstyle,1).strpart(alignstyle,0,1) + let alignopnxt = strpart(alignstyle,0,1) + if alignop == ':' + let seppat = '$' + let doend = 2 +" call Decho("Pass".pass.": alignop<:> case: setting seppat<$> doend==2") + endif + endif + + " cylic 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) + 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.">") + endwhile + let seplen= sepfield - endfield +" call Decho("Pass".pass.": seplen=[sepfield=".sepfield."] - [endfield=".endfield."]=".seplen) + + if endfield != -1 + if pass == 1 + " --------------------------------------------------------------------- + " Pass 1: Update FieldSize to max +" call Decho("Pass".pass.": before lead/trail remove: field<".strpart(txt,bgnfield,endfield-bgnfield).">") + let field = substitute(strpart(txt,bgnfield,endfield-bgnfield),'^\s*\(.\{-}\)\s*$','\1','') + if s:AlignLeadKeep == 'W' + 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 sFieldSize = "FieldSize_".ifield + if !exists(sFieldSize) + let FieldSize_{ifield}= fieldlen +" call Decho("Pass".pass.": set FieldSize_{".ifield."}=".FieldSize_{ifield}." <".field.">") + elseif fieldlen > FieldSize_{ifield} + let FieldSize_{ifield}= fieldlen +" call Decho("Pass".pass.": oset FieldSize_{".ifield."}=".FieldSize_{ifield}." <".field.">") + endif + let sSepSize= "SepSize_".ifield + if !exists(sSepSize) + let SepSize_{ifield}= seplen +" call Decho(" set SepSize_{".ifield."}=".SepSize_{ifield}." <".field.">") + elseif seplen > SepSize_{ifield} + let SepSize_{ifield}= seplen +" call Decho("Pass".pass.": oset SepSize_{".ifield."}=".SepSize_{ifield}." <".field.">") + endif + + else + " --------------------------------------------------------------------- + " Pass 2: Perform Alignment + let prepad = strpart(alignprepad,0,1) + let postpad = strpart(alignpostpad,0,1) + let alignprepad = strpart(alignprepad,1).strpart(alignprepad,0,1) + let alignpostpad = strpart(alignpostpad,1).strpart(alignpostpad,0,1) + let field = substitute(strpart(txt,bgnfield,endfield-bgnfield),'^\s*\(.\{-}\)\s*$','\1','') + if s:AlignLeadKeep == 'W' + let field = bgntxt.field + let bgntxt= "" + endif + if doend == 2 + 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 sep = s:MakeSpace(prepad).strpart(txt,endfield,sepfield-endfield).s:MakeSpace(postpad) + if seplen < SepSize_{ifield} + if alignsepop == "<" + " left-justify separators + let sep = sep.s:MakeSpace(SepSize_{ifield}-seplen) + elseif alignsepop == ">" + " right-justify separators + let sep = s:MakeSpace(SepSize_{ifield}-seplen).sep + else + " center-justify separators + let sepleft = (SepSize_{ifield} - seplen)/2 + let sepright = SepSize_{ifield} - seplen - sepleft + let sep = s:MakeSpace(sepleft).sep.s:MakeSpace(sepright) + endif + endif + 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 + if spaces > 0 + if alignop == 'c' + " center the field + let spaceleft = spaces/2 + let spaceright= FieldSize_{ifield} - spaceleft - fieldlen + let newtxt = newtxt.s:MakeSpace(spaceleft).field.s:MakeSpace(spaceright).sep + elseif alignop == 'r' + " right justify the field + let newtxt= newtxt.s:MakeSpace(spaces).field.sep + elseif ragged && doend == 2 + " left justify rightmost field (no trailing blanks needed) + let newtxt= newtxt.field + else + " left justfiy the field + let newtxt= newtxt.field.s:MakeSpace(spaces).sep + endif + elseif ragged && doend == 2 + " field at maximum field size and no trailing blanks needed + let newtxt= newtxt.field + else + " field is at maximum field size already + let newtxt= newtxt.field.sep + endif +" call Decho("Pass".pass.": newtxt<".newtxt.">") + endif " pass 1/2 + + " bgnfield indexes to end of separator at right of current field + " Update field counter + let bgnfield= sepfield + let ifield = ifield + 1 + if doend == 2 + let doend= 0 + endif + " handle end-of-text as end-of-field + elseif doend == 1 + let seppat = '$' + let doend = 2 + else + let doend = 0 + endif " endfield != -1 + endwhile " doend loop (as well as regularly separated fields) + + if pass == 2 + " Write altered line to buffer +" 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) + endif + + let line = line + 1 + endwhile " line loop + + let pass= pass + 1 + endwhile " pass loop +" call Decho("end of two pass loop") + + " Restore user options + let &et = etkeep + let &paste = pastekeep + + if exists("s:DoAlignPop") + " AlignCtrl Map support + call Align#AlignPop() + unlet s:DoAlignPop + endif + + " restore current search pattern + let @/ = keep_search + let &ic = keep_ic + let &report = keep_report + +" call Dret("Align#Align") + return +endfun + +" --------------------------------------------------------------------- +" AlignPush: this command/function pushes an alignment control string onto a stack {{{1 +fun! Align#AlignPush() +" call Dfunc("AlignPush()") + + " initialize the stack + if !exists("s:AlignCtrlStackQty") + let s:AlignCtrlStackQty= 1 + else + let s:AlignCtrlStackQty= s:AlignCtrlStackQty + 1 + endif + + " construct an AlignCtrlStack entry + if !exists("s:AlignSep") + let s:AlignSep= '' + endif + let s:AlignCtrlStack_{s:AlignCtrlStackQty}= s:AlignCtrl.'p'.s:AlignPrePad.'P'.s:AlignPostPad.s:AlignLeadKeep.s:AlignStyle.s:AlignSep +" call Decho("AlignPush: AlignCtrlStack_".s:AlignCtrlStackQty."<".s:AlignCtrlStack_{s:AlignCtrlStackQty}.">") + + " push [GV] patterns onto their own stack + if exists("s:AlignGPat") + let s:AlignGPat_{s:AlignCtrlStackQty}= s:AlignGPat + else + let s:AlignGPat_{s:AlignCtrlStackQty}= "" + endif + if exists("s:AlignVPat") + let s:AlignVPat_{s:AlignCtrlStackQty}= s:AlignVPat + else + let s:AlignVPat_{s:AlignCtrlStackQty}= "" + endif + +" call Dret("AlignPush") +endfun + +" --------------------------------------------------------------------- +" AlignPop: this command/function pops an alignment pattern from a stack {{1 +" and into the AlignCtrl variables. +fun! Align#AlignPop() +" call Dfunc("Align#AlignPop()") + + " sanity checks + if !exists("s:AlignCtrlStackQty") + echoerr "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" +" call Dret("Align#AlignPop <> : AlignPop needs to have been called first") + return "" + endif + + " pop top of AlignCtrlStack and pass value to AlignCtrl + let retval=s:AlignCtrlStack_{s:AlignCtrlStackQty} + unlet s:AlignCtrlStack_{s:AlignCtrlStackQty} + call Align#AlignCtrl(retval) + + " pop G pattern stack + if s:AlignGPat_{s:AlignCtrlStackQty} != "" + call Align#AlignCtrl('g',s:AlignGPat_{s:AlignCtrlStackQty}) + else + call Align#AlignCtrl('g') + endif + unlet s:AlignGPat_{s:AlignCtrlStackQty} + + " pop V pattern stack + if s:AlignVPat_{s:AlignCtrlStackQty} != "" + call Align#AlignCtrl('v',s:AlignVPat_{s:AlignCtrlStackQty}) + else + call Align#AlignCtrl('v') + endif + + unlet s:AlignVPat_{s:AlignCtrlStackQty} + let s:AlignCtrlStackQty= s:AlignCtrlStackQty - 1 + +" call Dret("Align#AlignPop <".retval."> : AlignCtrlStackQty=".s:AlignCtrlStackQty) + return retval +endfun + +" --------------------------------------------------------------------- +" AlignReplaceQuotedSpaces: {{{1 +fun! Align#AlignReplaceQuotedSpaces() +" call Dfunc("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:startingPos = 0 + let l:startQuotePos = 0 + let l:endQuotePos = 0 + let l:spacePos = 0 + let l:quoteRe = '\\\@, is needed. {{{1 +" However, doesn't split at all, so this function returns a list +" of arguments which has been: +" * split at whitespace +" * unless inside "..."s. One may escape characters with a backslash inside double quotes. +" along with a leading length-of-list. +" +" Examples: %Align "\"" will align on "s +" %Align " " will align on spaces +" +" The resulting list: qarglist[0] corresponds to a:0 +" qarglist[i] corresponds to a:{i} +fun! s:QArgSplitter(qarg) +" call Dfunc("s:QArgSplitter(qarg<".a:qarg.">)") + + if a:qarg =~ '".*"' + " handle "..." args, which may include whitespace + let qarglist = [] + let args = a:qarg +" call Decho("handle quoted arguments: args<".args.">") + while args != "" + let iarg = 0 + let arglen = strlen(args) +" call Decho("args[".iarg."]<".args[iarg]."> arglen=".arglen) + " 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) + + if iarg > 0 + " 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 + let qarglist= qarglist + split(strpart(args,0,iarg)) + endif + let args = strpart(args,iarg) + let arglen = strlen(args) + + elseif iarg < arglen && args[0] == '"' + " handle "quoted" section +" call Decho("handle quoted section") + let iarg= 1 + 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) + if args[iarg] == '"' + call add(qarglist,strpart(args,1,iarg-1)) + let args= strpart(args,iarg+1) + else + let qarglist = qarglist + split(args) + let args = "" + endif + endif +" call Decho("qarglist".string(qarglist)." iarg=".iarg." args<".args.">") + endwhile + + else + " split at all whitespace + let qarglist= split(a:qarg) + endif + + let qarglistlen= len(qarglist) + let qarglist = insert(qarglist,qarglistlen) +" call Dret("s:QArgSplitter ".string(qarglist)) + return qarglist +endfun + +" --------------------------------------------------------------------- +" s:Strlen: this function returns the length of a string, even if its {{{1 +" using two-byte etc characters. Depends on virtcol(). +" Currently, its only used if g:Align_xstrlen is set to a +" 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 + " 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 + " 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')) + + 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 + " preceded by lam, one otherwise, etc.) + " (comment from TM, solution from me) + let modkeep= &mod + exe "norm! o\" + call setline(line("."),a:x) + let ret= virtcol("$") - 1 + d + let &mod= modkeep + + else + " at least give a decent default + ret= strlen(a:x) + endif +" call Dret("s:Strlen ".ret) + return ret +endfun + +" --------------------------------------------------------------------- +" Set up default values: {{{1 +"call Decho("-- Begin AlignCtrl Initialization --") +call Align#AlignCtrl("default") +"call Decho("-- End AlignCtrl Initialization --") + +" --------------------------------------------------------------------- +" Restore: {{{1 +let &cpo= s:keepcpo +unlet s:keepcpo +" vim: ts=4 fdm=marker diff --git a/vimfiles/autoload/calutil.vim b/vimfiles/autoload/calutil.vim new file mode 100644 index 0000000..6a7f941 --- /dev/null +++ b/vimfiles/autoload/calutil.vim @@ -0,0 +1,147 @@ +" calutil.vim: some calendar utilities +" Author: Charles E. Campbell, Jr. +" Date: Oct 19, 2007 +" Version: 3a ASTRO-ONLY +" --------------------------------------------------------------------- +if exists("loaded_calutil") + finish +endif +let g:loaded_calutil= "v3a" + +" --------------------------------------------------------------------- +" DayOfWeek: {{{1 +" Usage : call calutil#DayOfWeek(y,m,d,[0|1|2]) +" g:CalUtilDayOfWeek: if 0-> integer (default) +" 1-> 3-letter English abbreviation for name of day +" 2-> English name of day +" Returns +" g:CalUtilDayOfWeek +" --------- +" 1 : 0 1 2 3 4 5 6 +" 2 : Mon Tue Wed Thu Fri Sat Sun +" 3 : Monday Tuesday Wednesday Thursday Friday Saturday Sunday +fun! calutil#DayOfWeek(y,m,d,...) + if a:0 > 0 + let g:CalUtilDayOfWeek= a:1 + endif + + let z= Cal2Jul(a:y,a:m,a:d) + if z >= 0 + let z= z%7 + else + let z= 7 - (-z%7) + endif + + if exists("g:CalUtilDayOfWeek") + if g:CalUtilDayOfWeek == 2 + let dow0="Mon" + let dow1="Tue" + let dow2="Wed" + let dow3="Thu" + let dow4="Fri" + let dow5="Sat" + let dow6="Sun" + return dow{z} + elseif g:CalUtilDayOfWeek == 3 + let dow0="Monday" + let dow1="Tuesday" + let dow2="Wednesday" + let dow3="Thursday" + let dow4="Friday" + let dow5="Saturday" + let dow6="Sunday" + return dow{z} + endif + endif + return z +endfun + +" --------------------------------------------------------------------- +" calutil#Cal2Jul: convert a (after 9/14/1752) Gregorian calendar date to Julian day {{{1 +" (on,before " ) Julian calendar date to Julian day +" (proleptic) +fun! calutil#Cal2Jul(y,m,d) + let year = a:y + let month= a:m + let day = a:d + + " there is no year zero + if year == 0 + let year= -1 + elseif year < 0 + let year= year + 1 + endif + + let julday= day - 32075 + + \ 1461*(year + 4800 + (month - 14)/12)/4 + + \ 367*(month - 2 - ((month - 14)/12)*12)/12 - + \ 3*((year + 4900 + (month - 14)/12)/100)/4 + + " 2361221 == Sep 2, 1752, which was followed immediately by + " Sep 14, 1752 (in England). Various countries + " adopted the Gregorian calendar at different times. + if julday <= 2361221 + let a = (14-month)/12 + let y = year + 4800 - a + let m = month + 12*a - 3 + let julday = day + (153*m + 2)/5 + y*365 + y/4 - 32083 + endif + return julday +endfun + +" --------------------------------------------------------------------- +" calutil#Jul2Cal: convert a Julian day to a date: {{{1 +" Default year/month/day +" julday,1 julday,"ymd" year/month/day +" julday,2 julday,"mdy" month/day/year +" julday,3 julday,"dmy" day/month/year +fun! calutil#Jul2Cal(julday,...) + let julday= a:julday + + if julday <= 2361221 + " Proleptic Julian Calendar: + " 2361210 == Sep 2, 1752, which was followed immediately by Sep 14, 1752 + " in England + let c = julday + 32082 + let d = (4*c + 3)/1461 + let e = c - (1461*d)/4 + let m = (5*e + 2)/153 + let day = e - (153*m + 2)/5 + 1 + let month = m + 3 - 12*(m/10) + let year = d - 4800 + m/10 + if year <= 0 + " proleptic Julian Calendar: there *is* no year 0! + let year= year - 1 + endif + + else + " Gregorian calendar + let t1 = julday + 68569 + let t2 = 4*t1/146097 + let t1 = t1 - (146097*t2 + 3)/4 + let yr = 4000*(t1 + 1)/1461001 + let t1 = t1 - (1461*yr/4 - 31) + let mo = 80*t1/2447 + let day = (t1 - 2447*mo/80) + let t1 = mo/11 + let month = (mo + 2 - 12*t1) + let year = (100*(t2 - 49) + yr + t1) + endif + + if a:0 > 0 + if a:1 == 1 || a:1 =~ "ymd" + return year."/".month."/".day + elseif a:1 == 2 || a:1 =~ "mdy" + return month."/".day."/".year + elseif a:1 == 3 || a:1 =~ "dmy" + return day."/".month."/".year + else + return year."/".month."/".day + endif + else + return year."/".month."/".day + endif +endfun + +" --------------------------------------------------------------------- +" vim: ts=4 fdm=marker diff --git a/vimfiles/autoload/getscript.vim b/vimfiles/autoload/getscript.vim index 5ca201b..b22ff8a 100644 --- a/vimfiles/autoload/getscript.vim +++ b/vimfiles/autoload/getscript.vim @@ -1,531 +1,591 @@ -" --------------------------------------------------------------------- -" getscript.vim -" Author: Charles E. Campbell, Jr. -" Date: May 05, 2007 -" Version: 25 -" Installing: :help glvs-install -" Usage: :help glvs -" -" GetLatestVimScripts: 642 1 :AutoInstall: getscript.vim -" --------------------------------------------------------------------- -" Initialization: {{{1 -" if you're sourcing this file, surely you can't be -" expecting vim to be in its vi-compatible mode -if &cp - echoerr "GetLatestVimScripts is not vi-compatible; not loaded (you need to set nocp)" - finish -endif -let s:keepcpo = &cpo -set cpo&vim -"DechoTabOn - -if exists("g:loaded_getscript") - finish -endif -let g:loaded_getscript= "v25" - -" --------------------------------------------------------------------- -" Global Variables: {{{1 -" allow user to change the command for obtaining scripts (does fetch work?) -if !exists("g:GetLatestVimScripts_wget") - if executable("wget") - let g:GetLatestVimScripts_wget= "wget" - elseif executable("curl") - let g:GetLatestVimScripts_wget= "curl" - else - let g:GetLatestVimScripts_wget = 'echo "GetLatestVimScripts needs wget or curl"' - let g:GetLatestVimScripts_options = "" - endif -endif - -" options that wget and curl require: -if !exists("g:GetLatestVimScripts_options") - if g:GetLatestVimScripts_wget == "wget" - let g:GetLatestVimScripts_options= "-q -O" - elseif g:GetLatestVimScripts_wget == "curl" - let g:GetLatestVimScripts_options= "-s -O" - else - let g:GetLatestVimScripts_options= "" - endif -endif - -" by default, allow autoinstall lines to work -if !exists("g:GetLatestVimScripts_allowautoinstall") - let g:GetLatestVimScripts_allowautoinstall= 1 -endif - -"" For debugging: -"let g:GetLatestVimScripts_wget = "echo" -"let g:GetLatestVimScripts_options = "options" - -" --------------------------------------------------------------------- -" Check If AutoInstall Capable: {{{1 -let s:autoinstall= "" -if g:GetLatestVimScripts_allowautoinstall - - if (has("win32") || has("gui_win32") || has("gui_win32s") || has("win16") || has("win64") || has("win32unix") || has("win95")) && &shell != "bash" - " windows (but not cygwin/bash) - let s:dotvim= "vimfiles" - if !exists("g:GetLatestVimScripts_mv") - let g:GetLatestVimScripts_mv= "ren" - endif - - else - " unix - let s:dotvim= ".vim" - if !exists("g:GetLatestVimScripts_mv") - let g:GetLatestVimScripts_mv= "mv" - endif - endif - - if exists('$HOME') && isdirectory(expand("$HOME")."/".s:dotvim) - let s:autoinstall= $HOME."/".s:dotvim - endif -" call Decho("s:autoinstall<".s:autoinstall.">") -"else "Decho -" call Decho("g:GetLatestVimScripts_allowautoinstall=".g:GetLatestVimScripts_allowautoinstall.": :AutoInstall: disabled") -endif - -" --------------------------------------------------------------------- -" Public Interface: {{{1 -com! -nargs=0 GetLatestVimScripts call getscript#GetLatestVimScripts() -com! -nargs=0 GetScript call getscript#GetLatestVimScripts() -silent! com -nargs=0 GLVS call getscript#GetLatestVimScripts() - -" --------------------------------------------------------------------- -" GetOneScript: (Get Latest Vim Script) this function operates {{{1 -" on the current line, interpreting two numbers and text as -" ScriptID, SourceID, and Filename. -" It downloads any scripts that have newer versions from vim.sf.net. -fun! s:GetOneScript(...) -" call Dfunc("GetOneScript()") - - " set options to allow progress to be shown on screen - let t_ti= &t_ti - let t_te= &t_te - let rs = &rs - set t_ti= t_te= nors - - " put current line on top-of-screen and interpret it into - " a script identifer : used to obtain webpage - " source identifier : used to identify current version - " and an associated comment: used to report on what's being considered - if a:0 >= 3 - let scriptid = a:1 - let srcid = a:2 - let fname = a:3 - let cmmnt = "" -" call Decho("scriptid<".scriptid.">") -" call Decho("srcid <".srcid.">") -" call Decho("fname <".fname.">") - else - let curline = getline(".") - if curline =~ '^\s*#' -" call Dret("GetOneScript : skipping a pure comment line") - return - endif - let parsepat = '^\s*\(\d\+\)\s\+\(\d\+\)\s\+\(.\{-}\)\(\s*#.*\)\=$' - try - let scriptid = substitute(curline,parsepat,'\1','e') - catch /^Vim\%((\a\+)\)\=:E486/ - let scriptid= 0 - endtry - try - let srcid = substitute(curline,parsepat,'\2','e') - catch /^Vim\%((\a\+)\)\=:E486/ - let srcid= 0 - endtry - try - let fname= substitute(curline,parsepat,'\3','e') - catch /^Vim\%((\a\+)\)\=:E486/ - let fname= "" - endtry - try - let cmmnt= substitute(curline,parsepat,'\4','e') - catch /^Vim\%((\a\+)\)\=:E486/ - let cmmnt= "" - endtry -" call Decho("curline <".curline.">") -" call Decho("parsepat<".parsepat.">") -" call Decho("scriptid<".scriptid.">") -" call Decho("srcid <".srcid.">") -" call Decho("fname <".fname.">") - endif - - if scriptid == 0 || srcid == 0 - " When looking for :AutoInstall: lines, skip scripts that - " have 0 0 scriptname -" call Dret("GetOneScript : skipping a scriptid==srcid==0 line") - return - endif - - let doautoinstall= 0 - if fname =~ ":AutoInstall:" -" call Decho("fname<".fname."> has :AutoInstall:...") - let aicmmnt= substitute(fname,'\s\+:AutoInstall:\s\+',' ','') -" call Decho("aicmmnt<".aicmmnt."> s:autoinstall=".s:autoinstall) - if s:autoinstall != "" - let doautoinstall = g:GetLatestVimScripts_allowautoinstall - endif - else - let aicmmnt= fname - endif -" call Decho("aicmmnt<".aicmmnt.">: doautoinstall=".doautoinstall) - - exe "norm z\" - redraw! -" call Decho('considering <'.aicmmnt.'> scriptid='.scriptid.' srcid='.srcid) - echomsg 'considering <'.aicmmnt.'> scriptid='.scriptid.' srcid='.srcid - - " grab a copy of the plugin's vim.sf.net webpage - let scriptaddr = 'http://vim.sf.net/script.php?script_id='.scriptid - let tmpfile = tempname() - let v:errmsg = "" - - " make three tries at downloading the description - let itry= 1 - while itry <= 3 -" call Decho("try#".itry." to download description of <".aicmmnt."> with addr=".scriptaddr) - if has("win32") || has("win16") || has("win95") -" call Decho("silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".tmpfile.' "'.scriptaddr.'"') - exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".tmpfile.' "'.scriptaddr.'"' - else -" call Decho("silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".tmpfile." '".scriptaddr."'") - exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".tmpfile." '".scriptaddr."'" - endif - if itry == 1 - exe "silent vsplit ".tmpfile - else - silent! e % - endif - - " find the latest source-id in the plugin's webpage - silent! 1 - let findpkg= search('Click on the package to download','W') - if findpkg > 0 - break - endif - let itry= itry + 1 - endwhile -" call Decho(" --- end downloading tries while loop --- itry=".itry) - - " testing: did finding /Click on the package.../ fail? - if findpkg == 0 || itry >= 4 - silent q! - call delete(tmpfile) - " restore options - let &t_ti = t_ti - let &t_te = t_te - let &rs = rs - let s:downerrors = s:downerrors + 1 -" call Decho("***warning*** couldn'".'t find "Click on the package..." in description page for <'.aicmmnt.">") - echomsg "***warning*** couldn'".'t find "Click on the package..." in description page for <'.aicmmnt.">" -" call Dret("GetOneScript : srch for /Click on the package/ failed") - return - endif -" call Decho('found "Click on the package to download"') - - let findsrcid= search('src_id=','W') - if findsrcid == 0 - silent q! - call delete(tmpfile) - " restore options - let &t_ti = t_ti - let &t_te = t_te - let &rs = rs - let s:downerrors = s:downerrors + 1 -" call Decho("***warning*** couldn'".'t find "src_id=" in description page for <'.aicmmnt.">") - echomsg "***warning*** couldn'".'t find "src_id=" in description page for <'.aicmmnt.">" -" call Dret("GetOneScript : srch for /src_id/ failed") - return - endif -" call Decho('found "src_id=" in description page') - - let srcidpat = '^\s*\([^<]\+\)<.*$' - let latestsrcid= substitute(getline("."),srcidpat,'\1','') - let fname = substitute(getline("."),srcidpat,'\2','') -" call Decho("srcidpat<".srcidpat."> latestsrcid<".latestsrcid."> fname<".fname.">") - silent q! - call delete(tmpfile) - - " convert the strings-of-numbers into numbers - let srcid = srcid + 0 - let latestsrcid = latestsrcid + 0 -" call Decho("srcid=".srcid." latestsrcid=".latestsrcid." fname<".fname.">") - - " has the plugin's most-recent srcid increased, which indicates - " that it has been updated - if latestsrcid > srcid - let s:downloads= s:downloads + 1 - if fname == bufname("%") - " GetLatestVimScript has to be careful about downloading itself - let fname= "NEW_".fname - endif - - " the plugin has been updated since we last obtained it, so download a new copy -" call Decho("...downloading new <".fname.">") - echomsg "...downloading new <".fname.">" - if has("win32") || has("gui_win32") || has("gui_win32s") || has("win16") || has("win64") || has("win32unix") || has("win95") -" call Decho("windows: silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".fname.' "'.'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid.'"') - exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".fname.' "'.'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid.'"' - else -" call Decho("unix: silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".fname." '".'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid."'") - exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".fname." '".'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid."'" - endif - - " AutoInstall: only if doautoinstall is so indicating - if doautoinstall -" call Decho("attempting to do autoinstall: getcwd<".getcwd()."> filereadable(".fname.")=".filereadable(fname)) - if filereadable(fname) -" call Decho("move <".fname."> to ".s:autoinstall) - exe "silent !".g:GetLatestVimScripts_mv." ".fname." ".s:autoinstall - let curdir= escape(substitute(getcwd(),'\','/','ge'),"|[]*'\" #") -" call Decho("exe cd ".s:autoinstall) - exe "cd ".s:autoinstall - - " decompress - if fname =~ '\.bz2$' -" call Decho("attempt to bunzip2 ".fname) - exe "silent !bunzip2 ".fname - let fname= substitute(fname,'\.bz2$','','') -" call Decho("new fname<".fname."> after bunzip2") - elseif fname =~ '\.gz$' -" call Decho("attempt to gunzip ".fname) - exe "silent !gunzip ".fname - let fname= substitute(fname,'\.gz$','','') -" call Decho("new fname<".fname."> after gunzip") - endif - - " distribute archive(.zip, .tar, .vba) contents - if fname =~ '\.zip$' -" call Decho("attempt to unzip ".fname) - exe "silent !unzip -o ".fname - elseif fname =~ '\.tar$' -" call Decho("attempt to untar ".fname) - exe "silent !tar -xvf ".fname - elseif fname =~ '\.vba$' -" call Decho("attempt to handle a vimball: ".fname) - 1split - exe "e ".fname - so % - q - endif - - if fname =~ '.vim$' -" call Decho("attempt to simply move ".fname." to plugin") - exe "silent !".g:GetLatestVimScripts_mv." ".fname." plugin" - endif - - " helptags step - let docdir= substitute(&rtp,',.*','','e')."/doc" -" call Decho("helptags docdir<".docdir.">") - exe "helptags ".docdir - exe "cd ".curdir - endif - endif - - " update the data in the file - let modline=scriptid." ".latestsrcid." ".fname.cmmnt - call setline(line("."),modline) -" call Decho("update data in ".expand("%")."#".line(".").": modline<".modline.">") - endif - - " restore options - let &t_ti= t_ti - let &t_te= t_te - let &rs = rs - -" call Dret("GetOneScript") -endfun - -" --------------------------------------------------------------------- -" GetLatestVimScripts: this function gets the latest versions of {{{1 -" scripts based on the list in -" (first dir in runtimepath)/GetLatest/GetLatestVimScripts.dat -fun! getscript#GetLatestVimScripts() -" call Dfunc("GetLatestVimScripts() autoinstall<".s:autoinstall.">") - -" insure that wget is executable - if executable(g:GetLatestVimScripts_wget) != 1 - echoerr "GetLatestVimScripts needs ".g:GetLatestVimScripts_wget." which apparently is not available on your system" -" call Dret("GetLatestVimScripts : wget not executable/availble") - return - endif - - " Find the .../GetLatest subdirectory under the runtimepath - for datadir in split(&rtp,',') + [''] - if isdirectory(datadir."/GetLatest") -" call Decho("found directory<".datadir.">") - let datadir= datadir . "/GetLatest" - break - endif - if filereadable(datadir."GetLatestVimScripts.dat") -" call Decho("found ".datadir."/GetLatestVimScripts.dat") - break - endif - endfor - - " Sanity checks: readability and writability - if datadir == "" - echoerr 'Missing "GetLatest/" on your runtimepath - see :help glvs-dist-install' -" call Dret("GetLatestVimScripts : unable to find a GetLatest subdirectory") - return - endif - - if filewritable(datadir) != 2 - echoerr "(getLatestVimScripts) Your ".datadir." isn't writable" -" call Dret("GetLatestVimScripts : non-writable directory<".datadir.">") - return - endif - let datafile= datadir."/GetLatestVimScripts.dat" - if !filereadable(datafile) - echoerr "Your data file<".datafile."> isn't readable" -" call Dret("GetLatestVimScripts : non-readable datafile<".datafile.">") - return - endif - if !filewritable(datafile) - echoerr "Your data file<".datafile."> isn't writable" -" call Dret("GetLatestVimScripts : non-writable datafile<".datafile.">") - return - endif -" call Decho("datadir <".datadir.">") -" call Decho("datafile <".datafile.">") - - " don't let any events interfere (like winmanager's, taglist's, etc) - let eikeep= &ei - set ei=all - - " record current directory, change to datadir, open split window with - " datafile - let origdir= getcwd() - exe "cd ".escape(substitute(datadir,'\','/','ge'),"|[]*'\" #") - split - exe "e ".escape(substitute(datafile,'\','/','ge'),"|[]*'\" #") - res 1000 - let s:downloads = 0 - let s:downerrors= 0 - - " Check on dependencies mentioned in plugins -" call Decho(" ") -" call Decho("searching plugins for GetLatestVimScripts dependencies") - let lastline = line("$") -" call Decho("lastline#".lastline) - let plugins = split(globpath(&rtp,"plugin/*.vim")) - let foundscript = 0 - let firstdir= "" - - for plugin in plugins - - " don't process plugins in system directories - if firstdir == "" - let firstdir= substitute(plugin,'[/\\][^/\\]\+$','','') -" call Decho("firstdir<".firstdir.">") - else - let curdir= substitute(plugin,'[/\\][^/\\]\+$','','') -" call Decho("curdir<".curdir.">") - if curdir != firstdir - break - endif - endif - - " read plugin in - $ -" call Decho(" ") -" call Decho(".dependency checking<".plugin."> line$=".line("$")) - exe "silent r ".plugin - - while search('^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+','W') != 0 - let newscript= substitute(getline("."),'^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+\s\+\(.*\)$','\1','e') - let llp1 = lastline+1 -" call Decho("..newscript<".newscript.">") - - " don't process ""GetLatestVimScripts lines - if newscript !~ '^"' - " found a "GetLatestVimScripts: # #" line in the script; check if its already in the datafile - let curline = line(".") - let noai_script = substitute(newscript,'\s*:AutoInstall:\s*','','e') - exe llp1 - let srchline = search('\<'.noai_script.'\>','bW') -" call Decho("..noai_script<".noai_script."> srch=".srchline."curline#".line(".")." lastline#".lastline) - - if srchline == 0 - " found a new script to permanently include in the datafile - let keep_rega = @a - let @a = substitute(getline(curline),'^"\s\+GetLatestVimScripts:\s\+','','') - exe lastline."put a" - echomsg "Appending <".@a."> to ".datafile." for ".newscript -" call Decho("..APPEND (".noai_script.")<".@a."> to GetLatestVimScripts.dat") - let @a = keep_rega - let lastline = llp1 - let curline = curline + 1 - let foundscript = foundscript + 1 -" else " Decho -" call Decho("..found <".noai_script."> (already in datafile at line#".srchline.")") - endif - - let curline = curline + 1 - exe curline - endif - endwhile - - let llp1= lastline + 1 -" call Decho(".deleting lines: ".llp1.",$d") - exe "silent! ".llp1.",$d" - endfor -" call Decho("--- end dependency checking loop --- foundscript=".foundscript) -" call Decho(" ") - - if foundscript == 0 - set nomod - endif - - " Check on out-of-date scripts using GetLatest/GetLatestVimScripts.dat -" call Decho("begin: checking out-of-date scripts using datafile<".datafile.">") - set lz - 1 -" /^-----/,$g/^\s*\d/call Decho(getline(".")) - 1 - /^-----/,$g/^\s*\d/call s:GetOneScript() -" call Decho("--- end out-of-date checking --- ") - - " Final report (an echomsg) - try - silent! ?^-------? - catch /^Vim\%((\a\+)\)\=:E114/ -" call Dret("GetLatestVimScripts : nothing done!") - return - endtry - exe "norm! kz\" - redraw! - let s:msg = "" - if s:downloads == 1 - let s:msg = "Downloaded one updated script to <".datadir.">" - elseif s:downloads == 2 - let s:msg= "Downloaded two updated scripts to <".datadir.">" - elseif s:downloads > 1 - let s:msg= "Downloaded ".s:downloads." updated scripts to <".datadir.">" - else - let s:msg= "Everything was already current" - endif - if s:downerrors > 0 - let s:msg= s:msg." (".s:downerrors." downloading errors)" - endif - echomsg s:msg - " save the file - if &mod - silent! w! - endif - q - - " restore events and current directory - exe "cd ".escape(substitute(origdir,'\','/','ge'),"|[]*'\" #") - let &ei= eikeep - set nolz -" call Dret("GetLatestVimScripts : did ".s:downloads." downloads") -endfun -" --------------------------------------------------------------------- - -" Restore Options: {{{1 -let &cpo= s:keepcpo - -" vim: ts=8 sts=2 fdm=marker nowrap +" --------------------------------------------------------------------- +" getscript.vim +" Author: Charles E. Campbell, Jr. +" Date: Jan 08, 2008 +" Version: 29 +" Installing: :help glvs-install +" Usage: :help glvs +" +" GetLatestVimScripts: 642 1 :AutoInstall: getscript.vim +"redraw!|call inputsave()|call input("Press to continue")|call inputrestore() +" --------------------------------------------------------------------- +" Initialization: {{{1 +" if you're sourcing this file, surely you can't be +" expecting vim to be in its vi-compatible mode! +if &cp + echoerr "GetLatestVimScripts is not vi-compatible; not loaded (you need to set nocp)" + finish +endif +let s:keepcpo = &cpo +set cpo&vim +"DechoTabOn + +if exists("g:loaded_getscript") + finish +endif +let g:loaded_getscript= "v29" + +" --------------------------- +" Global Variables: {{{1 +" --------------------------- +" Cygwin Detection ------- {{{2 +if !exists("g:getscript_cygwin") + if has("win32") || has("win95") || has("win64") || has("win16") + if &shell =~ '\%(\\|\\)\%(\.exe\)\=$' + let g:getscript_cygwin= 1 + else + let g:getscript_cygwin= 0 + endif + else + let g:getscript_cygwin= 0 + endif +endif +" shell quoting character {{{2 +if exists("g:netrw_shq") && !exists("g:getscript_shq") + let g:getscript_shq= g:netrw_shq +elseif !exists("g:getscript_shq") + if exists("&shq") && &shq != "" + let g:getscript_shq= &shq + elseif exists("&sxq") && &sxq != "" + let g:getscript_shq= &sxq + elseif has("win32") || has("win95") || has("win64") || has("win16") + if g:getscript_cygwin + let g:getscript_shq= "'" + else + let g:getscript_shq= '"' + endif + else + let g:getscript_shq= "'" + endif +" call Decho("g:getscript_shq<".g:getscript_shq.">") +endif + +" wget vs curl {{{2 +if !exists("g:GetLatestVimScripts_wget") + if executable("wget") + let g:GetLatestVimScripts_wget= "wget" + elseif executable("curl") + let g:GetLatestVimScripts_wget= "curl" + else + let g:GetLatestVimScripts_wget = 'echo "GetLatestVimScripts needs wget or curl"' + let g:GetLatestVimScripts_options = "" + endif +endif + +" options that wget and curl require: +if !exists("g:GetLatestVimScripts_options") + if g:GetLatestVimScripts_wget == "wget" + let g:GetLatestVimScripts_options= "-q -O" + elseif g:GetLatestVimScripts_wget == "curl" + let g:GetLatestVimScripts_options= "-s -O" + else + let g:GetLatestVimScripts_options= "" + endif +endif + +" by default, allow autoinstall lines to work +if !exists("g:GetLatestVimScripts_allowautoinstall") + let g:GetLatestVimScripts_allowautoinstall= 1 +endif + +"" For debugging: +"let g:GetLatestVimScripts_wget = "echo" +"let g:GetLatestVimScripts_options = "options" + +" --------------------------------------------------------------------- +" Check If AutoInstall Capable: {{{1 +let s:autoinstall= "" +if g:GetLatestVimScripts_allowautoinstall + + if (has("win32") || has("gui_win32") || has("gui_win32s") || has("win16") || has("win64") || has("win32unix") || has("win95")) && &shell != "bash" + " windows (but not cygwin/bash) + let s:dotvim= "vimfiles" + if !exists("g:GetLatestVimScripts_mv") + let g:GetLatestVimScripts_mv= "ren" + endif + + else + " unix + let s:dotvim= ".vim" + if !exists("g:GetLatestVimScripts_mv") + let g:GetLatestVimScripts_mv= "mv" + endif + endif + + if exists('$HOME') && isdirectory(expand("$HOME")."/".s:dotvim) + let s:autoinstall= $HOME."/".s:dotvim + endif +" call Decho("s:autoinstall<".s:autoinstall.">") +"else "Decho +" call Decho("g:GetLatestVimScripts_allowautoinstall=".g:GetLatestVimScripts_allowautoinstall.": :AutoInstall: disabled") +endif + +" --------------------------------------------------------------------- +" Public Interface: {{{1 +com! -nargs=0 GetLatestVimScripts call getscript#GetLatestVimScripts() +com! -nargs=0 GetScript call getscript#GetLatestVimScripts() +silent! com -nargs=0 GLVS call getscript#GetLatestVimScripts() + +" --------------------------------------------------------------------- +" GetOneScript: (Get Latest Vim Script) this function operates {{{1 +" on the current line, interpreting two numbers and text as +" ScriptID, SourceID, and Filename. +" It downloads any scripts that have newer versions from vim.sf.net. +fun! s:GetOneScript(...) +" call Dfunc("GetOneScript()") + + " set options to allow progress to be shown on screen + let rega= @a + let t_ti= &t_ti + let t_te= &t_te + let rs = &rs + set t_ti= t_te= nors + + " put current line on top-of-screen and interpret it into + " a script identifer : used to obtain webpage + " source identifier : used to identify current version + " and an associated comment: used to report on what's being considered + if a:0 >= 3 + let scriptid = a:1 + let srcid = a:2 + let fname = a:3 + let cmmnt = "" +" call Decho("scriptid<".scriptid.">") +" call Decho("srcid <".srcid.">") +" call Decho("fname <".fname.">") + else + let curline = getline(".") + if curline =~ '^\s*#' + let @a= rega +" call Dret("GetOneScript : skipping a pure comment line") + return + endif + let parsepat = '^\s*\(\d\+\)\s\+\(\d\+\)\s\+\(.\{-}\)\(\s*#.*\)\=$' + try + let scriptid = substitute(curline,parsepat,'\1','e') + catch /^Vim\%((\a\+)\)\=:E486/ + let scriptid= 0 + endtry + try + let srcid = substitute(curline,parsepat,'\2','e') + catch /^Vim\%((\a\+)\)\=:E486/ + let srcid= 0 + endtry + try + let fname= substitute(curline,parsepat,'\3','e') + catch /^Vim\%((\a\+)\)\=:E486/ + let fname= "" + endtry + try + let cmmnt= substitute(curline,parsepat,'\4','e') + catch /^Vim\%((\a\+)\)\=:E486/ + let cmmnt= "" + endtry +" call Decho("curline <".curline.">") +" call Decho("parsepat<".parsepat.">") +" call Decho("scriptid<".scriptid.">") +" call Decho("srcid <".srcid.">") +" call Decho("fname <".fname.">") + endif + + if scriptid == 0 || srcid == 0 + " When looking for :AutoInstall: lines, skip scripts that have 0 0 scriptname + let @a= rega +" call Dret("GetOneScript : skipping a scriptid==srcid==0 line") + return + endif + + let doautoinstall= 0 + if fname =~ ":AutoInstall:" +" call Decho("case AutoInstall: fname<".fname.">") + let aicmmnt= substitute(fname,'\s\+:AutoInstall:\s\+',' ','') +" call Decho("aicmmnt<".aicmmnt."> s:autoinstall=".s:autoinstall) + if s:autoinstall != "" + let doautoinstall = g:GetLatestVimScripts_allowautoinstall + endif + else + let aicmmnt= fname + endif +" call Decho("aicmmnt<".aicmmnt.">: doautoinstall=".doautoinstall) + + exe "norm z\" + redraw! +" call Decho('considering <'.aicmmnt.'> scriptid='.scriptid.' srcid='.srcid) + echomsg 'considering <'.aicmmnt.'> scriptid='.scriptid.' srcid='.srcid + + " grab a copy of the plugin's vim.sf.net webpage + let scriptaddr = 'http://vim.sf.net/script.php?script_id='.scriptid + let tmpfile = tempname() + let v:errmsg = "" + + " make up to three tries at downloading the description + let itry= 1 + while itry <= 3 +" call Decho("try#".itry." to download description of <".aicmmnt."> with addr=".scriptaddr) + if has("win32") || has("win16") || has("win95") +" call Decho("new|exe silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".g:getscript_shq.tmpfile.g:getscript_shq.' '.g:getscript_shq.scriptaddr.g:getscript_shq."|q!") + new|exe "silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".g:getscript_shq.tmpfile.g:getscript_shq.' '.g:getscript_shq.scriptaddr.g:getscript_shq|q! + else +" call Decho("exe silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".g:getscript_shq.tmpfile.g:getscript_shq." ".g:getscript_shq.scriptaddr.g:getscript_shq) + exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".g:getscript_shq.tmpfile.g:getscript_shq." ".g:getscript_shq.scriptaddr.g:getscript_shq + endif + if itry == 1 + exe "silent vsplit ".tmpfile + else + silent! e % + endif + + " find the latest source-id in the plugin's webpage + silent! 1 + let findpkg= search('Click on the package to download','W') + if findpkg > 0 + break + endif + let itry= itry + 1 + endwhile +" call Decho(" --- end downloading tries while loop --- itry=".itry) + + " testing: did finding "Click on the package..." fail? + if findpkg == 0 || itry >= 4 + silent q! + call delete(tmpfile) + " restore options + let &t_ti = t_ti + let &t_te = t_te + let &rs = rs + let s:downerrors = s:downerrors + 1 +" call Decho("***warning*** couldn'".'t find "Click on the package..." in description page for <'.aicmmnt.">") + echomsg "***warning*** couldn'".'t find "Click on the package..." in description page for <'.aicmmnt.">" +" call Dret("GetOneScript : srch for /Click on the package/ failed") + let @a= rega + return + endif +" call Decho('found "Click on the package to download"') + + let findsrcid= search('src_id=','W') + if findsrcid == 0 + silent q! + call delete(tmpfile) + " restore options + let &t_ti = t_ti + let &t_te = t_te + let &rs = rs + let s:downerrors = s:downerrors + 1 +" call Decho("***warning*** couldn'".'t find "src_id=" in description page for <'.aicmmnt.">") + echomsg "***warning*** couldn'".'t find "src_id=" in description page for <'.aicmmnt.">" + let @a= rega +" call Dret("GetOneScript : srch for /src_id/ failed") + return + endif +" call Decho('found "src_id=" in description page') + + let srcidpat = '^\s*\([^<]\+\)<.*$' + let latestsrcid= substitute(getline("."),srcidpat,'\1','') + let sname = substitute(getline("."),srcidpat,'\2','') " script name actually downloaded +" call Decho("srcidpat<".srcidpat."> latestsrcid<".latestsrcid."> sname<".sname.">") + silent q! + call delete(tmpfile) + + " convert the strings-of-numbers into numbers + let srcid = srcid + 0 + let latestsrcid = latestsrcid + 0 +" call Decho("srcid=".srcid." latestsrcid=".latestsrcid." sname<".sname.">") + + " has the plugin's most-recent srcid increased, which indicates + " that it has been updated + if latestsrcid > srcid +" call Decho("[latestsrcid=".latestsrcid."] <= [srcid=".srcid."]: need to update <".sname.">") + + let s:downloads= s:downloads + 1 + if sname == bufname("%") + " GetLatestVimScript has to be careful about downloading itself + let sname= "NEW_".sname + endif + + " the plugin has been updated since we last obtained it, so download a new copy +" call Decho("...downloading new <".sname.">") + echomsg "...downloading new <".sname.">" + if has("win32") || has("win16") || has("win95") +" call Decho("new|exe silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".g:getscript_shq.sname.g:getscript_shq." ".g:getscript_shq.'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid.g:getscript_shq."|q") + new|exe "silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".g:getscript_shq.sname.g:getscript_shq." ".g:getscript_shq.'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid.g:getscript_shq|q + else +" call Decho("silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".g:getscript_shq.sname.g:getscript_shq." ".g:getscript_shq.'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid.g:getscript_shq) + exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".g:getscript_shq.sname.g:getscript_shq." ".g:getscript_shq.'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid.g:getscript_shq + endif + + " AutoInstall: only if doautoinstall has been requested by the plugin itself + if doautoinstall +" call Decho("attempting to do autoinstall: getcwd<".getcwd()."> filereadable(".sname.")=".filereadable(sname)) + if filereadable(sname) +" call Decho("silent !".g:GetLatestVimScripts_mv." ".g:getscript_shq.sname.g:getscript_shq." ".g:getscript_shq.s:autoinstall.g:getscript_shq) + exe "silent !".g:GetLatestVimScripts_mv." ".g:getscript_shq.sname.g:getscript_shq." ".g:getscript_shq.s:autoinstall.g:getscript_shq + let curdir = escape(substitute(getcwd(),'\','/','ge'),"|[]*'\" #") + let installdir= curdir."/Installed" + if !isdirectory(installdir) + call mkdir(installdir) + endif +" call Decho("exe cd ".s:autoinstall) + exe "cd ".escape(s:autoinstall,' ') + + " decompress + if sname =~ '\.bz2$' +" call Decho("decompress: attempt to bunzip2 ".sname) + exe "silent !bunzip2 ".g:getscript_shq.sname.g:getscript_shq + let sname= substitute(sname,'\.bz2$','','') +" call Decho("decompress: new sname<".sname."> after bunzip2") + elseif sname =~ '\.gz$' +" call Decho("decompress: attempt to gunzip ".sname) + exe "silent !gunzip ".g:getscript_shq.sname.g:getscript_shq + let sname= substitute(sname,'\.gz$','','') +" call Decho("decompress: new sname<".sname."> after gunzip") + endif + + " distribute archive(.zip, .tar, .vba) contents + if sname =~ '\.zip$' +" call Decho("dearchive: attempt to unzip ".sname) + exe "silent !unzip -o ".g:getscript_shq.sname.g:getscript_shq + elseif sname =~ '\.tar$' +" call Decho("dearchive: attempt to untar ".sname) + exe "silent !tar -xvf ".g:getscript_shq.sname.g:getscript_shq + elseif sname =~ '\.vba$' +" call Decho("dearchive: attempt to handle a vimball: ".sname) + silent 1split + exe "silent e ".escape(sname,' ') + silent so % + silent q + endif + + if sname =~ '.vim$' +" call Decho("dearchive: attempt to simply move ".sname." to plugin") + exe "silent !".g:GetLatestVimScripts_mv." ".g:getscript_shq.sname.g:getscript_shq." plugin" + else +" call Decho("dearchive: move <".sname."> to installdir<".installdir.">") + exe "silent !".g:GetLatestVimScripts_mv." ".g:getscript_shq.sname.g:getscript_shq." ".installdir + endif + + " helptags step + let docdir= substitute(&rtp,',.*','','e')."/doc" +" call Decho("helptags: docdir<".docdir.">") + exe "helptags ".docdir + exe "cd ".curdir + endif + if fname !~ ':AutoInstall:' + let modline=scriptid." ".latestsrcid." :AutoInstall: ".fname.cmmnt + else + let modline=scriptid." ".latestsrcid." ".fname.cmmnt + endif + else + let modline=scriptid." ".latestsrcid." ".fname.cmmnt + endif + + " update the data in the file + call setline(line("."),modline) +" call Decho("update data in ".expand("%")."#".line(".").": modline<".modline.">") +" else " Decho +" call Decho("[latestsrcid=".latestsrcid."] <= [srcid=".srcid."], no need to update") + endif + + " restore options + let &t_ti = t_ti + let &t_te = t_te + let &rs = rs + let @a = rega + +" call Dret("GetOneScript") +endfun + +" --------------------------------------------------------------------- +" GetLatestVimScripts: this function gets the latest versions of {{{1 +" scripts based on the list in +" (first dir in runtimepath)/GetLatest/GetLatestVimScripts.dat +fun! getscript#GetLatestVimScripts() +" call Dfunc("GetLatestVimScripts() autoinstall<".s:autoinstall.">") + +" insure that wget is executable + if executable(g:GetLatestVimScripts_wget) != 1 + echoerr "GetLatestVimScripts needs ".g:GetLatestVimScripts_wget." which apparently is not available on your system" +" call Dret("GetLatestVimScripts : wget not executable/availble") + return + endif + + " Find the .../GetLatest subdirectory under the runtimepath + for datadir in split(&rtp,',') + [''] + if isdirectory(datadir."/GetLatest") +" call Decho("found directory<".datadir.">") + let datadir= datadir . "/GetLatest" + break + endif + if filereadable(datadir."GetLatestVimScripts.dat") +" call Decho("found ".datadir."/GetLatestVimScripts.dat") + break + endif + endfor + + " Sanity checks: readability and writability + if datadir == "" + echoerr 'Missing "GetLatest/" on your runtimepath - see :help glvs-dist-install' +" call Dret("GetLatestVimScripts : unable to find a GetLatest subdirectory") + return + endif + + if filewritable(datadir) != 2 + echoerr "(getLatestVimScripts) Your ".datadir." isn't writable" +" call Dret("GetLatestVimScripts : non-writable directory<".datadir.">") + return + endif + let datafile= datadir."/GetLatestVimScripts.dat" + if !filereadable(datafile) + echoerr "Your data file<".datafile."> isn't readable" +" call Dret("GetLatestVimScripts : non-readable datafile<".datafile.">") + return + endif + if !filewritable(datafile) + echoerr "Your data file<".datafile."> isn't writable" +" call Dret("GetLatestVimScripts : non-writable datafile<".datafile.">") + return + endif +" call Decho("datadir <".datadir.">") +" call Decho("datafile <".datafile.">") + + " don't let any events interfere (like winmanager's, taglist's, etc) + let eikeep= &ei + set ei=all + + " record current directory, change to datadir, open split window with + " datafile + let origdir= getcwd() + exe "cd ".escape(substitute(datadir,'\','/','ge'),"|[]*'\" #") + split + exe "e ".escape(substitute(datafile,'\','/','ge'),"|[]*'\" #") + res 1000 + let s:downloads = 0 + let s:downerrors= 0 + + " Check on dependencies mentioned in plugins +" call Decho(" ") +" call Decho("searching plugins for GetLatestVimScripts dependencies") + let lastline = line("$") +" call Decho("lastline#".lastline) + let plugins = split(globpath(&rtp,"plugin/*.vim"),'\n') + let foundscript = 0 + let firstdir= "" + + for plugin in plugins + + " don't process plugins in system directories + if firstdir == "" + let firstdir= substitute(plugin,'[/\\][^/\\]\+$','','') +" call Decho("setting firstdir<".firstdir.">") + else + let curdir= substitute(plugin,'[/\\][^/\\]\+$','','') +" call Decho("curdir<".curdir.">") + if curdir != firstdir +" call Decho("skipping subsequent plugins: curdir<".curdir."> != firstdir<".firstdir.">") + break + endif + endif + + " read plugin in + $ +" call Decho(" ") +" call Decho(".dependency checking<".plugin."> line$=".line("$")) + exe "silent r ".escape(plugin,"[]#*$%'\" ?`!&();<>\\") + + while search('^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+','W') != 0 + let newscript= substitute(getline("."),'^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+\s\+\(.*\)$','\1','e') + let llp1 = lastline+1 +" call Decho("..newscript<".newscript.">") + + " don't process ""GetLatestVimScripts lines -- those that have been doubly-commented out + if newscript !~ '^"' + " found a "GetLatestVimScripts: # #" line in the script; check if its already in the datafile + let curline = line(".") + let noai_script = substitute(newscript,'\s*:AutoInstall:\s*','','e') + exe llp1 + let srchline = search('\<'.noai_script.'\>','bW') +" call Decho("..noai_script<".noai_script."> srch=".srchline."curline#".line(".")." lastline#".lastline) + + if srchline == 0 + " found a new script to permanently include in the datafile + let keep_rega = @a + let @a = substitute(getline(curline),'^"\s\+GetLatestVimScripts:\s\+','','') + exe lastline."put a" + echomsg "Appending <".@a."> to ".datafile." for ".newscript +" call Decho("..APPEND (".noai_script.")<".@a."> to GetLatestVimScripts.dat") + let @a = keep_rega + let lastline = llp1 + let curline = curline + 1 + let foundscript = foundscript + 1 +" else " Decho +" call Decho("..found <".noai_script."> (already in datafile at line#".srchline.")") + endif + + let curline = curline + 1 + exe curline + endif + endwhile + + let llp1= lastline + 1 +" call Decho(".deleting lines: ".llp1.",$d") + exe "silent! ".llp1.",$d" + endfor +" call Decho("--- end dependency checking loop --- foundscript=".foundscript) +" call Decho(" ") + + if foundscript == 0 + setlocal nomod + endif + + " Check on out-of-date scripts using GetLatest/GetLatestVimScripts.dat +" call Decho("begin: checking out-of-date scripts using datafile<".datafile.">") + setlocal lz + 1 +" /^-----/,$g/^\s*\d/call Decho(getline(".")) + 1 + /^-----/,$g/^\s*\d/call s:GetOneScript() +" call Decho("--- end out-of-date checking --- ") + + " Final report (an echomsg) + try + silent! ?^-------? + catch /^Vim\%((\a\+)\)\=:E114/ +" call Dret("GetLatestVimScripts : nothing done!") + return + endtry + exe "norm! kz\" + redraw! + let s:msg = "" + if s:downloads == 1 + let s:msg = "Downloaded one updated script to <".datadir.">" + elseif s:downloads == 2 + let s:msg= "Downloaded two updated scripts to <".datadir.">" + elseif s:downloads > 1 + let s:msg= "Downloaded ".s:downloads." updated scripts to <".datadir.">" + else + let s:msg= "Everything was already current" + endif + if s:downerrors > 0 + let s:msg= s:msg." (".s:downerrors." downloading errors)" + endif + echomsg s:msg + " save the file + if &mod + silent! w! + endif + q + + " restore events and current directory + exe "cd ".escape(substitute(origdir,'\','/','ge'),"|[]*'\" #") + let &ei= eikeep + setlocal nolz +" call Dret("GetLatestVimScripts : did ".s:downloads." downloads") +endfun + +" --------------------------------------------------------------------- +" Restore Options: {{{1 +let &cpo= s:keepcpo +unlet s:keepcpo + +" --------------------------------------------------------------------- +" Modelines: {{{1 +" vim: ts=8 sts=2 fdm=marker nowrap diff --git a/vimfiles/autoload/netrw.vim b/vimfiles/autoload/netrw.vim index 4eae080..3734b69 100644 --- a/vimfiles/autoload/netrw.vim +++ b/vimfiles/autoload/netrw.vim @@ -1,7 +1,7 @@ " netrw.vim: Handles file transfer and remote directory listing across " AUTOLOAD SECTION -" Date: Dec 12, 2007 -" Version: 116 +" Date: Feb 26, 2008 +" Version: 122 " Maintainer: Charles E Campbell, Jr " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 1999-2007 Charles E. Campbell, Jr. {{{1 @@ -9,13 +9,11 @@ " with or without modifications, provided that this copyright " notice is copied with it. Like anything else that's free, " netrw.vim, netrwPlugin.vim, and netrwSettings.vim are provided -" *as is* and comes with no warranty of any kind, either +" *as is* and come 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 of this software. -" of this software. -" note: worked with tmpfile s:GetTempname() in NetRead() NetWrite() -"redraw!|call inputsave()|call input("Press to continue")|call inputrestore() +"redraw!|call DechoSep()|call inputsave()|call input("Press to continue")|call inputrestore() " " But be doers of the Word, and not only hearers, deluding your own selves {{{1 " (James 1:22 RSV) @@ -29,7 +27,7 @@ if !exists("s:NOTE") let s:WARNING = 1 let s:ERROR = 2 endif -let g:loaded_netrw = "v116" +let g:loaded_netrw = "v122" if v:version < 700 call netrw#ErrorMsg(s:WARNING,"you need vim version 7.0 or later for version ".g:loaded_netrw." of netrw",1) finish @@ -152,6 +150,9 @@ endif if !exists("g:netrw_dirhistmax") let g:netrw_dirhistmax= 10 endif +if !exists("g:netrw_fastbrowse") + let g:netrw_fastbrowse= 1 +endif if !exists("g:netrw_ftp_browse_reject") let g:netrw_ftp_browse_reject='^total\s\+\d\+$\|^Trying\s\+\d\+.*$\|^KERBEROS_V\d rejected\|^Security extensions not\|No such file\|: connect to address [0-9a-fA-F:]*: No route to host$' endif @@ -245,6 +246,9 @@ if g:netrw_liststyle == s:LONGLIST && g:netrw_scp_cmd !~ '^pscp' let g:netrw_list_cmd= g:netrw_list_cmd." -l" endif " Default values - m-r ---------- {{{3 +if !exists("g:netrw_markfileesc") + let g:netrw_markfileesc= '*./[\~' +endif if !exists("g:netrw_maxfilenamelen") let g:netrw_maxfilenamelen= 32 endif @@ -261,8 +265,8 @@ if !exists("g:netrw_mousemaps") let g:netrw_mousemaps= 0 endif endif -if !exists("g:netrw_noretmap") - let g:netrw_noretmap= 0 +if !exists("g:netrw_retmap") + let g:netrw_retmap= 0 endif if !exists("g:netrw_preview") let g:netrw_preview= 0 @@ -291,9 +295,6 @@ if exists("g:netrw_silent") && g:netrw_silent != 0 else let g:netrw_silentxfer= "" endif -if !exists("g:netrw_fastbrowse") - let g:netrw_fastbrowse= 1 -endif if !exists("g:netrw_shq") if exists("&shq") && &shq != "" let g:netrw_shq= &shq @@ -319,7 +320,10 @@ if !exists("g:netrw_sort_direction") let g:netrw_sort_direction= "normal" endif if !exists("g:netrw_sort_sequence") - let g:netrw_sort_sequence= '[\/]$,\.h$,\.c$,\.cpp$,\.[a-np-z]$,*,\.info$,\.swp$,\.o$\.obj$,\.bak$' + let g:netrw_sort_sequence= '[\/]$,\.h$,\.c$,\.cpp$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$' +endif +if !exists("g:netrw_special_syntax") + let g:netrw_special_syntax= 0 endif if !exists("g:netrw_ssh_browse_reject") let g:netrw_ssh_browse_reject='^total\s\+\d\+$' @@ -375,68 +379,6 @@ endif " ============================== " ------------------------------------------------------------------------ -" netrw#NetrwSavePosn: saves position of cursor on screen {{{2 -fun! netrw#NetrwSavePosn() -" call Dfunc("netrw#NetrwSavePosn()") - " Save current line and column - let w:netrw_winnr= winnr() - let w:netrw_line = line(".") - let w:netrw_col = virtcol(".") - - " Save top-of-screen line - norm! H0 - let w:netrw_hline= line(".") - - " set up string holding position parameters - let ret = "let w:netrw_winnr=".w:netrw_winnr."|let w:netrw_line=".w:netrw_line."|let w:netrw_col=".w:netrw_col."|let w:netrw_hline=".w:netrw_hline - - call netrw#NetrwRestorePosn() -" call Dret("netrw#NetrwSavePosn : winnr=".w:netrw_winnr." line=".w:netrw_line." col=".w:netrw_col." hline=".w:netrw_hline) - return ret -endfun - -" ------------------------------------------------------------------------ -" netrw#NetrwRestorePosn: restores the cursor and file position as saved by NetrwSavePosn() {{{2 -fun! netrw#NetrwRestorePosn(...) -" call Dfunc("netrw#NetrwRestorePosn() a:0=".a:0." winnr=".(exists("w:netrw_winnr")? w:netrw_winnr : -1)." line=".(exists("w:netrw_line")? w:netrw_line : -1)." col=".(exists("w:netrw_col")? w:netrw_col : -1)." hline=".(exists("w:netrw_hline")? w:netrw_hline : -1)) - let eikeep= &ei - set ei=all - if expand("%") == "NetrwMessage" - exe s:winBeforeErr."wincmd w" - endif - - if a:0 > 0 - exe a:1 - endif - - " restore window - if exists("w:netrw_winnr") -" call Decho("restore window: exe silent! ".w:netrw_winnr."wincmd w") - exe "silent! ".w:netrw_winnr."wincmd w" - endif - if v:shell_error == 0 - " as suggested by Bram M: redraw on no error - " allows protocol error messages to remain visible - redraw! - endif - - " restore top-of-screen line - if exists("w:netrw_hline") -" call Decho("restore topofscreen: exe norm! ".w:netrw_hline."G0z") - exe "norm! ".w:netrw_hline."G0z\" - endif - - " restore position - if exists("w:netrw_line") && exists("w:netrw_col") -" call Decho("restore posn: exe norm! ".w:netrw_line."G0".w:netrw_col."|") - exe "norm! ".w:netrw_line."G0".w:netrw_col."\" - endif - - let &ei= eikeep -" call Dret("netrw#NetrwRestorePosn") -endfun - -" --------------------------------------------------------------------- " s:NetrwOptionSave: save options and set to "standard" form {{{2 " 06/08/07 : removed call to NetrwSafeOptions(), either placed " immediately after NetrwOptionSave() calls in NetRead @@ -444,7 +386,7 @@ endfun " NetrwBrowse. " vt: normally its "w:" or "s:" (a variable type) fun! s:NetrwOptionSave(vt) -" call Dfunc("s:NetrwOptionSave(vt<".a:vt.">) win#".winnr()." buf#".bufnr(".")."<".bufname(bufnr(".")).">") +" call Dfunc("s:NetrwOptionSave(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%")).">") " call Decho(a:vt."netrw_optionsave".(exists("{a:vt}netrw_optionsave")? ("=".{a:vt}netrw_optionsave) : " doesn't exist")) if !exists("{a:vt}netrw_optionsave") @@ -484,14 +426,15 @@ fun! s:NetrwOptionSave(vt) if &go =~ 'a' | silent! let {a:vt}netrw_regstar = @* | endif silent! let {a:vt}netrw_regslash= @/ -" call Dret("s:NetrwOptionSave : win#".winnr()." buf#".bufnr(".")) +" call Dret("s:NetrwOptionSave : win#".winnr()." buf#".bufnr("%")) endfun " ------------------------------------------------------------------------ " s:NetrwOptionRestore: restore options {{{2 fun! s:NetrwOptionRestore(vt) -" call Dfunc("s:NetrwOptionRestore(vt<".a:vt.">) win#".winnr()." buf#".bufnr(".")) +" call Dfunc("s:NetrwOptionRestore(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")) if !exists("{a:vt}netrw_optionsave") +" call Decho("ro=".&ro." ma=".&ma." mod=".&mod." wrap=".&wrap) " call Dret("s:NetrwOptionRestore : ".a:vt."netrw_optionsave doesn't exist") return endif @@ -505,7 +448,7 @@ fun! s:NetrwOptionRestore(vt) unlet {a:vt}netrw_acdkeep if &l:acd " call Decho("exe cd ".escape(curdir,g:netrw_fname_escape)) - exe "cd ".escape(curdir,g:netrw_fname_escape) + exe "lcd ".escape(curdir,g:netrw_fname_escape) endif endif endif @@ -516,7 +459,11 @@ fun! s:NetrwOptionRestore(vt) if exists("{a:vt}netrw_cinokeep") |let &l:cino = {a:vt}netrw_cinokeep |unlet {a:vt}netrw_cinokeep |endif if exists("{a:vt}netrw_comkeep") |let &l:com = {a:vt}netrw_comkeep |unlet {a:vt}netrw_comkeep |endif if exists("{a:vt}netrw_cpokeep") |let &l:cpo = {a:vt}netrw_cpokeep |unlet {a:vt}netrw_cpokeep |endif - if exists("{a:vt}netrw_dirkeep") |exe "lcd ".{a:vt}netrw_dirkeep |unlet {a:vt}netrw_dirkeep |endif + if exists("{a:vt}netrw_dirkeep") && isdirectory({a:vt}netrw_dirkeep) && g:netrw_keepdir + let dirkeep = substitute({a:vt}netrw_dirkeep,'\\','/','g') + let dirkeep = escape(dirkeep,g:netrw_cd_escape) + if exists("{a:vt}netrw_dirkeep") |exe "lcd ".dirkeep|unlet {a:vt}netrw_dirkeep |endif + endif if exists("{a:vt}netrw_fokeep") |let &l:fo = {a:vt}netrw_fokeep |unlet {a:vt}netrw_fokeep |endif if exists("{a:vt}netrw_gdkeep") |let &l:gd = {a:vt}netrw_gdkeep |unlet {a:vt}netrw_gdkeep |endif if exists("{a:vt}netrw_hidkeep") |let &l:hidden = {a:vt}netrw_hidkeep |unlet {a:vt}netrw_hidkeep |endif @@ -546,13 +493,14 @@ fun! s:NetrwOptionRestore(vt) " call Decho("g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd) " call Decho("fo=".&fo.(exists("&acd")? " acd=".&acd : " acd doesn't exist")) -" call Dret("s:NetrwOptionRestore : win#".winnr()." buf#".bufnr(".")) +" call Decho("ro=".&ro." ma=".&ma." mod=".&mod." wrap=".&wrap) +" call Dret("s:NetrwOptionRestore : win#".winnr()." buf#".bufnr("%")) endfun " --------------------------------------------------------------------- " s:NetrwSafeOptions: sets options to help netrw do its job {{{2 fun! s:NetrwSafeOptions() -" call Dfunc("s:NetrwSafeOptions() win#".winnr()." buf#".bufnr(".")."<".bufname(bufnr(".")).">") +" call Dfunc("s:NetrwSafeOptions() win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%")).">") " call Decho("window's ft=".&ft) setlocal cino= setlocal com= @@ -1358,6 +1306,7 @@ fun! s:NetrwGetFile(readcmd, tfile, method) " readcmd=='t': simply do nothing if a:readcmd == 't' +" call Decho("ro=".&ro." ma=".&ma." mod=".&mod." wrap=".&wrap) " call Dret("NetrwGetFile : skip read of <".a:tfile.">") return endif @@ -1381,8 +1330,8 @@ fun! s:NetrwGetFile(readcmd, tfile, method) else let tfile= a:tfile endif -" call Decho("keepalt exe file ".tfile) - keepalt exe "silent! keepalt file ".tfile +" " call Decho("exe silent! keepalt file ".tfile) + exe "silent! keepalt file ".tfile " edit temporary file (ie. read the temporary file in) if rfile =~ '\.zip$' @@ -1403,6 +1352,7 @@ fun! s:NetrwGetFile(readcmd, tfile, method) endif " rename buffer back to remote filename +" call Decho("exe silent! keepalt file ".escape(rfile,' ')) exe "silent! keepalt file ".escape(rfile,' ') filetype detect " call Dredir("renamed buffer back to remote filename<".rfile."> : expand(%)<".expand("%").">","ls!") @@ -1421,6 +1371,7 @@ fun! s:NetrwGetFile(readcmd, tfile, method) else " not readable +" call Decho("ro=".&ro." ma=".&ma." mod=".&mod." wrap=".&wrap) " call Decho("tfile<".a:tfile."> not readable") call netrw#ErrorMsg(s:WARNING,"file <".a:tfile."> not readable",9) " call Dret("NetrwGetFile : tfile<".a:tfile."> not readable") @@ -1443,7 +1394,9 @@ fun! s:NetrwGetFile(readcmd, tfile, method) " call Decho("readcmd<".a:readcmd."> cmdarg<".v:cmdarg."> tfile<".a:tfile."> readable=".s:FileReadable(a:tfile)) " make sure file is being displayed - redraw! +" redraw! + +" call Decho("ro=".&ro." ma=".&ma." mod=".&mod." wrap=".&wrap) " call Dret("NetrwGetFile") endfun @@ -1709,15 +1662,19 @@ fun! s:BrowserMaps(islocal) nnoremap md :call NetrwMarkFileDiff(1) nnoremap me :call NetrwMarkFileEdit(1) nnoremap mf :call NetrwMarkFile(1,NetrwGetWord()) + nnoremap mh :call NetrwMarkHideSfx(1) nnoremap mm :call NetrwMarkFileMove(1) nnoremap mp :call NetrwMarkFilePrint(1) nnoremap mr :call NetrwMarkFileRegexp(1) + nnoremap ms :call NetrwMarkFileSource(1) nnoremap mT :call NetrwMarkFileTag(1) nnoremap mt :call NetrwMarkFileTgt(1) + nnoremap mu :call NetrwUnMarkFile(1) nnoremap mx :call NetrwMarkFileExe(1) nnoremap mz :call NetrwMarkFileCompress(1) nnoremap gb :call NetrwBookmarkDir(1,b:netrw_curdir) - nnoremap c :exe "cd ".escape(b:netrw_curdir,g:netrw_cd_escape) + nnoremap gh :call NetrwHidden(1) + nnoremap c :exe "lcd ".escape(b:netrw_curdir,g:netrw_cd_escape) nnoremap C :let g:netrw_chgwin= winnr() nnoremap d :call NetrwMakeDir("") nnoremap i :call NetrwListStyle(1) @@ -1725,7 +1682,8 @@ fun! s:BrowserMaps(islocal) nnoremap O :call NetrwObtain(0) nnoremap p :call NetrwPreview(NetrwBrowseChgDir(1,NetrwGetWord(),1)) nnoremap P :call NetrwPrevWinOpen(1) - nnoremap q :call NetrwBookmarkDir(2,b:netrw_curdir) + nnoremap qb :call NetrwBookmarkDir(2,b:netrw_curdir) + nnoremap qf :call NetrwFileInfo(1,NetrwGetWord()) nnoremap r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'exe "norm! 0"call NetrwRefresh(1,NetrwBrowseChgDir(1,'./')) nnoremap s :call NetrwSortStyle(1) nnoremap S :call NetSortSequence(1) @@ -1775,21 +1733,26 @@ fun! s:BrowserMaps(islocal) nnoremap md :call NetrwMarkFileDiff(0) nnoremap me :call NetrwMarkFileEdit(0) nnoremap mf :call NetrwMarkFile(0,NetrwGetWord()) + nnoremap mh :call NetrwMarkHideSfx(0) nnoremap mm :call NetrwMarkFileMove(0) nnoremap mp :call NetrwMarkFilePrint(0) nnoremap mr :call NetrwMarkFileRegexp(0) + nnoremap ms :call NetrwMarkFileSource(0) nnoremap mT :call NetrwMarkFileTag(0) nnoremap mt :call NetrwMarkFileTgt(0) + nnoremap mu :call NetrwUnMarkFile(0) nnoremap mx :call NetrwMarkFileExe(0) nnoremap mz :call NetrwMarkFileCompress(0) nnoremap gb :call NetrwBookmarkDir(1,b:netrw_cur) + nnoremap gh :call NetrwHidden(0) nnoremap C :let g:netrw_chgwin= winnr() nnoremap i :call NetrwListStyle(0) nnoremap o :call NetrwSplit(0) nnoremap O :call NetrwObtain(0) nnoremap p :call NetrwPreview(NetrwBrowseChgDir(1,NetrwGetWord(),1)) nnoremap P :call NetrwPrevWinOpen(0) - nnoremap q :call NetrwBookmarkDir(2,b:netrw_curdir) + nnoremap qb :call NetrwBookmarkDir(2,b:netrw_curdir) + nnoremap qf :call NetrwFileInfo(0,NetrwGetWord()) nnoremap r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'exe "norm! 0"call NetrwBrowse(0,NetrwBrowseChgDir(0,'./')) nnoremap s :call NetrwSortStyle(0) nnoremap S :call NetSortSequence(0) @@ -1826,6 +1789,158 @@ fun! s:BrowserMaps(islocal) " call Dret("s:BrowserMaps") endfun +" --------------------------------------------------------------------- +" s:ExplorePatHls: converts an Explore pattern into a regular expression search pattern {{{2 +fun! s:ExplorePatHls(pattern) +" call Dfunc("s:ExplorePatHls(pattern<".a:pattern.">)") + let repat= substitute(a:pattern,'^**/\{1,2}','','') +" call Decho("repat<".repat.">") + let repat= escape(repat,'][.\') +" call Decho("repat<".repat.">") + let repat= '\<'.substitute(repat,'\*','\\(\\S\\+ \\)*\\S\\+','g').'\>' +" call Dret("s:ExplorePatHls repat<".repat.">") + return repat +endfun + +" --------------------------------------------------------------------- +" s:NetrwBookmarkDir: {{{2 +" 0: (user: ) bookmark current directory +" 1: (user: ) change to the bookmarked directory +" 2: (user: ) list bookmarks +" 3: (browsing) record current directory history +" 4: (user: ) go up (previous) bookmark +" 5: (user: ) go down (next) bookmark +fun! s:NetrwBookmarkDir(chg,curdir) +" call Dfunc("NetrwBookmarkDir(chg=".a:chg." curdir<".a:curdir.">) cnt=".v:count." bookmarkcnt=".g:NETRW_BOOKMARKMAX." histcnt=".g:NETRW_DIRHIST_CNT." bookmax=".g:NETRW_BOOKMARKMAX." histmax=".g:netrw_dirhistmax) + + if a:chg == 0 + " bookmark the current directory +" call Decho("(user: ) bookmark the current directory") + if v:count > 0 + " handle bookmark# specified via the count + let g:NETRW_BOOKMARKDIR_{v:count}= a:curdir + if !exists("g:NETRW_BOOKMARKMAX") + let g:NETRW_BOOKMARKMAX= v:count + elseif v:count > g:NETRW_BOOKMARKMAX + let g:NETRW_BOOKMARKMAX= v:count + endif + else + " handle no count specified + let g:NETRW_BOOKMARKMAX = g:NETRW_BOOKMARKMAX + 1 + let g:NETRW_BOOKMARKDIR_{g:NETRW_BOOKMARKMAX} = a:curdir + endif + echo "bookmarked the current directory" + + elseif a:chg == 1 + " change to the bookmarked directory +" call Decho("(user: ) change to the bookmarked directory") + if exists("g:NETRW_BOOKMARKDIR_{v:count}") + exe "e ".g:NETRW_BOOKMARKDIR_{v:count} + else + echomsg "Sorry, bookmark#".v:count." doesn't exist!" + endif + + elseif a:chg == 2 +" redraw! + let didwork= 0 + " list user's bookmarks +" call Decho("(user: ) list user's bookmarks") + if exists("g:NETRW_BOOKMARKMAX") +" call Decho("list bookmarks [0,".g:NETRW_BOOKMARKMAX."]") + let cnt= 0 + while cnt <= g:NETRW_BOOKMARKMAX + if exists("g:NETRW_BOOKMARKDIR_{cnt}") +" call Decho("Netrw Bookmark#".cnt.": ".g:NETRW_BOOKMARKDIR_{cnt}) + echo "Netrw Bookmark#".cnt.": ".g:NETRW_BOOKMARKDIR_{cnt} + let didwork= 1 + endif + let cnt= cnt + 1 + endwhile + endif + + " list directory history + let cnt = g:NETRW_DIRHIST_CNT + let first = 1 + let histcnt = 0 + while ( first || cnt != g:NETRW_DIRHIST_CNT ) +" call Decho("first=".first." cnt=".cnt." dirhist_cnt=".g:NETRW_DIRHIST_CNT) + let histcnt= histcnt + 1 + if exists("g:NETRW_DIRHIST_{cnt}") +" call Decho("Netrw History#".histcnt.": ".g:NETRW_DIRHIST_{cnt}) + echo "Netrw History#".histcnt.": ".g:NETRW_DIRHIST_{cnt} + let didwork= 1 + endif + let first = 0 + let cnt = ( cnt - 1 ) % g:netrw_dirhistmax + if cnt < 0 + let cnt= cnt + g:netrw_dirhistmax + endif + endwhile + if didwork + call inputsave()|call input("Press to continue")|call inputrestore() + endif + + elseif a:chg == 3 + " saves most recently visited directories (when they differ) +" call Decho("(browsing) record curdir history") + if !exists("g:NETRW_DIRHIST_0") || g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT} != a:curdir + let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT + 1 ) % g:netrw_dirhistmax +" let g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}= substitute(a:curdir,'[/\\]$','','e') + let g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}= a:curdir +" call Decho("save dirhist#".g:NETRW_DIRHIST_CNT."<".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}.">") + endif + + elseif a:chg == 4 + " u: change to the previous directory stored on the history list +" call Decho("(user: ) chg to prev dir from history") + let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT - 1 ) % g:netrw_dirhistmax + if g:NETRW_DIRHIST_CNT < 0 + let g:NETRW_DIRHIST_CNT= g:NETRW_DIRHIST_CNT + g:netrw_dirhistmax + endif + if exists("g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}") +" call Decho("changedir u#".g:NETRW_DIRHIST_CNT."<".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}.">") + if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir") + setlocal ma noro +" call Decho("setlocal ma noro") + %d + setlocal nomod +" call Decho("setlocal nomod") + endif +" call Decho("exe e! ".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}) + exe "e! ".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT} + else + let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT + 1 ) % g:netrw_dirhistmax + echo "Sorry, no predecessor directory exists yet" + endif + + elseif a:chg == 5 + " U: change to the subsequent directory stored on the history list +" call Decho("(user: ) chg to next dir from history") + let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT + 1 ) % g:netrw_dirhistmax + if exists("g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}") +" call Decho("changedir U#".g:NETRW_DIRHIST_CNT."<".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}.">") + if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir") + setlocal ma noro +" call Decho("setlocal ma noro") + %d +" call Decho("removed all lines from buffer (%d)") + setlocal nomod +" call Decho("setlocal nomod") + endif +" call Decho("exe e! ".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}) + exe "e! ".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT} + else + let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT - 1 ) % g:netrw_dirhistmax + if g:NETRW_DIRHIST_CNT < 0 + let g:NETRW_DIRHIST_CNT= g:NETRW_DIRHIST_CNT + g:netrw_dirhistmax + endif + echo "Sorry, no successor directory exists yet" + endif + endif + call s:NetrwBookmarkMenu() +" call Dret("NetrwBookmarkDir") +endfun + " --------------------------------------------------------------------- " s:NetrwBrowse: This function uses the command in g:netrw_list_cmd to provide a {{{2 " list of the contents of a local or remote directory. It is assumed that the @@ -1833,30 +1948,29 @@ endfun " with the requested remote hostname first. fun! s:NetrwBrowse(islocal,dirname) if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif -" call Dfunc("NetrwBrowse(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".w:netrw_liststyle." ".g:loaded_netrw." buf#".bufnr("%")."<".bufname("%").">") +" call Dfunc("s:NetrwBrowse(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".w:netrw_liststyle." ".g:loaded_netrw." buf#".bufnr("%")."<".bufname("%").">") " call Dredir("ls!") if exists("s:netrw_skipbrowse") unlet s:netrw_skipbrowse -" call Dret("NetrwBrowse : s:netrw_skipbrowse=".s:netrw_skipbrowse) +" call Decho("ro=".&ro." ma=".&ma." mod=".&mod." wrap=".&wrap) +" call Dret("s:NetrwBrowse : s:netrw_skipbrowse=".s:netrw_skipbrowse) return endif call s:NetrwOptionSave("w:") call s:NetrwSafeOptions() - " clear any marked files - if exists("s:netrwmarkfilelist") + " re-instate any marked files + if exists("s:netrwmarkfilelist_{bufnr('%')}") " call Decho("clearing marked files") - unlet s:netrwmarkfilelist - unlet s:netrwmarkfilemtch - 2match none + exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/" endif if a:islocal && exists("w:netrw_acdkeep") && w:netrw_acdkeep " call Decho("handle w:netrw_acdkeep:") -" call Decho("cd ".escape(a:dirname,g:netrw_cd_escape)." (due to w:netrw_acdkeep=".w:netrw_acdkeep." - acd=".&acd.")") - exe 'cd '.escape(a:dirname,g:netrw_cd_escape) +" call Decho("lcd ".escape(a:dirname,g:netrw_cd_escape)." (due to w:netrw_acdkeep=".w:netrw_acdkeep." - acd=".&acd.")") + exe 'lcd '.escape(a:dirname,g:netrw_cd_escape) " call Decho("getcwd<".getcwd().">") elseif !a:islocal && a:dirname !~ '[\/]$' && a:dirname !~ '^"' @@ -1874,6 +1988,7 @@ fun! s:NetrwBrowse(islocal,dirname) mark ' call s:NetrwEnew(a:dirname) setlocal ma noro +" call Decho("setlocal ma noro") let b:netrw_curdir= a:dirname " call Decho("exe silent! keepalt file ".s:method."://".s:user.s:machine."/".escape(s:path,g:netrw_cd_escape)." (bt=".&bt.")") exe "silent! keepalt file ".s:method."://".s:user.s:machine."/".escape(s:path,g:netrw_cd_escape) @@ -1887,9 +2002,10 @@ fun! s:NetrwBrowse(islocal,dirname) " save certain window-oriented variables into buffer-oriented variables {{{3 call s:SetBufWinVars() call s:NetrwOptionRestore("w:") - setlocal noma nomod nowrap + setlocal ma nomod -" call Dret("NetrwBrowse : file<".s:fname.">") +" call Decho("ro=".&ro." ma=".&ma." mod=".&mod." wrap=".&wrap) +" call Dret("s:NetrwBrowse : file<".s:fname.">") return endif @@ -1901,11 +2017,25 @@ fun! s:NetrwBrowse(islocal,dirname) let dirname = a:dirname let s:last_sort_by = g:netrw_sort_by - call s:NetrwMenu(1) " set up menu {{{3 - if s:NetrwGetBuffer(a:islocal,dirname) " set up buffer {{{3 + " set up menu {{{3 + call s:NetrwMenu(1) + + " set up buffer {{{3 + let reusing= s:NetrwGetBuffer(a:islocal,dirname) + " maintain markfile highlighting + if exists("s:netrwmarkfilemtch_{bufnr('%')}") && s:netrwmarkfilemtch_{bufnr("%")} != "" +" call Decho("bufnr(%)=".bufnr('%')) +" call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/") + exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/" + else +" call Decho("2match none") + 2match none + endif + if reusing call s:NetrwOptionRestore("w:") setlocal noma nomod nowrap -" call Dret("NetrwBrowse : re-using buffer") +" call Decho("ro=".&ro." ma=".&ma." mod=".&mod." wrap=".&wrap) +" call Dret("s:NetrwBrowse : re-using buffer") return endif @@ -1944,7 +2074,7 @@ fun! s:NetrwBrowse(islocal,dirname) " call Decho("handle g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd) " call Decho('exe cd '.escape(b:netrw_curdir,g:netrw_cd_escape)) try - exe 'cd '.escape(b:netrw_curdir,g:netrw_cd_escape) + exe 'lcd '.escape(b:netrw_curdir,g:netrw_cd_escape) catch /^Vim\%((\a\+)\)\=:E472/ call netrw#ErrorMsg(s:ERROR,"unable to change directory to <".b:netrw_curdir."> (permissions?)",33) if exists("w:netrw_prvdir") @@ -1953,7 +2083,8 @@ fun! s:NetrwBrowse(islocal,dirname) call s:NetrwOptionRestore("w:") setlocal noma nomod nowrap let b:netrw_curdir= dirname -" call Dret("NetrwBrowse : reusing buffer#".(exists("bufnum")? bufnum : 'N/A')."<".dirname."> getcwd<".getcwd().">") +" call Decho("ro=".&ro." ma=".&ma." mod=".&mod." wrap=".&wrap) +" call Dret("s:NetrwBrowse : reusing buffer#".(exists("bufnum")? bufnum : 'N/A')."<".dirname."> getcwd<".getcwd().">") return endif endtry @@ -1967,9 +2098,9 @@ fun! s:NetrwBrowse(islocal,dirname) " analyze a:dirname and g:netrw_list_cmd {{{4 " call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "doesn't exist")."> a:dirname<".a:dirname.">") - if a:dirname == "NetrwTreeListing" + if a:dirname =~ "^NetrwTreeListing\>" let dirname= b:netrw_curdir -" call Decho("(dirname was NetrwTreeListing) dirname<".dirname.">") +" call Decho("(dirname was ".a:dirname.") dirname<".dirname.">") elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir") let dirname= substitute(b:netrw_curdir,'\\','/','g') if dirname !~ '/$' @@ -1987,9 +2118,10 @@ fun! s:NetrwBrowse(islocal,dirname) if !exists("g:netrw_quiet") call netrw#ErrorMsg(s:ERROR,"netrw doesn't understand your dirname<".dirname.">",20) endif - call s:NetrwOptionRestore("w:") - setlocal noma nomod nowrap -" call Dret("NetrwBrowse : badly formatted dirname<".dirname.">") + call s:NetrwOptionRestore("w:") + setlocal noma nomod nowrap +" call Decho("ro=".&ro." ma=".&ma." mod=".&mod." wrap=".&wrap) +" call Dret("s:NetrwBrowse : badly formatted dirname<".dirname.">") return endif let b:netrw_curdir= dirname @@ -2002,65 +2134,102 @@ fun! s:NetrwBrowse(islocal,dirname) call s:BrowserMaps(a:islocal) call s:PerformListing(a:islocal) -" call Dret("NetrwBrowse : did PerformListing") +" call Decho("ro=".&ro." ma=".&ma." mod=".&mod." wrap=".&wrap) +" call Dret("s:NetrwBrowse : did PerformListing") return endfun +" --------------------------------------------------------------------- +" s:NetrwFileInfo: supports qf (query for file information) {{{2 +fun! s:NetrwFileInfo(islocal,fname) +" call Dfunc("s:NetrwFileInfo(islocal=".a:islocal." fname<".a:fname.">)") + if a:islocal + if (has("unix") || has("macunix")) && executable("/bin/ls") + echo system("/bin/ls -lsad ".a:fname) + else + " use vim functions to return information about file below cursor + if !isdirectory(a:fname) && !filereadable(a:fname) && a:fname =~ '[*@/]' + let fname= substitute(a:fname,".$","","") + else + let fname= a:fname + endif + let t = getftime(fname) + let sz = getfsize(fname) + echo a:fname.": ".sz." ".strftime(g:netrw_timefmt,getftime(fname)) +" call Decho(fname.": ".sz." ".strftime(g:netrw_timefmt,getftime(fname))) + endif + else + echo "sorry, \"qf\" not supported yet for remote files" + endif +" call Dret("s:NetrwFileInfo") +endfun + " --------------------------------------------------------------------- " s:NetrwGetBuffer: {{{2 " returns 0=cleared buffer " 1=re-used buffer fun! s:NetrwGetBuffer(islocal,dirname) -" call Dfunc("s:NetrwGetBuffer(islocal=".a:islocal." dirname<".a:dirname.">)") +" call Dfunc("s:NetrwGetBuffer(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".g:netrw_liststyle) + let dirname= a:dirname " re-use buffer if possible {{{3 " call Decho("--re-use a buffer if possible--") if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST " find NetrwTreeList buffer if there is one -" call Decho("find NetrwTreeList buffer if there is one") - let dirname= "NetrwTreeListing" - let bufnum = bufnr('\') - if bufnum != -1 + if exists("w:netrw_treebufnr") && w:netrw_treebufnr > 0 +" call Decho(" re-use w:netrw_treebufnr=".w:netrw_treebufnr) + let eikeep= &ei + set ei=all + exe "b ".w:netrw_treebufnr + let &ei= eikeep " call Dret("s:NetrwGetBuffer : bufnum#".bufnum."") return endif + let bufnum= -1 +" call Decho(" liststyle=TREE but w:netrw_treebufnr doesn't exist") else " find buffer number of buffer named precisely the same as dirname {{{3 " call Decho("--find buffer numnber of buffer named precisely the same as dirname--") " call Dredir("ls!") - let dirname= a:dirname -" call Decho("find buffer<".dirname.">'s number ") - let bufnum= bufnr(escape(dirname,'\')) -" call Decho("bufnr(dirname<".escape(dirname,'\').">)=".bufnum) + + " get dirname and associated buffer number + let bufnum = bufnr(escape(dirname,'\')) +" call Decho(" find buffer<".dirname.">'s number ") +" call Decho(" bufnr(dirname<".escape(dirname,'\').">)=".bufnum) + if bufnum < 0 && dirname !~ '/$' " trying appending a trailing / -" call Decho("try appending a trailing / to dirname<".dirname.">") +" call Decho(" try appending a trailing / to dirname<".dirname.">") let bufnum= bufnr(escape(dirname.'/','\')) if bufnum > 0 let dirname= dirname.'/' endif endif + if bufnum < 0 && dirname =~ '/$' " trying removing a trailing / -" call Decho("try removing a trailing / from dirname<".dirname.">") +" call Decho(" try removing a trailing / from dirname<".dirname.">") let bufnum= bufnr(escape(substitute(dirname,'/$','',''),'\')) if bufnum > 0 let dirname= substitute(dirname,'/$','','') endif endif -" call Decho("findbuf1: bufnum=bufnr('".dirname."')=".bufnum." bufname(".bufnum.")<".bufname(bufnum)."> (initial)") - let ibuf= 1 + +" call Decho(" findbuf1: bufnum=bufnr('".dirname."')=".bufnum." bufname(".bufnum.")<".bufname(bufnum)."> (initial)") " note: !~ was used just below, but that means using ../ to go back would match (ie. abc/def/ and abc/ matches) if bufnum > 0 && bufname(bufnum) != dirname + " handle approximate matches +" call Decho(" handling approx match: bufnum#%d<".bufname(bufnum)."> approx= dirname<".dirname.">") + let ibuf = 1 let buflast = bufnr("$") -" call Decho("findbuf2: buflast=".buflast) +" call Decho(" findbuf2: buflast=".buflast) while ibuf <= buflast let bname= substitute(bufname(ibuf),'\\','/','g') -" call Decho("findbuf3: dirname<".dirname."> bufname(".ibuf.")<".bname.">") - if bname != '' && bname !~ '/' && dirname =~ '/'.bname.'$' | break | endif - if bname =~ '^'.dirname.'/\=$' | break | endif - if dirname =~ '^'.bname.'/$' | break | endif +" call Decho(" findbuf3: dirname<".dirname."> bufname(".ibuf.")<".bname.">") + if bname != '' && bname !~ '/' && dirname =~ '/'.bname.'/\=$' | break | endif + if bname =~ '^'.dirname.'/\=$' | break | endif + if dirname =~ '^'.bname.'/$' | break | endif let ibuf= ibuf + 1 endwhile if ibuf > buflast @@ -2068,43 +2237,51 @@ fun! s:NetrwGetBuffer(islocal,dirname) else let bufnum= ibuf endif -" call Decho("findbuf4: bufnum=".bufnum) +" call Decho(" findbuf4: bufnum=".bufnum." (ibuf=".ibuf." buflast=".buflast.")") endif endif " get enew buffer and name it -or- re-use buffer {{{3 -" call Decho("--get enewbuffer and name it -or- re-use buffer--") +" call Decho("--get enew buffer and name it OR re-use buffer-- (bufnum=".bufnum.")") mark ' if bufnum < 0 || !bufexists(bufnum) -" call Decho("get enew buffer") call s:NetrwEnew(dirname) +" call Decho(" got enew buffer#".bufnr("%")." (altbuf<".expand("#").">)") " name the buffer if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST -" call Decho('silent! keepalt file NetrwTreeListing') - silent! keepalt file NetrwTreeListing + " Got enew buffer; transform into a NetrwTreeListing +" call Decho("--transform enew buffer#".bufnr("%")." into a NetrwTreeListing --") + if !exists("s:netrw_treelistnum") + let s:netrw_treelistnum= 1 + else + let s:netrw_treelistnum= s:netrw_treelistnum + 1 + endif + let w:netrw_treebufnr= bufnr("%") +" call Decho(" exe silent! keepalt file NetrwTreeListing ".s:netrw_treelistnum) + exe 'silent! keepalt file NetrwTreeListing\ '.s:netrw_treelistnum nnoremap [ :silent call TreeListMove('[') nnoremap ] :silent call TreeListMove(']') nnoremap [[ :silent call TreeListMove('[') nnoremap ]] :silent call TreeListMove(']') +" call Decho(" tree listing#".s:netrw_treelistnum." bufnr=".w:netrw_treebufnr) else -" call Decho('exe silent! keepalt file '.escape(dirname,g:netrw_cd_escape)) " let v:errmsg= "" " Decho let escdirname= escape(dirname,g:netrw_cd_escape) - exe 'silent! keepalt file '.escdirname " call Decho("errmsg<".v:errmsg."> bufnr(".escdirname.")=".bufnr(escdirname)."<".bufname(bufnr(escdirname)).">") +" call Decho(' exe silent! keepalt file '.escdirname) + exe 'silent! keepalt file '.escdirname endif -" call Decho("named enew buffer#".bufnr("%")."<".bufname("%").">") +" call Decho(" named enew buffer#".bufnr("%")."<".bufname("%").">") else " Re-use the buffer - -" call Decho("re-use buffer#".bufnum.":") +" call Decho("--re-use buffer#".bufnum.": --") let eikeep= &ei set ei=all if getline(2) =~ '^" Netrw Directory Listing' -" call Decho("re-use buffer#".bufnum."<".((bufnum > 0)? bufname(bufnum) : "")."> using: keepalt b ".bufnum) +" call Decho(" re-use buffer#".bufnum."<".((bufnum > 0)? bufname(bufnum) : "")."> using: keepalt b ".bufnum) exe "keepalt b ".bufnum else -" call Decho("reusing buffer#".bufnum."<".((bufnum > 0)? bufname(bufnum) : "")."> using: b ".bufnum) +" call Decho(" reusing buffer#".bufnum."<".((bufnum > 0)? bufname(bufnum) : "")."> using: b ".bufnum) exe "b ".bufnum endif let &ei= eikeep @@ -2113,7 +2290,8 @@ fun! s:NetrwGetBuffer(islocal,dirname) " call Dret("s:NetrwGetBuffer 0 : re-using buffer#".bufnr("%").", but its empty, so refresh it") return 0 elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST -" call Decho("clear buffer<".expand("%")."> with :%d") +" call Decho("--re-use tree listing--") +" call Decho(" clear buffer<".expand("%")."> with :%d") silent %d call s:NetrwListSettings(a:islocal) " call Dret("s:NetrwGetBuffer 0 : re-using buffer#".bufnr("%").", but treelist mode always needs a refresh") @@ -2132,21 +2310,38 @@ fun! s:NetrwGetBuffer(islocal,dirname) " call Decho("--do netrw settings: make this buffer not-a-file, modifiable, not line-numbered, etc--") let fname= expand("%") call s:NetrwListSettings(a:islocal) - exe "file ".escape(fname,' ') + exe "keepalt file ".escape(fname,' ') " delete all lines from buffer {{{3 " call Decho("--delete all lines from buffer--") -" call Decho("clear buffer<".expand("%")."> with :%d") +" call Decho(" clear buffer<".expand("%")."> with :%d") keepalt silent! %d " call Dret("s:NetrwGetBuffer 0 : buf#".bufnr("%")) return 0 endfun +" --------------------------------------------------------------------- +" s:NetrwGetcwd: get the current directory. {{{2 +" Change backslashes to forward slashes, if any. +" If doesc is true, escape certain troublesome characters +fun! s:NetrwGetcwd(doesc) +" call Dfunc("NetrwGetcwd(doesc=".a:doesc.")") + let curdir= substitute(getcwd(),'\\','/','ge') + if curdir !~ '[\/]$' + let curdir= curdir.'/' + endif + if a:doesc + let curdir= escape(curdir,g:netrw_cd_escape) + endif +" call Dret("NetrwGetcwd <".curdir.">") + return curdir +endfun + " --------------------------------------------------------------------- " s:NetrwGetWord: it gets the directory named under the cursor {{{2 fun! s:NetrwGetWord() -" call Dfunc("NetrwGetWord() line#".line(".")." liststyle=".g:netrw_liststyle." virtcol=".virtcol(".")) +" call Dfunc("s:NetrwGetWord() line#".line(".")." liststyle=".g:netrw_liststyle." virtcol=".virtcol(".")) call s:UseBufWinVars() " insure that w:netrw_liststyle is set up @@ -2225,7 +2420,13 @@ fun! s:NetrwGetWord() " call Decho("4: dirname<".dirname.">") endif -" call Dret("NetrwGetWord <".dirname.">") + " symlinks are indicated by a trailing "@". Remove it before further processing. + let dirname= substitute(dirname,"@$","","") + + " executables are indicated by a trailing "*". Remove it before further processing. + let dirname= substitute(dirname,"\*$","","") + +" call Dret("s:NetrwGetWord <".dirname.">") return dirname endfun @@ -2235,7 +2436,8 @@ fun! s:NetrwListSettings(islocal) " call Dfunc("s:NetrwListSettings(islocal=".a:islocal.")") let fname= bufname("%") setlocal bt=nofile nobl ma nonu nowrap noro - exe "file ".escape(fname,' ') +" call Decho("setlocal bt=nofile nobl ma nonu nowrap noro") + exe "keepalt file ".escape(fname,' ') if g:netrw_use_noswf setlocal noswf endif @@ -2252,184 +2454,112 @@ fun! s:NetrwListSettings(islocal) endfun " --------------------------------------------------------------------- -" s:PerformListing: {{{2 -fun! s:PerformListing(islocal) -" call Dfunc("s:PerformListing(islocal=".a:islocal.") buf(%)=".bufnr("%")."<".bufname("%").">") +" s:NetrwListStyle: {{{2 +" islocal=0: remote browsing +" =1: local browsing +fun! s:NetrwListStyle(islocal) +" call Dfunc("NetrwListStyle(islocal=".a:islocal.") w:netrw_liststyle=".w:netrw_liststyle) + let fname = s:NetrwGetWord() + if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif + let w:netrw_liststyle = (w:netrw_liststyle + 1) % s:MAXLIST +" call Decho("fname<".fname.">") +" call Decho("chgd w:netrw_liststyle to ".w:netrw_liststyle) +" call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "doesn't exist").">") - call s:NetrwSafeOptions() - setlocal noro ma + if w:netrw_liststyle == s:THINLIST + " use one column listing +" call Decho("use one column list") + let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge') -" if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1 " Decho -" call Decho("(netrw) Processing your browsing request...") -" endif " Decho + elseif w:netrw_liststyle == s:LONGLIST + " use long list +" call Decho("use long list") + let g:netrw_list_cmd = g:netrw_list_cmd." -l" -" call Decho('w:netrw_liststyle='.(exists("w:netrw_liststyle")? w:netrw_liststyle : 'n/a')) - if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") - " force a refresh for tree listings -" call Decho("force refresh for treelisting: clear buffer<".expand("%")."> with :%d") - keepjumps %d - endif + elseif w:netrw_liststyle == s:WIDELIST + " give wide list +" call Decho("use wide list") + let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge') - " save current directory on directory history list - call s:NetrwBookmarkDir(3,b:netrw_curdir) + elseif w:netrw_liststyle == s:TREELIST +" call Decho("use tree list") + let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge') - " Set up the banner {{{3 -" call Decho("set up banner") - keepjumps put ='\" ============================================================================' - keepjumps put ='\" Netrw Directory Listing (netrw '.g:loaded_netrw.')' - keepjumps put ='\" '.b:netrw_curdir - keepjumps 1d - let w:netrw_bannercnt= 3 - exe "keepjumps ".w:netrw_bannercnt - - let sortby= g:netrw_sort_by - if g:netrw_sort_direction =~ "^r" - let sortby= sortby." reversed" - endif - - " Sorted by... {{{3 -" call Decho("handle specified sorting: g:netrw_sort_by<".g:netrw_sort_by.">") - if g:netrw_sort_by =~ "^n" -" call Decho("directories will be sorted by name") - " sorted by name - keepjumps put ='\" Sorted by '.sortby - keepjumps put ='\" Sort sequence: '.g:netrw_sort_sequence - let w:netrw_bannercnt= w:netrw_bannercnt + 2 else -" call Decho("directories will be sorted by size or time") - " sorted by size or date - keepjumps put ='\" Sorted by '.sortby - let w:netrw_bannercnt= w:netrw_bannercnt + 1 + call netrw#ErrorMsg(s:WARNING,"bad value for g:netrw_liststyle (=".w:netrw_liststyle.")",46) + let g:netrw_liststyle = s:THINLIST + let w:netrw_liststyle = g:netrw_liststyle + let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge') endif - exe "keepjumps ".w:netrw_bannercnt + setlocal ma noro +" call Decho("setlocal ma noro") - " show copy/move target, if any - if exists("s:netrwmftgt") && exists("s:netrwmfloc") -" call Decho("show copy/move target<".s:netrwmftgt."> netrwmfloc=".s:netrwmfloc) - if s:netrwmfloc - keepjumps put ='\" Copy/Move Tgt: '.s:netrwmftgt.' (local)' - else - keepjumps put ='\" Copy/Move Tgt: '.s:netrwmftgt.' (remote)' + " clear buffer - this will cause NetrwBrowse/LocalBrowseCheck to do a refresh +" call Decho("clear buffer<".expand("%")."> with :%d") + %d + + " refresh the listing + let svpos= netrw#NetrwSavePosn() + call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) + call netrw#NetrwRestorePosn(svpos) + + " keep cursor on the filename + silent keepjumps $ + let result= search('\%(^\%(|\+\s\)\=\|\s\{2,}\)\zs'.escape(fname,'.\[]*$^').'\%(\s\{2,}\|$\)','bc') +" call Decho("search result=".result." w:netrw_bannercnt=".(exists("w:netrw_bannercnt")? w:netrw_bannercnt : 'N/A')) + if result <= 0 && exists("w:netrw_bannercnt") + exe "keepjumps ".w:netrw_bannercnt + endif + +" call Dret("NetrwListStyle".(exists("w:netrw_liststyle")? ' : w:netrw_liststyle='.w:netrw_liststyle : "")) +endfun + +" --------------------------------------------------------------------- +" s:NetrwBookmarkMenu: Uses menu priorities {{{2 +" .2.[cnt] for bookmarks, and +" .3.[cnt] for history +" (see s:NetrwMenu()) +fun! s:NetrwBookmarkMenu() + if !exists("s:netrw_menucnt") + return + endif +" call Dfunc("NetrwBookmarkMenu() bookmarkcnt=".g:NETRW_BOOKMARKMAX." histcnt=".g:NETRW_DIRHIST_CNT." menucnt=".s:netrw_menucnt) + if has("menu") && has("gui_running") && &go =~ 'm' + if exists("g:NetrwTopLvlMenu") + exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Bookmark' endif - let w:netrw_bannercnt= w:netrw_bannercnt + 1 - endif - exe "keepjumps ".w:netrw_bannercnt - " Hiding... -or- Showing... {{{3 -" call Decho("handle hiding/showing (g:netrw_hide=".g:netrw_list_hide." g:netrw_list_hide<".g:netrw_list_hide.">)") - if g:netrw_list_hide != "" && g:netrw_hide - if g:netrw_hide == 1 - keepjumps put ='\" Hiding: '.g:netrw_list_hide - else - keepjumps put ='\" Showing: '.g:netrw_list_hide - endif - let w:netrw_bannercnt= w:netrw_bannercnt + 1 - endif - exe "keepjumps ".w:netrw_bannercnt - keepjumps put ='\" Quick Help: :help -:go up dir D:delete R:rename s:sort-by x:exec' - keepjumps put ='\" ============================================================================' - let w:netrw_bannercnt= w:netrw_bannercnt + 2 - - " bannercnt should index the line just after the banner - let w:netrw_bannercnt= w:netrw_bannercnt + 1 - exe "keepjumps ".w:netrw_bannercnt -" call Decho("bannercnt=".w:netrw_bannercnt." (should index line just after banner) line($)=".line("$")) - - " set up syntax highlighting {{{3 -" call Decho("set up syntax highlighting") - if has("syntax") - setlocal ft=netrw - if !exists("g:syntax_on") || !g:syntax_on - setlocal ft= - endif - endif - - " get list of files -" call Decho("Get list of files - islocal=".a:islocal) - if a:islocal - call s:LocalListing() - else " remote - call s:NetrwRemoteListing() - endif -" call Decho("w:netrw_bannercnt=".w:netrw_bannercnt." (banner complete)") - - " manipulate the directory listing (hide, sort) {{{3 - if line("$") >= w:netrw_bannercnt -" call Decho("manipulate directory listing (hide)") -" call Decho("g:netrw_hide=".g:netrw_hide." g:netrw_list_hide<".g:netrw_list_hide.">") - if g:netrw_hide && g:netrw_list_hide != "" - call s:NetrwListHide() - endif - if line("$") >= w:netrw_bannercnt -" call Decho("manipulate directory listing (sort) : g:netrw_sort_by<".g:netrw_sort_by.">") - - if g:netrw_sort_by =~ "^n" - " sort by name - call s:SetSort() - - if w:netrw_bannercnt < line("$") -" call Decho("g:netrw_sort_direction=".g:netrw_sort_direction." (bannercnt=".w:netrw_bannercnt.")") - if g:netrw_sort_direction =~ 'n' - " normal direction sorting - exe 'silent keepjumps '.w:netrw_bannercnt.',$sort' - else - " reverse direction sorting - exe 'silent keepjumps '.w:netrw_bannercnt.',$sort!' - endif - endif - " remove priority pattern prefix -" call Decho("remove priority pattern prefix") - exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\d\{3}\///e' - - elseif a:islocal - if w:netrw_bannercnt < line("$") -" call Decho("g:netrw_sort_direction=".g:netrw_sort_direction) - if g:netrw_sort_direction =~ 'n' -" call Decho('exe silent keepjumps '.w:netrw_bannercnt.',$sort') - exe 'silent keepjumps '.w:netrw_bannercnt.',$sort' - else -" call Decho('exe silent keepjumps '.w:netrw_bannercnt.',$sort!') - exe 'silent keepjumps '.w:netrw_bannercnt.',$sort!' - endif - endif - exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\d\{-}\///e' + " show bookmarked places + let cnt = 0 + while cnt <= g:NETRW_BOOKMARKMAX + if exists("g:NETRW_BOOKMARKDIR_{cnt}") + let bmdir= escape(g:NETRW_BOOKMARKDIR_{cnt},'.') +" call Decho('silent! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmark.'.bmdir.' :e '.g:NETRW_BOOKMARKDIR_{cnt}) + exe 'silent! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmarks.'.bmdir.' :e '.g:NETRW_BOOKMARKDIR_{cnt}."\" endif + let cnt= cnt + 1 + endwhile - elseif g:netrw_sort_direction =~ 'r' -" call Decho('reverse the sorted listing') - exe 'silent keepjumps '.w:netrw_bannercnt.'g/^/m '.w:netrw_bannercnt - endif + " show directory browsing history + let cnt = g:NETRW_DIRHIST_CNT + let first = 1 + let histcnt = 0 + while ( first || cnt != g:NETRW_DIRHIST_CNT ) + let histcnt = histcnt + 1 + let priority = g:NETRW_DIRHIST_CNT + histcnt + if exists("g:NETRW_DIRHIST_{cnt}") + let bmdir= escape(g:NETRW_DIRHIST_{cnt},'.') +" call Decho('silent! menu '.g:NetrwMenuPriority.".3.".priority." ".g:NetrwTopLvlMenu.'History.'.bmdir.' :e '.g:NETRW_DIRHIST_{cnt}) + exe 'silent! menu '.g:NetrwMenuPriority.".3.".priority." ".g:NetrwTopLvlMenu.'History.'.bmdir.' :e '.g:NETRW_DIRHIST_{cnt}."\" + endif + let first = 0 + let cnt = ( cnt - 1 ) % g:netrw_dirhistmax + if cnt < 0 + let cnt= cnt + g:netrw_dirhistmax + endif + endwhile endif - - " convert to wide/tree listing {{{3 -" call Decho("modify display if wide/tree listing style") - call s:NetrwWideListing() - call s:NetrwTreeListing(b:netrw_curdir) - - if exists("w:netrw_bannercnt") && line("$") > w:netrw_bannercnt - " place cursor on the top-left corner of the file listing -" call Decho("place cursor on top-left corner of file listing") - exe 'silent keepjumps '.w:netrw_bannercnt - norm! 0 - endif - - " record previous current directory - let w:netrw_prvdir= b:netrw_curdir -" call Decho("record netrw_prvdir<".w:netrw_prvdir.">") - - " save certain window-oriented variables into buffer-oriented variables {{{3 - call s:SetBufWinVars() - call s:NetrwOptionRestore("w:") - - " set display to netrw display settings -" call Decho("set display to netrw display settings (noma nomod etc)") - setlocal noma nomod nonu nobl nowrap ro - if exists("s:treecurpos") - call setpos('.',s:treecurpos) - unlet s:treecurpos - endif - -" call Dret("s:PerformListing : curpos<".string(getpos(".")).">") +" call Dret("NetrwBookmarkMenu") endfun " --------------------------------------------------------------------- @@ -2449,8 +2579,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) call s:NetrwOptionSave("s:") call s:NetrwSafeOptions() - call netrw#NetrwSavePosn() - let nbcd_curpos = getpos('.') + let nbcd_curpos = netrw#NetrwSavePosn() let dirname = substitute(b:netrw_curdir,'\\','/','ge') let newdir = a:newdir let dolockout = 0 @@ -2476,7 +2605,12 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) " ------------ " call Decho('case "handling a file": newdir<'.newdir.'> !~ dirpat<'.dirpat.">") if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") && newdir !~ '^\(/\|\a:\)' - let dirname= s:NetrwTreeDir().newdir + let dirname= s:NetrwTreeDir() + if dirname =~ '/$' + let dirname= dirname.newdir + else + let dirname= s:NetrwTreeDir()."/".newdir + endif " call Decho("tree listing") elseif newdir =~ '^\(/\|\a:\)' let dirname= newdir @@ -2551,6 +2685,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) " force a refresh " call Decho("clear buffer<".expand("%")."> with :%d") setlocal noro ma +" call Decho("setlocal noro ma") keepjumps %d endif @@ -2584,6 +2719,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) " call Decho('case liststyle is TREELIST and w:netrw_treedict exists') " force a refresh (for TREELIST, wait for NetrwTreeDir() to force the refresh) setlocal noro ma +" call Decho("setlocal noro ma") if !(exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir")) " call Decho("clear buffer<".expand("%")."> with :%d") keepjumps %d @@ -2648,12 +2784,553 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) if dolockout " call Decho("doing modification lockout settings: ma nomod noro") setlocal ma nomod noro +" call Decho("setlocal ma nomod noro") endif " call Dret("s:NetrwBrowseChgDir <".dirname."> : curpos<".string(getpos(".")).">") return dirname endfun +" --------------------------------------------------------------------- +" s:NetrwBrowseX: allows users to write custom functions to operate on {{{2 +" files given their extension. Passes 0=local, 1=remote +fun! netrw#NetrwBrowseX(fname,remote) +" call Dfunc("NetrwBrowseX(fname<".a:fname."> remote=".a:remote.")") + + " set up the filename + " (lower case the extension, make a local copy of a remote file) + let exten= substitute(a:fname,'.*\.\(.\{-}\)','\1','e') + if has("win32") || has("win95") || has("win64") || has("win16") + let exten= substitute(exten,'^.*$','\L&\E','') + endif + let fname= escape(a:fname,"%#") +" call Decho("fname<".fname."> after escape()") + + " seems kde systems often have gnome-open due to dependencies, even though + " gnome-open's subsidiary display tools are largely absent. Kde systems + " usually have "kdeinit" running, though... (tnx Mikolaj Machowski) + if !exists("s:haskdeinit") + if has("unix") + let s:haskdeinit= s:System("system",'ps -e') =~ 'kdeinit' + if v:shell_error + let s:haskdeinit = 0 + endif + else + let s:haskdeinit= 0 + endif +" call Decho("setting s:haskdeinit=".s:haskdeinit) + endif + + if a:remote == 1 + " create a local copy + let fname= fnamemodify(tempname(),":r").".".exten +" call Decho("a:remote=".a:remote.": create a local copy of <".a:fname."> as <".fname.">") + exe "silent keepjumps bot 1new ".a:fname + setlocal bh=delete +" call Decho("read <".fname.">, now writing: exe w! ".fname) + exe "silent! w! ".fname + q + endif +" call Decho("exten<".exten."> "."netrwFileHandlers#NFH_".exten."():exists=".exists("*netrwFileHandlers#NFH_".exten)) + + " set up redirection + if &srr =~ "%s" + if (has("win32") || has("win95") || has("win64") || has("win16")) + let redir= substitute(&srr,"%s","nul","") + else + let redir= substitute(&srr,"%s","/dev/null","") + endif + elseif (has("win32") || has("win95") || has("win64") || has("win16")) + let redir= &srr . "nul" + else + let redir= &srr . "/dev/null" + endif +" call Decho("redir{".redir."} srr{".&srr."}") + + " extract any viewing options. Assumes that they're set apart by quotes. + if exists("g:netrw_browsex_viewer") + if g:netrw_browsex_viewer =~ '\s' + let viewer = substitute(g:netrw_browsex_viewer,'\s.*$','','') + let viewopt = substitute(g:netrw_browsex_viewer,'^\S\+\s*','','')." " + let oviewer = '' + let cnt = 1 + while !executable(viewer) && viewer != oviewer + let viewer = substitute(g:netrw_browsex_viewer,'^\(\(^\S\+\s\+\)\{'.cnt.'}\S\+\)\(.*\)$','\1','') + let viewopt = substitute(g:netrw_browsex_viewer,'^\(\(^\S\+\s\+\)\{'.cnt.'}\S\+\)\(.*\)$','\3','')." " + let cnt = cnt + 1 + let oviewer = viewer +" call Decho("!exe: viewer<".viewer."> viewopt<".viewopt.">") + endwhile + else + let viewer = g:netrw_browsex_viewer + let viewopt = "" + endif +" call Decho("viewer<".viewer."> viewopt<".viewopt.">") + endif + + " execute the file handler + if exists("g:netrw_browsex_viewer") && g:netrw_browsex_viewer == '-' +" call Decho("g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">") + let ret= netrwFileHandlers#Invoke(exten,fname) + + elseif exists("g:netrw_browsex_viewer") && executable(viewer) +" call Decho("g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">") +" call Decho("exe silent !".viewer." ".viewopt.g:netrw_shq.escape(fname,'%#').g:netrw_shq.redir) + exe "silent !".viewer." ".viewopt.g:netrw_shq.escape(fname,'%#').g:netrw_shq.redir + let ret= v:shell_error + + elseif has("win32") || has("win64") +" call Decho('exe silent !start rundll32 url.dll,FileProtocolHandler '.g:netrw_shq.escape(fname, '%#').g:netrw_shq) + exe 'silent !start rundll32 url.dll,FileProtocolHandler '.g:netrw_shq.escape(fname, '%#').g:netrw_shq + call inputsave()|call input("Press to continue")|call inputrestore() + let ret= v:shell_error + + elseif has("unix") && executable("gnome-open") && !s:haskdeinit +" call Decho("exe silent !gnome-open ".g:netrw_shq.escape(fname,'%#').g:netrw_shq." ".redir) + exe "silent !gnome-open ".g:netrw_shq.escape(fname,'%#').g:netrw_shq.redir + let ret= v:shell_error + + elseif has("unix") && executable("kfmclient") && s:haskdeinit +" call Decho("exe silent !kfmclient exec ".g:netrw_shq.escape(fname,'%#').g:netrw_shq." ".redir) + exe "silent !kfmclient exec ".g:netrw_shq.escape(fname,'%#').g:netrw_shq." ".redir + let ret= v:shell_error + + elseif has("macunix") && executable("open") +" call Decho("exe silent !open '".escape(fname,'%#')."' ".redir) + exe silent !open '".escape(fname,'%#')."' ".redir + let ret= v:shell_error + + else + " netrwFileHandlers#Invoke() always returns 0 + let ret= netrwFileHandlers#Invoke(exten,fname) + endif + + " if unsuccessful, attempt netrwFileHandlers#Invoke() + if ret + let ret= netrwFileHandlers#Invoke(exten,fname) + endif + +" redraw! + + " cleanup: remove temporary file, + " delete current buffer if success with handler, + " return to prior buffer (directory listing) + " Feb 12, 2008: had to de-activiate removal of + " temporary file because it wasn't getting seen. +" if a:remote == 1 && fname != a:fname +" call Decho("deleting temporary file<".fname.">") +" call s:System("delete",fname) +" endif + + if a:remote == 1 + setlocal bh=delete bt=nofile + if g:netrw_use_noswf + setlocal noswf + endif + exe "norm! \" +" redraw! + endif + +" call Dret("NetrwBrowseX") +endfun + +" --------------------------------------------------------------------- +" netrw#Explore: launch the local browser in the directory of the current file {{{2 +" dosplit==0: the window will be split iff the current file has +" been modified +" dosplit==1: the window will be split before running the local +" browser +fun! netrw#Explore(indx,dosplit,style,...) +" call Dfunc("netrw#Explore(indx=".a:indx." dosplit=".a:dosplit." style=".a:style.",a:1<".a:1.">) &modified=".&modified." a:0=".a:0) + if !exists("b:netrw_curdir") + let b:netrw_curdir= getcwd() +" call Decho("set b:netrw_curdir<".b:netrw_curdir."> (used getcwd)") + endif + let curfile= b:netrw_curdir +" call Decho("curfile<".curfile.">") + + " save registers + silent! let keepregstar = @* + silent! let keepregplus = @+ + silent! let keepregslash= @/ + + " if dosplit or file has been modified + if a:dosplit || &modified || a:style == 6 +" call Decho("case: dosplit=".a:dosplit." modified=".&modified." a:style=".a:style) + call s:SaveWinVars() + + if a:style == 0 " Explore, Sexplore +" call Decho("style=0: Explore or Sexplore") + exe g:netrw_winsize."wincmd s" + + elseif a:style == 1 "Explore!, Sexplore! +" call Decho("style=1: Explore! or Sexplore!") + exe g:netrw_winsize."wincmd v" + + elseif a:style == 2 " Hexplore +" call Decho("style=2: Hexplore") + exe "bel ".g:netrw_winsize."wincmd s" + + elseif a:style == 3 " Hexplore! +" call Decho("style=3: Hexplore!") + exe "abo ".g:netrw_winsize."wincmd s" + + elseif a:style == 4 " Vexplore +" call Decho("style=4: Vexplore") + exe "lefta ".g:netrw_winsize."wincmd v" + + elseif a:style == 5 " Vexplore! +" call Decho("style=5: Vexplore!") + exe "rightb ".g:netrw_winsize."wincmd v" + + elseif a:style == 6 " Texplore + call s:SaveBufVars() +" call Decho("style = 6: Texplore") + tabnew + call s:RestoreBufVars() + endif + call s:RestoreWinVars() + endif + norm! 0 + + if a:0 > 0 +" call Decho("case [a:0=".a:0."]>0: a:1<".a:1.">") + if a:1 =~ '^\~' && (has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin)) + let dirname= substitute(a:1,'\~',expand("$HOME"),'') +" call Decho("using dirname<".dirname."> (case: ~ && unix||cygwin)") + elseif a:1 == '.' + let dirname= exists("b:netrw_curdir")? b:netrw_curdir : getcwd() + if dirname !~ '/$' + let dirname= dirname."/" + endif +" call Decho("using dirname<".dirname."> (case: ".(exists("b:netrw_curdir")? "b:netrw_curdir" : "getcwd()").")") + elseif a:1 =~ '\$' + let dirname= expand(a:1) + else + let dirname= a:1 +" call Decho("using dirname<".dirname.">") + endif + else + " clear explore +" call Decho("clearing explore variables") + 2match none + if exists("s:explore_match") |unlet s:explore_match |endif + if exists("s:explore_indx") |unlet s:explore_indx |endif + if exists("s:dirstarstar") |unlet s:dirstarstar |endif + if exists("s:dirstarstar") |unlet s:dirstarstar |endif + if exists("w:netrw_explore_indx") |unlet w:netrw_explore_indx |endif + if exists("w:netrw_explore_listlen")|unlet w:netrw_explore_listlen|endif + if exists("w:netrw_explore_list") |unlet w:netrw_explore_list |endif + if exists("w:netrw_explore_bufnr") |unlet w:netrw_explore_bufnr |endif +" redraw! + echo " " + echo " " +" call Dret("netrw#Explore : cleared list") + return + endif + + if dirname =~ '/\*\*/' + " handle .../**/.../filepat +" call Decho("case Explore .../**/.../filepat") + let prefixdir= substitute(dirname,'^\(.\{-}\)\*\*.*$','\1','') + if prefixdir =~ '^/' || (prefixdir =~ '^\a:/' && (has("win32") || has("win95") || has("win64") || has("win16"))) + let b:netrw_curdir = prefixdir + else + let b:netrw_curdir= getcwd().'/'.prefixdir + endif + let dirname= substitute(dirname,'^.\{-}\(\*\*/.*\)$','\1','') + let starpat= 4; +" call Decho("pwd<".getcwd()."> dirname<".dirname.">") +" call Decho("case Explore ../**/../filepat (starpat=".starpat.")") + + elseif dirname =~ '^\*//' + " starpat=1: Explore *//pattern (current directory only search for files containing pattern) +" call Decho("case Explore *//pattern") + let pattern= substitute(dirname,'^\*//\(.*\)$','\1','') + let starpat= 1 +" call Decho("Explore *//pat: (starpat=".starpat.") dirname<".dirname."> -> pattern<".pattern.">") + if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif + + elseif dirname =~ '^\*\*//' + " starpat=2: Explore **//pattern (recursive descent search for files containing pattern) +" call Decho("case Explore **//pattern") + let pattern= substitute(dirname,'^\*\*//','','') + let starpat= 2 +" call Decho("Explore **//pat: (starpat=".starpat.") dirname<".dirname."> -> pattern<".pattern.">") + + elseif dirname =~ '^\*/' + " starpat=3: Explore */filepat (search in current directory for filenames matching filepat) + let starpat= 3 +" call Decho("case Explore */filepat (starpat=".starpat.")") + + elseif dirname=~ '^\*\*/' + " starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat) + let starpat= 4 +" call Decho("case Explore **/filepat (starpat=".starpat.")") + else + let starpat= 0 + endif + + if starpat == 0 && a:indx >= 0 + " [Explore Hexplore Vexplore Sexplore] [dirname] +" call Decho("case dirname<".dirname."> a:indx=".a:indx.": Explore Hexplore Vexplore Sexplore") + if dirname == "" + let dirname= substitute(expand("%:p"),'^\(.*[/\\]\)[^/\\]*$','\1','e') + endif + if dirname =~ '^scp:' || dirname =~ '^ftp:' +" call Decho("calling NetrwBrowse(0,dirname<".dirname.">)") + call s:NetrwBrowse(0,dirname) + else + if dirname == ""|let dirname= getcwd()|endif +" call Decho("calling LocalBrowseCheck(dirname<".dirname.">)") + call netrw#LocalBrowseCheck(dirname) + endif + +" call Decho("curfile<".curfile.">") + if has("win32") || has("win95") || has("win64") || has("win16") + call search('\<'.substitute(curfile,'^.*[/\\]','','e').'\>','cW') + else + call search('\<'.substitute(curfile,'^.*/','','e').'\>','cW') + endif + + " starpat=1: Explore *//pattern (current directory only search for files containing pattern) + " starpat=2: Explore **//pattern (recursive descent search for files containing pattern) + " starpat=3: Explore */filepat (search in current directory for filenames matching filepat) + " starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat) + elseif a:indx <= 0 + " Nexplore, Pexplore, Explore: handle starpat +" call Decho("case Nexplore, Pexplore, , : starpat=".starpat." a:indx=".a:indx) + if !mapcheck("","n") && !mapcheck("","n") && exists("b:netrw_curdir") +" call Decho("set up and maps") + let s:didstarstar= 1 + nnoremap :Pexplore + nnoremap :Nexplore + endif + + if has("path_extra") +" call Decho("starpat=".starpat.": has +path_extra") + if !exists("w:netrw_explore_indx") + let w:netrw_explore_indx= 0 + endif + let indx = a:indx +" call Decho("starpat=".starpat.": set indx= [a:indx=".indx."]") +" + if indx == -1 + " Nexplore +" call Decho("case Nexplore with starpat=".starpat.": (indx=".indx.")") + if !exists("w:netrw_explore_list") " sanity check + call netrw#ErrorMsg(s:WARNING,"using Nexplore or improperly; see help for netrw-starstar",40) + silent! let @* = keepregstar + silent! let @+ = keepregstar + silent! let @/ = keepregslash +" call Dret("netrw#Explore") + return + endif + let indx= w:netrw_explore_indx + if indx < 0 | let indx= 0 | endif + if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif + let curfile= w:netrw_explore_list[indx] +" call Decho("indx=".indx." curfile<".curfile.">") + while indx < w:netrw_explore_listlen && curfile == w:netrw_explore_list[indx] + let indx= indx + 1 +" call Decho("indx=".indx." (Nexplore while loop)") + endwhile + if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif +" call Decho("Nexplore: indx= [w:netrw_explore_indx=".w:netrw_explore_indx."]=".indx) + + elseif indx == -2 + " Pexplore +" call Decho("case Pexplore with starpat=".starpat.": (indx=".indx.")") + if !exists("w:netrw_explore_list") " sanity check + call netrw#ErrorMsg(s:WARNING,"using Pexplore or improperly; see help for netrw-starstar",41) + silent! let @* = keepregstar + silent! let @+ = keepregstar + silent! let @/ = keepregslash +" call Dret("netrw#Explore") + return + endif + let indx= w:netrw_explore_indx + if indx < 0 | let indx= 0 | endif + if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif + let curfile= w:netrw_explore_list[indx] +" call Decho("indx=".indx." curfile<".curfile.">") + while indx >= 0 && curfile == w:netrw_explore_list[indx] + let indx= indx - 1 +" call Decho("indx=".indx." (Pexplore while loop)") + endwhile + if indx < 0 | let indx= 0 | endif +" call Decho("Pexplore: indx= [w:netrw_explore_indx=".w:netrw_explore_indx."]=".indx) + + else + " Explore -- initialize + " build list of files to Explore with Nexplore/Pexplore +" call Decho("starpat=".starpat.": case Explore: initialize (indx=".indx.")") + let w:netrw_explore_indx= 0 + if !exists("b:netrw_curdir") + let b:netrw_curdir= getcwd() + endif +" call Decho("starpat=".starpat.": b:netrw_curdir<".b:netrw_curdir.">") + + " switch on starpat to build the w:netrw_explore_list of files + if starpat == 1 + " starpat=1: Explore *//pattern (current directory only search for files containing pattern) +" call Decho("starpat=".starpat.": build *//pattern list") + exe "vimgrep /".pattern."/gj ".b:netrw_curdir."/*" + let w:netrw_explore_list = map(getqflist(),'bufname(v:val.bufnr)') + if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif + + elseif starpat == 2 + " starpat=2: Explore **//pattern (recursive descent search for files containing pattern) +" call Decho("starpat=".starpat.": build **//pattern list") + try + exe "silent vimgrep /".pattern."/gj "."**/*" + catch /^Vim\%((\a\+)\)\=:E480/ + call netrw#ErrorMsg(s:WARNING,'no files matched pattern<'.pattern.'>',45) + if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif + silent! let @* = keepregstar + silent! let @+ = keepregstar + silent! let @/ = keepregslash +" call Dret("netrw#Explore : no files matched pattern") + return + endtry + let s:netrw_curdir = b:netrw_curdir + let w:netrw_explore_list = getqflist() + let w:netrw_explore_list = map(w:netrw_explore_list,'s:netrw_curdir."/".bufname(v:val.bufnr)') + + elseif starpat == 3 + " starpat=3: Explore */filepat (search in current directory for filenames matching filepat) +" call Decho("starpat=".starpat.": build */filepat list") + let dirname = substitute(dirname,'^\*/','','') + let w:netrw_explore_list= split(expand(b:netrw_curdir."/".dirname),'\n') + if &hls | let keepregslash= s:ExplorePatHls(dirname) | endif + + elseif starpat == 4 + " starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat) +" call Decho("starpat=".starpat.": build **/filepat list") + let w:netrw_explore_list= split(expand(b:netrw_curdir."/".dirname),'\n') + if &hls | let keepregslash= s:ExplorePatHls(dirname) | endif + endif " switch on starpat to build w:netrw_explore_list + + let w:netrw_explore_listlen = len(w:netrw_explore_list) +" call Decho("w:netrw_explore_list<".string(w:netrw_explore_list).">") +" call Decho("w:netrw_explore_listlen=".w:netrw_explore_listlen) + + if w:netrw_explore_listlen == 0 || (w:netrw_explore_listlen == 1 && w:netrw_explore_list[0] =~ '\*\*\/') + call netrw#ErrorMsg(s:WARNING,"no files matched",42) + silent! let @* = keepregstar + silent! let @+ = keepregstar + silent! let @/ = keepregslash +" call Dret("netrw#Explore : no files matched") + return + endif + endif " if indx ... endif + + " NetrwStatusLine support - for exploring support + let w:netrw_explore_indx= indx +" call Decho("explorelist<".join(w:netrw_explore_list,',')."> len=".w:netrw_explore_listlen) + + " wrap the indx around, but issue a note + if indx >= w:netrw_explore_listlen || indx < 0 +" call Decho("wrap indx (indx=".indx." listlen=".w:netrw_explore_listlen.")") + let indx = (indx < 0)? ( w:netrw_explore_listlen - 1 ) : 0 + let w:netrw_explore_indx= indx + call netrw#ErrorMsg(s:NOTE,"no more files match Explore pattern",43) + sleep 1 + endif + + exe "let dirfile= w:netrw_explore_list[".indx."]" +" call Decho("dirfile=w:netrw_explore_list[indx=".indx."]= <".dirfile.">") + let newdir= substitute(dirfile,'/[^/]*$','','e') +" call Decho("newdir<".newdir.">") + +" call Decho("calling LocalBrowseCheck(newdir<".newdir.">)") + call netrw#LocalBrowseCheck(newdir) + if !exists("w:netrw_liststyle") + let w:netrw_liststyle= g:netrw_liststyle + endif + if w:netrw_liststyle == s:THINLIST || w:netrw_liststyle == s:LONGLIST + call search('^'.substitute(dirfile,"^.*/","","").'\>',"W") + else + call search('\<'.substitute(dirfile,"^.*/","","").'\>',"w") + endif + let w:netrw_explore_mtchcnt = indx + 1 + let w:netrw_explore_bufnr = bufnr("%") + let w:netrw_explore_line = line(".") + call s:SetupNetrwStatusLine('%f %h%m%r%=%9*%{NetrwStatusLine()}') +" call Decho("explore: mtchcnt=".w:netrw_explore_mtchcnt." bufnr=".w:netrw_explore_bufnr." line#".w:netrw_explore_line) + + else +" call Decho("your vim does not have +path_extra") + if !exists("g:netrw_quiet") + call netrw#ErrorMsg(s:WARNING,"your vim needs the +path_extra feature for Exploring with **!",44) + endif + silent! let @* = keepregstar + silent! let @+ = keepregstar + silent! let @/ = keepregslash +" call Dret("netrw#Explore : missing +path_extra") + return + endif + + else +" call Decho("case Explore newdir<".dirname.">") + if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && dirname =~ '/' + silent! unlet w:netrw_treedict + silent! unlet w:netrw_treetop + endif + let newdir= dirname + if !exists("b:netrw_curdir") + call netrw#LocalBrowseCheck(getcwd()) + else + call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,newdir)) + endif + endif + + " visual display of **/ **// */ Exploration files + if exists("w:netrw_explore_indx") && exists("b:netrw_curdir") + if !exists("s:explore_prvdir") || s:explore_prvdir != b:netrw_curdir + " only update match list if current directory isn't the same as before + let s:explore_prvdir = b:netrw_curdir + let s:explore_match = "" + let dirlen = strlen(b:netrw_curdir) + if b:netrw_curdir !~ '/$' + let dirlen= dirlen + 1 + endif + let prvfname= "" + for fname in w:netrw_explore_list +" call Decho("fname<".fname.">") + if fname =~ '^'.b:netrw_curdir + if s:explore_match == "" + let s:explore_match= '\<'.escape(strpart(fname,dirlen),g:netrw_markfileesc."'".g:netrw_markfileesc."'").'\>' + else + let s:explore_match= s:explore_match.'\|\<'.escape(strpart(fname,dirlen),g:netrw_markfileesc."'".g:netrw_markfileesc."'").'\>' + endif + elseif fname !~ '^/' && fname != prvfname + if s:explore_match == "" + let s:explore_match= '\<'.escape(fname,g:netrw_markfileesc."'".g:netrw_markfileesc."'").'\>' + else + let s:explore_match= s:explore_match.'\|\<'.escape(fname,g:netrw_markfileesc."'".g:netrw_markfileesc."'").'\>' + endif + endif + let prvfname= fname + endfor +" call Decho("explore_match<".s:explore_match.">") + exe "2match netrwMarkFile /".s:explore_match."/" + endif + echo "==Pexplore ==Nexplore" + else + 2match none + if exists("s:explore_match") | unlet s:explore_match | endif + if exists("s:explore_prvdir") | unlet s:explore_prvdir | endif + echo " " +" call Decho("cleared explore match list") + endif + + silent! let @* = keepregstar + silent! let @+ = keepregstar + silent! let @/ = keepregslash +" call Dret("netrw#Explore : @/<".@/.">") +endfun + " --------------------------------------------------------------------- " s:NetrwHide: this function is invoked by the "a" map for browsing {{{2 " and switches the hiding mode. The actual hiding is done by @@ -2665,12 +3342,12 @@ fun! s:NetrwHide(islocal) " call Dfunc("NetrwHide(islocal=".a:islocal.") g:netrw_hide=".g:netrw_hide) let svpos= netrw#NetrwSavePosn() - if exists("s:netrwmarkfilelist") -" call Decho(((g:netrw_hide == 1)? "unhide" : "hide")." files in markfilelist<".string(s:netrwmarkfilelist).">") + if exists("s:netrwmarkfilelist_{bufnr('%')}") +" call Decho(((g:netrw_hide == 1)? "unhide" : "hide")." files in markfilelist<".string(s:netrwmarkfilelist_{bufnr("%")}).">") " call Decho("g:netrw_list_hide<".g:netrw_list_hide.">") " hide the files in the markfile list - for fname in s:netrwmarkfilelist + for fname in s:netrwmarkfilelist_{bufnr("%")} " call Decho("match(g:netrw_list_hide<".g:netrw_list_hide.'> fname<\<'.fname.'\>>)='.match(g:netrw_list_hide,'\<'.fname.'\>')." isk=".&isk) if match(g:netrw_list_hide,'\<'.fname.'\>') != -1 " remove fname from hiding list @@ -2688,8 +3365,8 @@ fun! s:NetrwHide(islocal) " call Decho("hide: g:netrw_list_hide<".g:netrw_list_hide.">") endif endfor - unlet s:netrwmarkfilelist - unlet s:netrwmarkfilemtch + unlet s:netrwmarkfilelist_{bufnr("%")} + unlet s:netrwmarkfilemtch_{bufnr("%")} 2match none let g:netrw_hide= 1 @@ -2710,6 +3387,28 @@ fun! s:NetrwHide(islocal) " call Dret("NetrwHide") endfun +" --------------------------------------------------------------------- +" s:NetrwHidden: invoked by "gh" {{{2 +fun! s:NetrwHidden(islocal) +" call Dfunc("s:NetrwHidden()") + " save current position + let svpos= netrw#NetrwSavePosn() + + if g:netrw_list_hide =~ '\(^\|,\)\\(^\\|\\s\\s\\)\\zs\\.\\S\\+' + " remove pattern from hiding list + let g:netrw_list_hide= substitute(g:netrw_list_hide,'\(^\|,\)\\(^\\|\\s\\s\\)\\zs\\.\\S\\+','','') + elseif strlen(g:netrw_list_hide) >= 1 + let g:netrw_list_hide= g:netrw_list_hide . ',\(^\|\s\s\)\zs\.\S\+' + else + let g:netrw_list_hide= '\(^\|\s\s\)\zs\.\S\+' + endif + + " refresh screen and return to saved position + call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) + call netrw#NetrwRestorePosn(svpos) +" call Dret("s:NetrwHidden") +endfun + " --------------------------------------------------------------------- " s:NetrwLeftmouse: handles the when in a netrw browsing window {{{2 fun! s:NetrwLeftmouse(islocal) @@ -2809,7 +3508,93 @@ fun! s:NetSortSequence(islocal) endfun " --------------------------------------------------------------------- -" s:NetrwMarkFile: This function is invoked by mf, and is used to both {{{2 +" s:NetrwMakeDir: this function makes a directory (both local and remote) {{{2 +fun! s:NetrwMakeDir(usrhost) +" call Dfunc("NetrwMakeDir(usrhost<".a:usrhost.">)") + + " get name of new directory from user. A bare will skip. + " if its currently a directory, also request will be skipped, but with + " a message. + call inputsave() + let newdirname= input("Please give directory name: ") + call inputrestore() +" call Decho("newdirname<".newdirname.">") + + if newdirname == "" +" call Dret("NetrwMakeDir : user aborted with bare ") + return + endif + + if a:usrhost == "" + + " Local mkdir: + " sanity checks + let fullnewdir= b:netrw_curdir.'/'.newdirname +" call Decho("fullnewdir<".fullnewdir.">") + if isdirectory(fullnewdir) + if !exists("g:netrw_quiet") + call netrw#ErrorMsg(s:WARNING,"<".newdirname."> is already a directory!",24) + endif +" call Dret("NetrwMakeDir : directory<".newdirname."> exists previously") + return + endif + if s:FileReadable(fullnewdir) + if !exists("g:netrw_quiet") + call netrw#ErrorMsg(s:WARNING,"<".newdirname."> is already a file!",25) + endif +" call Dret("NetrwMakeDir : file<".newdirname."> exists previously") + return + endif + + " requested new local directory is neither a pre-existing file or + " directory, so make it! + if exists("*mkdir") + call mkdir(fullnewdir,"p") + else + let netrw_origdir= s:NetrwGetcwd(1) + exe 'keepjumps cd '.b:netrw_curdir +" call Decho("netrw_origdir<".netrw_origdir.">: cd b:netrw_curdir<".b:netrw_curdir.">") +" call Decho("exe silent! !".g:netrw_local_mkdir.' '.g:netrw_shq.newdirname.g:netrw_shq) + exe "silent! !".g:netrw_local_mkdir.' '.g:netrw_shq.newdirname.g:netrw_shq + if !g:netrw_keepdir + exe 'keepjumps cd '.netrw_origdir +" call Decho("netrw_keepdir=".g:netrw_keepdir.": cd ".netrw_origdir." getcwd<".getcwd().">") + endif + endif + + if v:shell_error == 0 + " refresh listing +" call Decho("refresh listing") + let svpos= netrw#NetrwSavePosn() + call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./')) + call netrw#NetrwRestorePosn(svpos) + elseif !exists("g:netrw_quiet") + call netrw#ErrorMsg(s:ERROR,"unable to make directory<".newdirname.">",26) + endif +" redraw! + + else + " Remote mkdir: + let mkdircmd = s:MakeSshCmd(g:netrw_mkdir_cmd) + let newdirname= substitute(b:netrw_curdir,'^\%(.\{-}/\)\{3}\(.*\)$','\1','').newdirname +" call Decho("exe silent! !".mkdircmd." ".g:netrw_shq.newdirname.g:netrw_shq) + exe "silent! !".mkdircmd." ".g:netrw_shq.newdirname.g:netrw_shq + if v:shell_error == 0 + " refresh listing + let svpos= netrw#NetrwSavePosn() + call s:NetrwRefresh(0,s:NetrwBrowseChgDir(0,'./')) + call netrw#NetrwRestorePosn(svpos) + elseif !exists("g:netrw_quiet") + call netrw#ErrorMsg(s:ERROR,"unable to make directory<".newdirname.">",27) + endif +" redraw! + endif + +" call Dret("NetrwMakeDir") +endfun + +" --------------------------------------------------------------------- +" s:NetrwMarkFile: (invoked by mf) This function is used to both {{{2 " mark and unmark files. If a markfile list exists, " then the rename and delete functions will use it instead " of whatever may happen to be under the cursor at that @@ -2817,63 +3602,68 @@ endfun " shift-leftmouse may also be used to mark files. fun! s:NetrwMarkFile(islocal,fname) " call Dfunc("s:NetrwMarkFile(islocal=".a:islocal." fname<".a:fname.">)") -" call Decho("b:netrw_curdir<".b:netrw_curdir.">") - if a:islocal && exists("b:netrw_curdir") - exe "cd ".b:netrw_curdir - endif + let curbufnr= bufnr("%") + if exists("s:netrwmarkfilelist_{curbufnr}") +" call Decho("starting s:netrwmarkfilelist_{curbufnr}<".string(s:netrwmarkfilelist_{curbufnr}).">") +" call Decho("starting s:netrwmarkfilemtch_{curbufnr}<".s:netrwmarkfilemtch_{curbufnr}.">") - if exists("s:netrwmarkfilelist") -" call Decho("starting s:netrwmarkfilelist<".string(s:netrwmarkfilelist).">") -" call Decho("starting s:netrwmarkfilemtch<".s:netrwmarkfilemtch.">") - - if index(s:netrwmarkfilelist,a:fname) == -1 + if index(s:netrwmarkfilelist_{curbufnr},a:fname) == -1 " append filename to list -" call Decho("append filename<".a:fname."> to markfilelist<".string(s:netrwmarkfilelist).">") - call add(s:netrwmarkfilelist,a:fname) - let s:netrwmarkfilemtch= s:netrwmarkfilemtch.'\|\<'.escape(a:fname,'*./[\').'\>' +" call Decho("append filename<".a:fname."> to markfilelist<".string(s:netrwmarkfilelist_{curbufnr}).">") + call add(s:netrwmarkfilelist_{curbufnr},a:fname) + let s:netrwmarkfilemtch_{curbufnr}= s:netrwmarkfilemtch_{curbufnr}.'\|\<'.escape(a:fname,g:netrw_markfileesc."'".g:netrw_markfileesc."'").'\>' else " remove filename from list -" call Decho("remove filename<".a:fname."> from markfilelist<".string(s:netrwmarkfilelist).">") - call filter(s:netrwmarkfilelist,'v:val != a:fname') - if s:netrwmarkfilelist == [] - unlet s:netrwmarkfilelist - unlet s:netrwmarkfilemtch +" call Decho("remove filename<".a:fname."> from markfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}).">") + call filter(s:netrwmarkfilelist_{curbufnr},'v:val != a:fname') + if s:netrwmarkfilelist_{curbufnr} == [] +" call Decho("markfile list now empty, unlet s:netrwmarkfilelist_".curbufnr." and ...mtch_".curbufnr) + unlet s:netrwmarkfilelist_{curbufnr} + unlet s:netrwmarkfilemtch_{curbufnr} else - let s:netrwmarkfilemtch= substitute(s:netrwmarkfilemtch,'\\<'.a:fname.'\\>','','') - let s:netrwmarkfilemtch= substitute(s:netrwmarkfilemtch,'\\|\\|','\\|','g') - let s:netrwmarkfilemtch= substitute(s:netrwmarkfilemtch,'^\\|\|\\|$','','') -" call Decho("ending s:netrwmarkfilelist<".string(s:netrwmarkfilelist).">") -" call Decho("ending s:netrwmarkfilemtch<".s:netrwmarkfilemtch.">") +" call Decho("rebuild s:netrwmarkfilemtch_".curbufnr) + let s:netrwmarkfilemtch_{curbufnr}= "" + let first = 1 + for fname in s:netrwmarkfilelist_{curbufnr} + if first + let s:netrwmarkfilemtch_{curbufnr}= s:netrwmarkfilemtch_{curbufnr}.'\<'.escape(fname,g:netrw_markfileesc."'".g:netrw_markfileesc."'").'\>' + else + let s:netrwmarkfilemtch_{curbufnr}= s:netrwmarkfilemtch_{curbufnr}.'\|\<'.escape(fname,g:netrw_markfileesc."'".g:netrw_markfileesc."'").'\>' + endif + let first= 0 + endfor +" call Decho("ending s:netrwmarkfilelist_{curbufnr}<".string(s:netrwmarkfilelist_{curbufnr}).">") +" call Decho("ending s:netrwmarkfilemtch_{curbufnr}<".s:netrwmarkfilemtch_{curbufnr}.">") endif endif else " call Decho("add fname<".a:fname."> to new markfilelist") - let s:netrwmarkfilelist= [] - call add(s:netrwmarkfilelist,a:fname) -" call Decho("ending s:netrwmarkfilelist<".string(s:netrwmarkfilelist).">") + let s:netrwmarkfilelist_{curbufnr}= [] + call add(s:netrwmarkfilelist_{curbufnr},a:fname) +" call Decho("ending s:netrwmarkfilelist_{curbufnr}<".string(s:netrwmarkfilelist_{curbufnr}).">") if a:fname =~ '/$' - let s:netrwmarkfilemtch= '\<'.escape(a:fname,'*./[\') + let s:netrwmarkfilemtch_{curbufnr}= '\<'.escape(a:fname,g:netrw_markfileesc) else - let s:netrwmarkfilemtch= '\<'.escape(a:fname,'*./[\').'\>' + let s:netrwmarkfilemtch_{curbufnr}= '\<'.escape(a:fname,g:netrw_markfileesc).'\>' endif -" call Decho("ending s:netrwmarkfilemtch<".s:netrwmarkfilemtch.">") +" call Decho("ending s:netrwmarkfilemtch_{curbufnr}<".s:netrwmarkfilemtch_{curbufnr}.">") endif - if exists("s:netrwmarkfilemtch") && s:netrwmarkfilemtch != "" -" call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch."/") - exe "2match netrwMarkFile /".s:netrwmarkfilemtch."/" + if exists("s:netrwmarkfilemtch_{curbufnr}") && s:netrwmarkfilemtch_{curbufnr} != "" +" call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{curbufnr}."/") + exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{curbufnr}."/" else " call Decho("2match none") 2match none endif -" call Dret("s:NetrwMarkFile : netrwmarkfilelist".(exists("s:netrwmarkfilelist")? string(s:netrwmarkfilelist) : " doesn't exist")) +" call Dret("s:NetrwMarkFile : netrwmarkfilelist".(exists("s:netrwmarkfilelist_{curbufnr}")? string(s:netrwmarkfilelist_{curbufnr}) : " doesn't exist")) endfun " --------------------------------------------------------------------- -" s:NetrwMarkFileCompress: This function, invoked by mz, is used to {{{2 +" s:NetrwMarkFileCompress: (invoked by mz) This function is used to {{{2 " compress/decompress files using the programs " in g:netrw_compress and g:netrw_uncompress, " using g:netrw_compress_suffix to know which to @@ -2882,22 +3672,28 @@ endfun " g:netrw_decompress = { ".gz" : "gunzip" , ".bz2" : "bunzip2" , ".zip" : "unzip" , ".tar" : "tar -xf"} fun! s:NetrwMarkFileCompress(islocal) " call Dfunc("s:NetrwMarkFileCompress(islocal=".a:islocal.")") - let svpos= netrw#NetrwSavePosn() - if a:islocal && exists("b:netrw_curdir") - exe "cd ".b:netrw_curdir - endif + let svpos = netrw#NetrwSavePosn() + let curdir = b:netrw_curdir + let curbufnr = bufnr("%") - if exists("s:netrwmarkfilelist") && exists("g:netrw_compress") && exists("g:netrw_decompress") - for fname in s:netrwmarkfilelist + if exists("s:netrwmarkfilelist_{curbufnr}") && exists("g:netrw_compress") && exists("g:netrw_decompress") + for fname in s:netrwmarkfilelist_{curbufnr} " for every filename in the marked list for sfx in sort(keys(g:netrw_decompress)) if fname =~ '\'.sfx.'$' " fname has a suffix indicating that its compressed; apply associated decompression routine let exe= g:netrw_decompress[sfx] " call Decho("fname<".fname."> is compressed so decompress with <".exe.">") + if a:islocal + if g:netrw_keepdir + let fname= s:ComposePath(curdir,fname) + endif + else + let fname= b:netrw_curdir.fname + endif if executable(exe) if a:islocal - call system(exe." ".fname) + call system(exe." ".fname) else call s:RemoteSystem(exe." ".fname) endif @@ -2911,14 +3707,14 @@ fun! s:NetrwMarkFileCompress(islocal) unlet exe elseif a:islocal " fname not a compressed file, so compress it - call system(g:netrw_compress." ".fname) + call system(g:netrw_compress." ".s:ComposePath(b:netrw_curdir,fname)) else " fname not a compressed file, so compress it call s:RemoteSystem(g:netrw_compress." ".fname) endif endfor - unlet s:netrwmarkfilelist - unlet s:netrwmarkfilemtch + unlet s:netrwmarkfilelist_{curbufnr} + unlet s:netrwmarkfilemtch_{curbufnr} 2match none call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) call netrw#NetrwRestorePosn(svpos) @@ -2927,7 +3723,7 @@ fun! s:NetrwMarkFileCompress(islocal) endfun " --------------------------------------------------------------------- -" s:NetrwMarkFileCopy: copy marked files to target {{{2 +" s:NetrwMarkFileCopy: (invoked by mc) copy marked files to target {{{2 " If no marked files, then set up directory as the " target. Currently does not support copying entire " directories. @@ -2935,20 +3731,23 @@ endfun " 0=failure fun! s:NetrwMarkFileCopy(islocal) " call Dfunc("s:NetrwMarkFileCopy(islocal=".a:islocal.") target<".(exists("s:netrwmftgt")? s:netrwmftgt : '---').">") - if a:islocal && exists("b:netrw_curdir") - exe "cd ".b:netrw_curdir - endif - if exists("s:netrwmarkfilelist") -" call Decho("s:netrwmarkfilelist<".string(s:netrwmarkfilelist).">") -" call Decho("s:netrwmarkfilemtch<".string(s:netrwmarkfilemtch).">") - let svpos= netrw#NetrwSavePosn() + " s:netrwmarkfilelist_{bufnr("%")}: the List of marked files + let curbufnr= bufnr("%") + if exists("s:netrwmarkfilelist_{curbufnr}") +" call Decho("s:netrwmarkfilelist_{curbufnr}<".string(s:netrwmarkfilelist_{curbufnr}).">") +" call Decho("s:netrwmarkfilemtch_{curbufnr}<".string(s:netrwmarkfilemtch_{curbufnr}).">") + let svpos = netrw#NetrwSavePosn() + let curdir = b:netrw_curdir + " s:netrwmftgt : name of directory to copy files to + " s:netrwmfloc : =0 target directory is remote + " =1 target directory is local if exists("s:netrwmftgt") && exists("s:netrwmfloc") " call Decho("s:netrwmftgt<".s:netrwmftgt.">") " call Decho("s:netrwmfloc=".s:netrwmfloc) - for fname in s:netrwmarkfilelist + for fname in s:netrwmarkfilelist_{curbufnr} " call Decho("s:NetrwMarkFileCopy: fname<".fname.">") " sanity check @@ -2960,10 +3759,10 @@ fun! s:NetrwMarkFileCopy(islocal) if a:islocal && s:netrwmfloc " local to local copy -" call Decho("local to local copy: getcwd<".getcwd()."> b:netrw_curdir<".b:netrw_curdir.">") +" call Decho("local to local copy: from b:netrw_curdir<".b:netrw_curdir."> fname<".fname."> to s:netrwmftgt<".s:netrwmftgt.">") if executable(g:netrw_localcopycmd) -" call Decho("let ret= system(".g:netrw_localcopycmd." ".fname." ".s:netrwmftgt.")") - let ret= system(g:netrw_localcopycmd." ".fname." ".s:netrwmftgt) +" call Decho("let ret= system(".g:netrw_localcopycmd." ".s:ComposePath(b:netrw_curdir,fname)." ".s:netrwmftgt.")") + let ret= system(g:netrw_localcopycmd." ".s:ComposePath(curdir,fname)." ".s:netrwmftgt) if v:shell_error < 0 call netrw#ErrorMsg(s:ERROR,"command<".g:netrw_localcopycmd."> failed, aborting",54) break @@ -2981,7 +3780,7 @@ fun! s:NetrwMarkFileCopy(islocal) elseif a:islocal && !s:netrwmfloc " local to remote copy " call Decho("local to remote copy: getcwd<".getcwd()."> b:netrw_curdir<".b:netrw_curdir.">") - call s:NetrwUpload(fname,s:netrwmftgt) + call s:NetrwUpload(s:ComposePath(curdir,fname),s:netrwmftgt) else " remote to remote copy @@ -2992,13 +3791,13 @@ fun! s:NetrwMarkFileCopy(islocal) " unmark marked file list (although I expect s:NetrwUpload() " to do it, I'm just making sure) - if exists("s:netrwmarkfilelist") - unlet s:netrwmarkfilelist - unlet s:netrwmarkfilemtch + if exists("s:netrwmarkfilelist_{curbufnr}") + unlet s:netrwmarkfilelist_{curbufnr} + unlet s:netrwmarkfilemtch_{curbufnr} 2match none endif else - call netrw#ErrorMsg(s:ERROR,"missing a markfile copy target!",56) + call netrw#ErrorMsg(s:ERROR,"missing a markfile copy target! (see help for netrw-mt)",56) endif " refresh the listing @@ -3013,21 +3812,23 @@ fun! s:NetrwMarkFileCopy(islocal) endfun " --------------------------------------------------------------------- -" s:NetrwMarkFileDiff: This function, invoked by md, is used to {{{2 +" s:NetrwMarkFileDiff: (invoked by md) This function is used to {{{2 " invoke vim's diff mode on the marked files. " Either two or three files can be so handled. fun! s:NetrwMarkFileDiff(islocal) " call Dfunc("s:NetrwMarkFileDiff(islocal=".a:islocal.") b:netrw_curdir<".b:netrw_curdir.">") - if a:islocal && exists("b:netrw_curdir") - exe "cd ".b:netrw_curdir - endif - if exists("s:netrwmarkfilelist") - let curdir= b:netrw_curdir + let curbufnr= bufnr("%") + if exists("s:netrwmarkfilelist_{curbufnr}") - let cnt= 0 - for fname in s:netrwmarkfilelist + let cnt = 0 + let curdir = b:netrw_curdir + for fname in s:netrwmarkfilelist_{curbufnr} let cnt= cnt + 1 - if !a:islocal + if a:islocal + if g:netrw_keepdir + let fname= s:ComposePath(curdir,fname) + endif + else let fname= curdir.fname endif if cnt == 1 @@ -3044,27 +3845,34 @@ fun! s:NetrwMarkFileDiff(islocal) break endif endfor - unlet s:netrwmarkfilelist - unlet s:netrwmarkfilemtch + unlet s:netrwmarkfilelist_{curbufnr} + unlet s:netrwmarkfilemtch_{curbufnr} 2match none endif " call Dret("s:NetrwMarkFileDiff") endfun " --------------------------------------------------------------------- -" s:NetrwMarkFileEdit: put marked files on arg list and start editing them {{{2 +" s:NetrwMarkFileEdit: (invoked by me) put marked files on arg list and start editing them {{{2 fun! s:NetrwMarkFileEdit(islocal) " call Dfunc("s:NetrwMarkFileEdit(islocal=".a:islocal.")") - if a:islocal && exists("b:netrw_curdir") - exe "cd ".b:netrw_curdir - endif - if exists("s:netrwmarkfilelist") - call s:SetRexDir(a:islocal,b:netrw_curdir) - let flist= substitute(escape(join(s:netrwmarkfilelist,"\t"),' '),"\t",' ','g') + let curdir = b:netrw_curdir + let curbufnr = bufnr("%") + if exists("s:netrwmarkfilelist_{curbufnr}") + call s:SetRexDir(a:islocal,curdir) + if a:islocal && g:netrw_keepdir + " use complete paths if its local and keepdir enabled + let flist= "" + for fname in s:netrwmarkfilelist_{curbufnr} + let flist= flist." ".s:ComposePath(curdir,fname) + endfor + else + let flist= substitute(escape(join(s:netrwmarkfilelist_{curbufnr},"\t"),' '),"\t",' ','g') + endif " unmark marked file list - unlet s:netrwmarkfilelist - unlet s:netrwmarkfilemtch + unlet s:netrwmarkfilelist_{curbufnr} + unlet s:netrwmarkfilemtch_{curbufnr} 2match none " call Decho("exe silent args ".flist) exe "silent args ".flist @@ -3074,15 +3882,14 @@ fun! s:NetrwMarkFileEdit(islocal) endfun " --------------------------------------------------------------------- -" s:NetrwMarkFileExe: execute arbitrary command on marked files, one at a time {{{2 +" s:NetrwMarkFileExe: (invoked by mx) execute arbitrary command on marked files, one at a time {{{2 fun! s:NetrwMarkFileExe(islocal) " call Dfunc("s:NetrwMarkFileExe(islocal=".a:islocal.")") - let svpos= netrw#NetrwSavePosn() - if a:islocal && exists("b:netrw_curdir") - exe "cd ".b:netrw_curdir - endif + let svpos = netrw#NetrwSavePosn() + let curdir = b:netrw_curdir + let curbufnr = bufnr("%") - if exists("s:netrwmarkfilelist") + if exists("s:netrwmarkfilelist_{curbufnr}") " get the command call inputsave() let cmd= input("Enter command: ","","file") @@ -3091,7 +3898,14 @@ fun! s:NetrwMarkFileExe(islocal) " apply command to marked files. Substitute: filename -> % " If no %, then append a space and the filename to the command - for fname in s:netrwmarkfilelist + for fname in s:netrwmarkfilelist_{curbufnr} + if a:islocal + if g:netrw_keepdir + let fname= s:ComposePath(curdir,fname) + endif + else + let fname= b:netrw_curdir.fname + endif if cmd =~ '%' let xcmd= substitute(cmd,'%',fname,'g') else @@ -3113,44 +3927,112 @@ fun! s:NetrwMarkFileExe(islocal) endfor " unmark marked file list - unlet s:netrwmarkfilelist - unlet s:netrwmarkfilemtch + unlet s:netrwmarkfilelist_{curbufnr} + unlet s:netrwmarkfilemtch_{curbufnr} 2match none " refresh the listing call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) call netrw#NetrwRestorePosn(svpos) + else + call netrw#ErrorMsg(s:ERROR,"no files marked!",59) endif " call Dret("s:NetrwMarkFileExe") endfun " --------------------------------------------------------------------- -" s:NetrwMarkFileMove: execute arbitrary command on marked files, one at a time {{{2 -fun! s:NetrwMarkFileMove(islocal) -" call Dfunc("s:NetrwMarkFileMove(islocal=".a:islocal.")") - if a:islocal && exists("b:netrw_curdir") - exe "cd ".b:netrw_curdir +" s:NetrwMarkHideSfx: (invoked by mh) (un)hide files having same suffix +" as the marked file(s) (toggles suffix presence) +fun! s:NetrwMarkHideSfx(islocal) +" call Dfunc("s:NetrwMarkHideSfx(islocal=".a:islocal.")") + let svpos = netrw#NetrwSavePosn() + let curbufnr = bufnr("%") + + " s:netrwmarkfilelist_{curbufnr}: the List of marked files + if exists("s:netrwmarkfilelist_{curbufnr}") + + for fname in s:netrwmarkfilelist_{curbufnr} +" call Decho("s:NetrwMarkFileCopy: fname<".fname.">") + " construct suffix pattern + if fname =~ '\.' + let sfxpat= "^.*".substitute(fname,'^.*\(\.[^. ]\+\)$','\1','') + else + let sfxpat= '^\%(\%(\.\)\@!.\)*$' + endif + " determine if its in the hiding list or not + let inhidelist= 0 + if g:netrw_list_hide != "" + let itemnum = 0 + let hidelist= split(g:netrw_list_hide,',') + for hidepat in hidelist + if sfxpat == hidepat + let inhidelist= 1 + break + endif + let itemnum= itemnum + 1 + endfor + endif +" call Decho("fname<".fname."> inhidelist=".inhidelist." sfxpat<".sfxpat.">") + if inhidelist + " remove sfxpat from list + call remove(hidelist,itemnum) + let g:netrw_list_hide= join(hidelist,",") + elseif g:netrw_list_hide != "" + " append sfxpat to non-empty list + let g:netrw_list_hide= g:netrw_list_hide.",".sfxpat + else + " set hiding list to sfxpat + let g:netrw_list_hide= sfxpat + endif + endfor + + " refresh the listing + call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) + call netrw#NetrwRestorePosn(svpos) + else + call netrw#ErrorMsg(s:ERROR,"no files marked!",59) endif - if exists("s:netrwmarkfilelist") - let svpos= netrw#NetrwSavePosn() +" call Dret("s:NetrwMarkHideSfx") +endfun + +" --------------------------------------------------------------------- +" s:NetrwMarkFileMove: (invoked by mm) execute arbitrary command on marked files, one at a time {{{2 +fun! s:NetrwMarkFileMove(islocal) +" call Dfunc("s:NetrwMarkFileMove(islocal=".a:islocal.")") + + let curbufnr= bufnr("%") + if exists("s:netrwmarkfilelist_{curbufnr}") + let svpos = netrw#NetrwSavePosn() + let curdir = b:netrw_curdir if exists("s:netrwmftgt") && exists("s:netrwmfloc") - if a:islocal && s:netrwmfloc - " local to local move + for fname in s:netrwmarkfilelist_{curbufnr} +" call Decho("s:NetrwMarkFileMove: fname<".fname.">") + if a:islocal + if g:netrw_keepdir + let fname= s:ComposePath(curdir,fname) + endif + else + let fname= curdir.fname + endif + + if a:islocal && s:netrwmfloc + " local to local move if executable(g:netrw_localmovecmd) " call Decho("let ret= system(".g:netrw_localmovecmd." ".fname." ".s:netrwmftgt.")") let ret= system(g:netrw_localmovecmd." ".fname." ".s:netrwmftgt) if v:shell_error < 0 - call netrw#ErrorMsg(s:ERROR,"command<".g:netrw_localmovecmd."> failed, aborting",54) + call netrw#ErrorMsg(s:ERROR,"command<".g:netrw_localmovecmd."> failed, aborting",54) break endif else call netrw#ErrorMsg(s:ERROR,"command<".g:netrw_localmovecmd."> is not executable!",57) break endif - else + else + " copy file, then remove original " remote to local move " local to remote move " remote to remote move @@ -3165,30 +4047,48 @@ fun! s:NetrwMarkFileMove(islocal) call s:NetrwRemoteRm("---","---") endif endif - endif + endif + endfor + endif - " First, do a copy, then (attempt to) do a delete + " unmark marked file list + if exists("s:netrwmarkfilelist_{curbufnr}") + unlet s:netrwmarkfilelist_{curbufnr} + unlet s:netrwmarkfilemtch_{curbufnr} + 2match none + endif + " refresh the listing and restore cursor position + call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) call netrw#NetrwRestorePosn(svpos) + else + call netrw#ErrorMsg(s:ERROR,"no files marked!",59) endif " call Dret("s:NetrwMarkFileMove") endfun " --------------------------------------------------------------------- -" s:NetrwMarkFilePrint: This function, invoked by mp, prints marked files {{{2 +" s:NetrwMarkFilePrint: (invoked by mp) This function prints marked files {{{2 " using the hardcopy command fun! s:NetrwMarkFilePrint(islocal) " call Dfunc("s:NetrwMarkFilePrint(islocal=".a:islocal.")") - if a:islocal && exists("b:netrw_curdir") - exe "cd ".b:netrw_curdir - endif - if exists("s:netrwmarkfilelist") - let netrwmarkfilelist= s:netrwmarkfilelist - unlet s:netrwmarkfilelist - unlet s:netrwmarkfilemtch + let curbufnr= bufnr("%") + if exists("s:netrwmarkfilelist_{curbufnr}") + let netrwmarkfilelist = s:netrwmarkfilelist_{curbufnr} + let curdir = b:netrw_curdir + unlet s:netrwmarkfilelist_{curbufnr} + unlet s:netrwmarkfilemtch_{curbufnr} for fname in netrwmarkfilelist + if a:islocal + if g:netrw_keepdir + let fname= s:ComposePath(curdir,fname) + endif + else + let fname= curdir.fname + endif 1split + " the autocmds will handle both local and remote files exe "silent e ".fname " call Decho("hardcopy ".fname) hardcopy @@ -3200,16 +4100,11 @@ fun! s:NetrwMarkFilePrint(islocal) endfun " --------------------------------------------------------------------- - -" =========================================== -" s:NetrwMarkFileRegexp: This function, invoked by mr, is used to mark {{{2 +" s:NetrwMarkFileRegexp: (invoked by mr) This function is used to mark {{{2 " files when given a regexp (for which a prompt is " issued). fun! s:NetrwMarkFileRegexp(islocal) " call Dfunc("s:NetrwMarkFileRegexp(islocal=".a:islocal.")") - if a:islocal && exists("b:netrw_curdir") - exe "cd ".b:netrw_curdir - endif " get the regular expression call inputsave() @@ -3218,8 +4113,8 @@ fun! s:NetrwMarkFileRegexp(islocal) if a:islocal " get the matching list of files using local glob() - let dirname = escape(b:netrw_curdir,s:netrw_glob_escape) - let filelist = glob(s:ComposePath(dirname,regexp)) + let dirname = escape(b:netrw_curdir,s:netrw_glob_escape) + let filelist = glob(s:ComposePath(dirname,regexp)) if filelist != "" let filelist= filelist."\n" endif @@ -3245,6 +4140,7 @@ fun! s:NetrwMarkFileRegexp(islocal) let areg = @a silent %y a set ei=all ma +" call Decho("set ei=all ma") 1split enew silent norm! "ap @@ -3275,21 +4171,53 @@ fun! s:NetrwMarkFileRegexp(islocal) endfun " --------------------------------------------------------------------- -" s:NetrwMarkFileTag: This function, invoked by mT, applies {{{2 +" s:NetrwMarkFileSource: (invoked by ms) This function sources marked files {{{2 +fun! s:NetrwMarkFileSource(islocal) +" call Dfunc("s:NetrwMarkFileSource(islocal=".a:islocal.")") + let curbufnr= bufnr("%") + if exists("s:netrwmarkfilelist_{curbufnr}") + let netrwmarkfilelist = s:netrwmarkfilelist_{bufnr("%")} + let curdir = b:netrw_curdir + unlet s:netrwmarkfilelist_{curbufnr} + unlet s:netrwmarkfilemtch_{curbufnr} + for fname in netrwmarkfilelist + if a:islocal + if g:netrw_keepdir + let fname= s:ComposePath(curdir,fname) + endif + else + let fname= curdir.fname + endif + " the autocmds will handle sourcing both local and remote files + exe "so ".fname + endfor + 2match none + endif +" call Dret("s:NetrwMarkFileSource") +endfun + +" --------------------------------------------------------------------- +" s:NetrwMarkFileTag: (invoked by mt) This function applies {{{2 " g:netrw_ctags to marked files fun! s:NetrwMarkFileTag(islocal) " call Dfunc("s:NetrwMarkFileTag(islocal=".a:islocal.")") - let svpos= netrw#NetrwSavePosn() - if a:islocal && exists("b:netrw_curdir") - exe "cd ".b:netrw_curdir - endif + let svpos = netrw#NetrwSavePosn() + let curdir = b:netrw_curdir + let curbufnr = bufnr("%") - if exists("s:netrwmarkfilelist") -" call Decho("s:netrwmarkfilelist<".string(s:netrwmarkfilelist).">") - let netrwmarkfilelist= string(s:netrwmarkfilelist) - unlet s:netrwmarkfilelist - unlet s:netrwmarkfilemtch - let netrwmarkfilelist= substitute(netrwmarkfilelist,'[[\],]','','g') + if exists("s:netrwmarkfilelist_{curbufnr}") +" call Decho("s:netrwmarkfilelist_{curbufnr}<".string(s:netrwmarkfilelist_{curbufnr}).">") + if a:islocal && g:netrw_keepdir + let netrwmarkfilelist= "" + for fname in s:netrwmarkfilelist_{curbufnr} + let netrwmarkfilelist= netrwmarkfilelist." ".s:ComposePath(curdir,fname) + endfor + else + let netrwmarkfilelist= string(s:netrwmarkfilelist_{curbufnr}) + let netrwmarkfilelist= substitute(netrwmarkfilelist,'[[\],]','','g') + endif + unlet s:netrwmarkfilelist_{curbufnr} + unlet s:netrwmarkfilemtch_{curbufnr} " call Decho("netrwmarkfilelist<".netrwmarkfilelist.">") if a:islocal @@ -3322,42 +4250,175 @@ fun! s:NetrwMarkFileTag(islocal) endfun " --------------------------------------------------------------------- - " s:NetrwMarkFileTgt: {{{2 +" s:NetrwMarkFileTgt: (invoked by mt) This function sets up a marked file target {{{2 +" Sets up two variables, +" s:netrwmftgt : holds the target directory +" s:netrwmfloc : 0=target directory is remote +" 1=target directory is local fun! s:NetrwMarkFileTgt(islocal) " call Dfunc("s:NetrwMarkFileTgt(islocal=".a:islocal.")") - let svpos= netrw#NetrwSavePosn() - if a:islocal && exists("b:netrw_curdir") - exe "cd ".b:netrw_curdir - endif + let svpos = netrw#NetrwSavePosn() + let curdir = b:netrw_curdir + let hadtgt = exists("s:netrwmftgt") + + " set up target + if line(".") < w:netrw_bannercnt + " if cursor in banner region, use b:netrw_curdir for the target + let s:netrwmftgt= b:netrw_curdir +" call Decho("inbanner: s:netrwmftgt<".s:netrwmftgt.">") - if exists("s:netrwmftgt") || exists("s:netrwmfloc") -" call Decho("s:netrwmftgt<".s:netrwmftgt."> exists; removing it") - silent! unlet s:netrwmftgt s:netrwmfloc else -" call Decho("s:netrwmftgt doesn't exist; setting it to <".b:netrw_curdir.">") - let s:netrwmftgt = b:netrw_curdir - let s:netrwmfloc = a:islocal - if g:netrw_cygwin - let s:netrwmftgt= substitute(system("cygpath ".b:netrw_curdir),'\n$','','') + " get word under cursor. + " * If directory, use it for the target. + " * If file, use b:netrw_curdir for the target + let curword= s:NetrwGetWord() + let tgtdir = s:ComposePath(curdir,curword) + if isdirectory(tgtdir) + let s:netrwmftgt = tgtdir +" call Decho("isdir: s:netrwmftgt<".s:netrwmftgt.">") + else + let s:netrwmftgt = curdir +" call Decho("isfile: s:netrwmftgt<".s:netrwmftgt.">") endif endif + if a:islocal + " simplify the target (eg. /abc/def/../ghi -> /abc/ghi) + let s:netrwmftgt= simplify(s:netrwmftgt) +" call Decho("simplify: s:netrwmftgt<".s:netrwmftgt.">") + endif + if g:netrw_cygwin + let s:netrwmftgt= substitute(system("cygpath ".s:netrwmftgt),'\n$','','') + endif + let s:netrwmfloc= a:islocal + if g:netrw_fastbrowse > 0 + call s:LocalBrowseShellCmdRefresh() + endif call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) call netrw#NetrwRestorePosn(svpos) + if !hadtgt + norm! j + endif + " call Dret("s:NetrwMarkFileTgt") endfun +" --------------------------------------------------------------------- +" s:NetrwUnMarkFile: {{{2 +fun! s:NetrwUnMarkFile(islocal) +" call Dfunc("s:NetrwUnMarkFile(islocal=".a:islocal.")") + let svpos = netrw#NetrwSavePosn() + let curbufnr = bufnr("%") + + " unmark marked file list (although I expect s:NetrwUpload() + " to do it, I'm just making sure) + if exists("s:netrwmarkfilelist_{bufnr('%')}") +" call Decho("unlet'ing: s:netrwmarkfile[list|mtch]_".bufnr("%")) + unlet s:netrwmarkfilelist_{curbufnr} + unlet s:netrwmarkfilemtch_{curbufnr} + 2match none + endif + +" call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) + call netrw#NetrwRestorePosn(svpos) +" call Dret("s:NetrwUnMarkFile") +endfun + " =========================================== +" s:NetrwMenu: generates the menu for gvim and netrw {{{2 +fun! s:NetrwMenu(domenu) + + if !exists("g:NetrwMenuPriority") + let g:NetrwMenuPriority= 80 + endif + + if has("menu") && has("gui_running") && &go =~ 'm' && g:netrw_menu +" call Dfunc("NetrwMenu(domenu=".a:domenu.")") + + if !exists("s:netrw_menu_enabled") && a:domenu +" call Decho("initialize menu") + let s:netrw_menu_enabled= 1 + exe 'silent! menu '.g:NetrwMenuPriority.'.1 '.g:NetrwTopLvlMenu.'Help ' + call s:NetrwBookmarkMenu() " provide some history! uses priorities 2,3, reserves 4 + exe 'silent! menu '.g:NetrwMenuPriority.'.5 '.g:NetrwTopLvlMenu.'-Sep1- :' + exe 'silent! menu '.g:NetrwMenuPriority.'.6 '.g:NetrwTopLvlMenu.'Go\ Up\ Directory- -' + exe 'silent! menu '.g:NetrwMenuPriority.'.7 '.g:NetrwTopLvlMenu.'Apply\ Special\ Viewerx x' + exe 'silent! menu '.g:NetrwMenuPriority.'.8.1 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Current\ Directorymb mb' + exe 'silent! menu '.g:NetrwMenuPriority.'.8.2 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Bookmarkgb gb' + exe 'silent! menu '.g:NetrwMenuPriority.'.8.3 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Prev\ Dir\ (History)u u' + exe 'silent! menu '.g:NetrwMenuPriority.'.8.4 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Next\ Dir\ (History)U U' + exe 'silent! menu '.g:NetrwMenuPriority.'.8.5 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Listqb qb' + exe 'silent! menu '.g:NetrwMenuPriority.'.9.1 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ File\ Hiding\ List'." \NetrwHideEdit" + exe 'silent! menu '.g:NetrwMenuPriority.'.9.2 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ Sorting\ SequenceS S' + exe 'silent! menu '.g:NetrwMenuPriority.'.9.3 '.g:NetrwTopLvlMenu.'Browsing\ Control.Refresh\ Listing'." \NetrwRefresh" + exe 'silent! menu '.g:NetrwMenuPriority.'.9.4 '.g:NetrwTopLvlMenu.'Browsing\ Control.Settings/Options:NetrwSettings '.":NetrwSettings\" + exe 'silent! menu '.g:NetrwMenuPriority.'.10 '.g:NetrwTopLvlMenu.'Delete\ File/DirectoryD D' + exe 'silent! menu '.g:NetrwMenuPriority.'.11.1 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ Current\ Window '."\" + exe 'silent! menu '.g:NetrwMenuPriority.'.11.2 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.Preview\ File/Directoryp p' + exe 'silent! menu '.g:NetrwMenuPriority.'.11.3 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ Previous\ WindowP P' + exe 'silent! menu '.g:NetrwMenuPriority.'.11.4 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ New\ Windowo o' + exe 'silent! menu '.g:NetrwMenuPriority.'.11.5 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ New\ Vertical\ Windowv v' + exe 'silent! menu '.g:NetrwMenuPriority.'.12.1 '.g:NetrwTopLvlMenu.'Explore.Directory\ Name :Explore ' + exe 'silent! menu '.g:NetrwMenuPriority.'.12.2 '.g:NetrwTopLvlMenu.'Explore.Filenames\ Matching\ Pattern\ (curdir\ only):Explore\ */ :Explore */' + exe 'silent! menu '.g:NetrwMenuPriority.'.12.2 '.g:NetrwTopLvlMenu.'Explore.Filenames\ Matching\ Pattern\ (+subdirs):Explore\ **/ :Explore **/' + exe 'silent! menu '.g:NetrwMenuPriority.'.12.3 '.g:NetrwTopLvlMenu.'Explore.Files\ Containing\ Pattern\ (curdir\ only):Explore\ *// :Explore *//' + exe 'silent! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Files\ Containing\ Pattern\ (+subdirs):Explore\ **// :Explore **//' + exe 'silent! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Next\ Match:Nexplore :Nexplore' + exe 'silent! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Prev\ Match:Pexplore :Pexplore' + exe 'silent! menu '.g:NetrwMenuPriority.'.13 '.g:NetrwTopLvlMenu.'Make\ Subdirectoryd d' + exe 'silent! menu '.g:NetrwMenuPriority.'.14.1 '.g:NetrwTopLvlMenu.'Marked\ Files.Mark\ Filemf mf' + exe 'silent! menu '.g:NetrwMenuPriority.'.14.2 '.g:NetrwTopLvlMenu.'Marked\ Files.Mark\ Files\ by\ Regexpmr mr' + exe 'silent! menu '.g:NetrwMenuPriority.'.14.3 '.g:NetrwTopLvlMenu.'Marked\ Files.Hide-Show-List\ Controla a' + exe 'silent! menu '.g:NetrwMenuPriority.'.14.4 '.g:NetrwTopLvlMenu.'Marked\ Files.Copy\ To\ Targetmc mc' + exe 'silent! menu '.g:NetrwMenuPriority.'.14.5 '.g:NetrwTopLvlMenu.'Marked\ Files.DeleteD D' + exe 'silent! menu '.g:NetrwMenuPriority.'.14.6 '.g:NetrwTopLvlMenu.'Marked\ Files.Diffmd md' + exe 'silent! menu '.g:NetrwMenuPriority.'.14.7 '.g:NetrwTopLvlMenu.'Marked\ Files.Editme me' + exe 'silent! menu '.g:NetrwMenuPriority.'.14.8 '.g:NetrwTopLvlMenu.'Marked\ Files.Exe\ Cmdmx mx' + exe 'silent! menu '.g:NetrwMenuPriority.'.14.9 '.g:NetrwTopLvlMenu.'Marked\ Files.Move\ To\ Targetmm mm' + exe 'silent! menu '.g:NetrwMenuPriority.'.14.10 '.g:NetrwTopLvlMenu.'Marked\ Files.ObtainO O' + exe 'silent! menu '.g:NetrwMenuPriority.'.14.11 '.g:NetrwTopLvlMenu.'Marked\ Files.Printmp mp' + exe 'silent! menu '.g:NetrwMenuPriority.'.14.12 '.g:NetrwTopLvlMenu.'Marked\ Files.ReplaceR R' + exe 'silent! menu '.g:NetrwMenuPriority.'.14.13 '.g:NetrwTopLvlMenu.'Marked\ Files.Set\ Targetmt mt' + exe 'silent! menu '.g:NetrwMenuPriority.'.14.14 '.g:NetrwTopLvlMenu.'Marked\ Files.TagmT mT' + exe 'silent! menu '.g:NetrwMenuPriority.'.14.15 '.g:NetrwTopLvlMenu.'Marked\ Files.Zip/Unzip/Compress/Uncompressmz mz' + exe 'silent! menu '.g:NetrwMenuPriority.'.15 '.g:NetrwTopLvlMenu.'Obtain\ FileO O' + exe 'silent! menu '.g:NetrwMenuPriority.'.16.1 '.g:NetrwTopLvlMenu.'Style.Listing\ Style\ (thin-long-wide-tree)i i' + exe 'silent! menu '.g:NetrwMenuPriority.'.16.2 '.g:NetrwTopLvlMenu.'Style.Normal-Hide-Showa a' + exe 'silent! menu '.g:NetrwMenuPriority.'.16.3 '.g:NetrwTopLvlMenu.'Style.Reverse\ Sorting\ Order'."r r" + exe 'silent! menu '.g:NetrwMenuPriority.'.16.4 '.g:NetrwTopLvlMenu.'Style.Sorting\ Method\ (name-time-size)s s' + exe 'silent! menu '.g:NetrwMenuPriority.'.17 '.g:NetrwTopLvlMenu.'Rename\ File/DirectoryR R' + exe 'silent! menu '.g:NetrwMenuPriority.'.18 '.g:NetrwTopLvlMenu.'Set\ Current\ Directoryc c' + let s:netrw_menucnt= 28 + + elseif !a:domenu + let s:netrwcnt = 0 + let curwin = winnr() + windo if getline(2) =~ "Netrw" | let s:netrwcnt= s:netrwcnt + 1 | endif + exe curwin."wincmd w" + + if s:netrwcnt <= 1 +" call Decho("clear menus") + exe 'silent! unmenu '.g:NetrwTopLvlMenu +" call Decho('exe silent! unmenu '.g:NetrwTopLvlMenu.'*') + silent! unlet s:netrw_menu_enabled + endif + endif +" call Dret("NetrwMenu") + endif + +endfun + +" ========================================== " s:NetrwObtain: obtain file under cursor or from markfile list {{{2 fun! s:NetrwObtain(islocal) " call Dfunc("NetrwObtain(islocal=".a:islocal.")") - if exists("s:netrwmarkfilelist") - for fname in s:netrwmarkfilelist + if exists("s:netrwmarkfilelist_{bufnr('%')}") + for fname in s:netrwmarkfilelist_{bufnr("%")} call netrw#NetrwObtain(a:islocal,fname) endfor - unlet s:netrwmarkfilelist - unlet s:netrwmarkfilemtch + unlet s:netrwmarkfilelist_{bufnr("%")} + unlet s:netrwmarkfilemtch_{bufnr("%")} 2match none else call netrw#NetrwObtain(a:islocal,expand("")) @@ -3406,6 +4467,7 @@ fun! netrw#NetrwObtain(islocal,fname,...) let curline= line(".") let endline= line("$")+1 setlocal ma noro +" call Decho("setlocal ma noro") keepjumps $ " call Decho("getcwd<".getcwd().">") " call Decho("curdir<".curdir.">") @@ -3418,7 +4480,7 @@ fun! netrw#NetrwObtain(islocal,fname,...) " ftp + <.netrc>: Method #2 setlocal ff=unix if path != "" - put ='cd '.path + put ='lcd '.path " call Decho("ftp: cd ".path) endif if tgtdir != '.' @@ -3459,8 +4521,8 @@ fun! netrw#NetrwObtain(islocal,fname,...) endif if path != "" - put ='cd '.path -" call Decho('cd '.a:path) + put ='lcd '.path +" call Decho('lcd '.a:path) endif if tgtdir != '.' put ='lcd '.tgtdir @@ -3522,7 +4584,7 @@ fun! netrw#NetrwObtain(islocal,fname,...) " restore status line let &stl = s:netrw_users_stl let &laststatus = s:netrw_users_ls - redraw! +" redraw! " restore NetrwMethod if exists("keep_netrw_method") @@ -3534,6 +4596,110 @@ fun! netrw#NetrwObtain(islocal,fname,...) " call Dret("netrw#NetrwObtain") endfun +" --------------------------------------------------------------------- +" s:NetrwPrevWinOpen: open file/directory in previous window. {{{2 +" If there's only one window, then the window will first be split. +" Returns: +" choice = 0 : didn't have to choose +" choice = 1 : saved modified file in window first +" choice = 2 : didn't save modified file, opened window +" choice = 3 : cancel open +fun! s:NetrwPrevWinOpen(islocal) +" call Dfunc("NetrwPrevWinOpen(islocal=".a:islocal.")") + + " grab a copy of the b:netrw_curdir to pass it along to newly split windows + let curdir = b:netrw_curdir + + " get last window number and the word currently under the cursor + let lastwinnr = winnr("$") + let curword = s:NetrwGetWord() + let choice = 0 +" call Decho("lastwinnr=".lastwinnr." curword<".curword.">") + + let didsplit = 0 + if lastwinnr == 1 + " if only one window, open a new one first +" call Decho("only one window, so open a new one (g:netrw_alto=".g:netrw_alto.")") + if g:netrw_preview +" call Decho("exe ".(g:netrw_alto? "top " : "bot ")."vert ".g:netrw_winsize."wincmd s") + exe (g:netrw_alto? "top " : "bot ")."vert ".g:netrw_winsize."wincmd s" + else +" call Decho("exe ".(g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s") + exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s" + endif + let didsplit = 1 + + else + call s:SaveBufVars() +" call Decho("wincmd p") + wincmd p + call s:RestoreBufVars() + " if the previous window's buffer has been changed (is modified), + " and it doesn't appear in any other extant window, then ask the + " user if s/he wants to abandon modifications therein. + let bnr = winbufnr(0) + let bnrcnt = 0 + if &mod +" call Decho("detected: prev window's buffer has been modified: bnr=".bnr." winnr#".winnr()) + let eikeep= &ei + set ei=all + windo if winbufnr(0) == bnr | let bnrcnt=bnrcnt+1 | endif + exe bnr."wincmd p" + let &ei= eikeep +" call Decho("bnr=".bnr." bnrcnt=".bnrcnt." buftype=".&bt." winnr#".winnr()) + if bnrcnt == 1 + let bufname= bufname(winbufnr(winnr())) + let choice= confirm("Save modified file<".bufname.">?","&Yes\n&No\n&Cancel") +" call Decho("bufname<".bufname."> choice=".choice." winnr#".winnr()) + + if choice == 1 + " Yes -- write file & then browse + let v:errmsg= "" + silent w + if v:errmsg != "" + call netrw#ErrorMsg(s:ERROR,"unable to write <".bufname.">!",30) + if didsplit + q + else + wincmd p + endif +" call Dret("NetrwPrevWinOpen ".choice." : unable to write <".bufname.">") + return choice + endif + + elseif choice == 2 + " No -- don't worry about changed file, just browse anyway + setlocal nomod + call netrw#ErrorMsg(s:WARNING,bufname." changes to ".bufname." abandoned",31) + wincmd p + + else + " Cancel -- don't do this + if didsplit + q + else + wincmd p + endif +" call Dret("NetrwPrevWinOpen ".choice." : cancelled") + return choice + endif + endif + endif + endif + + " restore b:netrw_curdir (window split/enew may have lost it) + let b:netrw_curdir= curdir + if a:islocal < 2 + if a:islocal + call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(a:islocal,curword)) + else + call s:NetrwBrowse(a:islocal,s:NetrwBrowseChgDir(a:islocal,curword)) + endif + endif +" call Dret("NetrwPrevWinOpen ".choice) + return choice +endfun + " --------------------------------------------------------------------- " s:NetrwUpload: load fname to tgt (used by NetrwMarkFileCopy()) {{{2 " fname may itself be a remote or local file @@ -3584,6 +4750,7 @@ fun! s:NetrwRefresh(islocal,dirname) " NetrwBrowseChgDir() may clear the display; hence a NetrwSavePosn() may not work if its placed here. " Also, NetrwBrowseChgDir() now does a NetrwSavePosn() itself. setlocal ma noro +" call Decho("setlocal ma noro") " call Decho("clear buffer<".expand("%")."> with :%d") %d if a:islocal @@ -3592,11 +4759,88 @@ fun! s:NetrwRefresh(islocal,dirname) call s:NetrwBrowse(a:islocal,a:dirname) endif call netrw#NetrwRestorePosn() - redraw! + + " restore file marks + if exists("s:netrwmarkfilemtch_{bufnr('%')}") && s:netrwmarkfilemtch_{bufnr("%")} != "" +" call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/") + exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/" + else +" call Decho("2match none") + 2match none + endif + +" redraw! " call Dret("NetrwRefresh") endfun " --------------------------------------------------------------------- +" s:NetrwSetSort: sets up the sort based on the g:netrw_sort_sequence {{{2 +" What this function does is to compute a priority for the patterns +" in the g:netrw_sort_sequence. It applies a substitute to any +" "files" that satisfy each pattern, putting the priority / in +" front. An "*" pattern handles the default priority. +fun! s:NetrwSetSort() +" call Dfunc("SetSort() bannercnt=".w:netrw_bannercnt) + if w:netrw_liststyle == s:LONGLIST + let seqlist = substitute(g:netrw_sort_sequence,'\$','\\%(\t\\|\$\\)','ge') + else + let seqlist = g:netrw_sort_sequence + endif + " sanity check -- insure that * appears somewhere + if seqlist == "" + let seqlist= '*' + elseif seqlist !~ '\*' + let seqlist= seqlist.',*' + endif + let priority = 1 + while seqlist != "" + if seqlist =~ ',' + let seq = substitute(seqlist,',.*$','','e') + let seqlist = substitute(seqlist,'^.\{-},\(.*\)$','\1','e') + else + let seq = seqlist + let seqlist = "" + endif + let eseq= escape(seq,'/') + if priority < 10 + let spriority= "00".priority.'\/' + elseif priority < 100 + let spriority= "0".priority.'\/' + else + let spriority= priority.'\/' + endif +" call Decho("priority=".priority." spriority<".spriority."> seq<".seq."> seqlist<".seqlist.">") + + " sanity check + if w:netrw_bannercnt > line("$") + " apparently no files were left after a Hiding pattern was used +" call Dret("SetSort : no files left after hiding") + return + endif + if seq == '*' + let starpriority= spriority + else + exe 'silent keepjumps '.w:netrw_bannercnt.',$g/'.eseq.'/s/^/'.spriority.'/' + exe 'silent keepjumps '.w:netrw_bannercnt.',$g/^\d\{3}\/\d\{3}\//s/^\d\{3}\///' + endif + let priority = priority + 1 + endwhile + if exists("starpriority") + exe 'silent keepjumps '.w:netrw_bannercnt.',$v/^\d\{3}\//s/^/'.starpriority.'/' + endif + + " Following line associated with priority -- items that satisfy a priority + " pattern get prefixed by ###/ which permits easy sorting by priority. + " Sometimes files can satisfy multiple priority patterns -- only the latest + " priority pattern needs to be retained. So, at this point, these excess + " priority prefixes need to be removed, but not directories that happen to + " be just digits themselves. + exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\(\d\{3}\/\)\%(\d\{3}\/\)\+\ze./\1/e' + +" call Dret("SetSort") +endfun + +" ===================================================================== " s:NetrwSortStyle: change sorting style (name - time - size) and refresh display {{{2 fun! s:NetrwSortStyle(islocal) " call Dfunc("s:NetrwSortStyle(islocal=".a:islocal.") netrw_sort_by<".g:netrw_sort_by.">") @@ -3620,12 +4864,13 @@ endfun " =4 : local and t " =5 : local and v fun! s:NetrwSplit(mode) -" call Dfunc("NetrwSplit(mode=".a:mode.") alto=".g:netrw_alto." altv=".g:netrw_altv) +" call Dfunc("s:NetrwSplit(mode=".a:mode.") alto=".g:netrw_alto." altv=".g:netrw_altv) call s:SaveWinVars() if a:mode == 0 " remote and o +" call Decho("exe ".(g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s") exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s" let s:didsplit= 1 call s:RestoreWinVars() @@ -3635,6 +4880,7 @@ fun! s:NetrwSplit(mode) elseif a:mode == 1 " remote and t let cursorword = s:NetrwGetWord() +" call Decho("tabnew") tabnew let s:didsplit= 1 call s:RestoreWinVars() @@ -3643,6 +4889,7 @@ fun! s:NetrwSplit(mode) elseif a:mode == 2 " remote and v +" call Decho("exe ".(g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v") exe (g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v" let s:didsplit= 1 call s:RestoreWinVars() @@ -3651,6 +4898,7 @@ fun! s:NetrwSplit(mode) elseif a:mode == 3 " local and o +" call Decho("exe ".(g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s") exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s" let s:didsplit= 1 call s:RestoreWinVars() @@ -3661,6 +4909,7 @@ fun! s:NetrwSplit(mode) " local and t let netrw_curdir= b:netrw_curdir let cursorword = s:NetrwGetWord() +" call Decho("tabnew") tabnew let b:netrw_curdir= netrw_curdir let s:didsplit= 1 @@ -3670,6 +4919,7 @@ fun! s:NetrwSplit(mode) elseif a:mode == 5 " local and v +" call Decho("exe ".(g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v") exe (g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v" let s:didsplit= 1 call s:RestoreWinVars() @@ -3680,148 +4930,488 @@ fun! s:NetrwSplit(mode) call netrw#ErrorMsg(s:ERROR,"(NetrwSplit) unsupported mode=".a:mode,45) endif -" call Dret("NetrwSplit") +" call Dret("s:NetrwSplit") endfun " --------------------------------------------------------------------- -" s:NetrwBrowseX: allows users to write custom functions to operate on {{{2 -" files given their extension. Passes 0=local, 1=remote -fun! netrw#NetrwBrowseX(fname,remote) -" call Dfunc("NetrwBrowseX(fname<".a:fname."> remote=".a:remote.")") +" NetrwStatusLine: {{{2 +fun! NetrwStatusLine() - " set up the filename - " (lower case the extension, make a local copy of a remote file) - let exten= substitute(a:fname,'.*\.\(.\{-}\)','\1','e') - if has("win32") || has("win95") || has("win64") || has("win16") - let exten= substitute(exten,'^.*$','\L&\E','') +" vvv NetrwStatusLine() debugging vvv +" let g:stlmsg="" +" if !exists("w:netrw_explore_bufnr") +" let g:stlmsg="!X" +" elseif w:netrw_explore_bufnr != bufnr("%") +" let g:stlmsg="explore_bufnr!=".bufnr("%") +" endif +" if !exists("w:netrw_explore_line") +" let g:stlmsg=" !X" +" elseif w:netrw_explore_line != line(".") +" let g:stlmsg=" explore_line!={line(.)<".line(".").">" +" endif +" if !exists("w:netrw_explore_list") +" let g:stlmsg=" !X" +" endif +" ^^^ NetrwStatusLine() debugging ^^^ + + if !exists("w:netrw_explore_bufnr") || w:netrw_explore_bufnr != bufnr("%") || !exists("w:netrw_explore_line") || w:netrw_explore_line != line(".") || !exists("w:netrw_explore_list") + " restore user's status line + let &stl = s:netrw_users_stl + let &laststatus = s:netrw_users_ls + if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif + if exists("w:netrw_explore_line") |unlet w:netrw_explore_line |endif + return "" + else + return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen endif - let fname= escape(a:fname,"%#") -" call Decho("fname<".fname."> after escape()") +endfun - " seems kde systems often have gnome-open due to dependencies, even though - " gnome-open's subsidiary display tools are largely absent. Kde systems - " usually have "kdeinit" running, though... (tnx Mikolaj Machowski) - if !exists("s:haskdeinit") - if has("unix") - let s:haskdeinit= s:System("system",'ps -e') =~ 'kdeinit' - if v:shell_error - let s:haskdeinit = 0 +" --------------------------------------------------------------------- +" s:NetrwTreeDir: determine tree directory given current cursor position {{{2 +" (full path directory with trailing slash returned) +fun! s:NetrwTreeDir() +" call Dfunc("NetrwTreeDir() curline#".line(".")."<".getline(".")."> b:netrw_curdir<".b:netrw_curdir."> tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%").">") + + let treedir= b:netrw_curdir +" call Decho("set initial treedir<".treedir.">") + let s:treecurpos= netrw#NetrwSavePosn() + + if w:netrw_liststyle == s:TREELIST +" call Decho("w:netrrw_liststyle is TREELIST:") +" call Decho("line#".line(".")." getline(.)<".getline('.')."> treecurpos<".string(s:treecurpos).">") + if getline('.') =~ '/$' + let treedir= substitute(getline('.'),'^\%(| \)*\([^|].\{-}\)$','\1','e') + else + let treedir= "" + endif + +" call Decho("treedir<".treedir.">") + + " detect user attempting to close treeroot + if getline('.') !~ '|' && getline('.') != '..' +" call Decho("user attempted to close treeroot") + " now force a refresh +" call Decho("clear buffer<".expand("%")."> with :%d") + keepjumps %d +" call Dret("NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">") + return b:netrw_curdir + endif + + " elide all non-depth information + let depth = substitute(getline('.'),'^\(\%(| \)*\)[^|].\{-}$','\1','e') +" call Decho("depth<".depth."> 1st subst") + + " elide first depth + let depth = substitute(depth,'^| ','','') +" call Decho("depth<".depth."> 2nd subst") + + " construct treedir by searching backwards at correct depth +" call Decho("constructing treedir<".treedir."> depth<".depth.">") + while depth != "" && search('^'.depth.'[^|].\{-}/$','bW') + let dirname= substitute(getline("."),'^\(| \)*','','e') + let treedir= dirname.treedir + let depth = substitute(depth,'^| ','','') +" call Decho("constructing treedir<".treedir.">: dirname<".dirname."> while depth<".depth.">") + endwhile + if w:netrw_treetop =~ '/$' + let treedir= w:netrw_treetop.treedir + else + let treedir= w:netrw_treetop.'/'.treedir + endif +" call Decho("bufnr(.)=".bufnr("%")." line($)=".line("$")." line(.)=".line(".")) + endif + let treedir= substitute(treedir,'//$','/','') + +" " now force a refresh +"" call DECHO("clear buffer<".expand("%")."> with :%d") +" setlocal ma noro +" keepjumps %d + +" call Dret("NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">") + return treedir +endfun + +" --------------------------------------------------------------------- +" s:NetrwTreeDisplay: recursive tree display {{{2 +fun! s:NetrwTreeDisplay(dir,depth) +" call Dfunc("NetrwTreeDisplay(dir<".a:dir."> depth<".a:depth.">)") + + " insure that there are no folds + setlocal nofen + + " install ../ and shortdir + if a:depth == "" + call setline(line("$")+1,'../') +" call Decho("setline#".line("$")." ../ (depth is zero)") + endif + if a:dir =~ '^\a\+://' + if a:dir == w:netrw_treetop + let shortdir= a:dir + else + let shortdir= substitute(a:dir,'^.*/\([^/]\+\)/$','\1/','e') + endif + call setline(line("$")+1,a:depth.shortdir) + else + let shortdir= substitute(a:dir,'^.*/','','e') + call setline(line("$")+1,a:depth.shortdir.'/') + endif +" call Decho("setline#".line("$")." shortdir<".a:depth.shortdir.">") + + " append a / to dir if its missing one + let dir= a:dir + if dir !~ '/$' + let dir= dir.'/' + endif + + " display subtrees (if any) + let depth= "| ".a:depth + +" call Decho("display subtrees with depth<".depth."> and current leaves") + for entry in w:netrw_treedict[a:dir] + let direntry= substitute(dir.entry,'/$','','e') +" call Decho("dir<".dir."> entry<".entry."> direntry<".direntry.">") + if entry =~ '/$' && has_key(w:netrw_treedict,direntry) +" call Decho("<".direntry."> is a key in treedict - display subtree for it") + call s:NetrwTreeDisplay(direntry,depth) + elseif entry =~ '/$' && has_key(w:netrw_treedict,direntry.'/') +" call Decho("<".direntry."/> is a key in treedict - display subtree for it") + call s:NetrwTreeDisplay(direntry.'/',depth) + else +" call Decho("<".entry."> is not a key in treedict (no subtree)") + call setline(line("$")+1,depth.entry) + endif + endfor +" call Dret("NetrwTreeDisplay") +endfun + +" --------------------------------------------------------------------- +" s:NetrwTreeListing: displays tree listing from treetop on down, using NetrwTreeDisplay() {{{2 +fun! s:NetrwTreeListing(dirname) + if w:netrw_liststyle == s:TREELIST +" call Dfunc("NetrwTreeListing() bufname<".expand("%").">") +" call Decho("curdir<".a:dirname.">") +" call Decho("win#".winnr().": w:netrw_treetop ".(exists("w:netrw_treetop")? "exists" : "doesn't exit")." w:netrw_treedict ".(exists("w:netrw_treedict")? "exists" : "doesn't exit")) + + " update the treetop +" call Decho("update the treetop") + if !exists("w:netrw_treetop") + let w:netrw_treetop= a:dirname +" call Decho("w:netrw_treetop<".w:netrw_treetop."> (reusing)") + elseif (w:netrw_treetop =~ ('^'.a:dirname) && s:Strlen(a:dirname) < s:Strlen(w:netrw_treetop)) || a:dirname !~ ('^'.w:netrw_treetop) + let w:netrw_treetop= a:dirname +" call Decho("w:netrw_treetop<".w:netrw_treetop."> (went up)") + endif + + " insure that we have at least an empty treedict + if !exists("w:netrw_treedict") + let w:netrw_treedict= {} + endif + + " update the directory listing for the current directory +" call Decho("updating dictionary with ".a:dirname.":[..directory listing..]") +" call Decho("bannercnt=".w:netrw_bannercnt." line($)=".line("$")) + exe "silent! keepjumps ".w:netrw_bannercnt.',$g@^\.\.\=/$@d' + let w:netrw_treedict[a:dirname]= getline(w:netrw_bannercnt,line("$")) +" call Decho("w:treedict[".a:dirname."]= ".w:netrw_treedict[a:dirname]) + exe "silent! keepjumps ".w:netrw_bannercnt.",$d" + + " if past banner, record word + if exists("w:netrw_bannercnt") && line(".") > w:netrw_bannercnt + let fname= expand("") + else + let fname= "" + endif +" call Decho("fname<".fname.">") + + " display from treetop on down + call s:NetrwTreeDisplay(w:netrw_treetop,"") + +" call Dret("NetrwTreeListing : bufname<".expand("%").">") + endif +endfun + +" --------------------------------------------------------------------- +" s:NetrwWideListing: {{{2 +fun! s:NetrwWideListing() + + if w:netrw_liststyle == s:WIDELIST +" call Dfunc("NetrwWideListing() w:netrw_liststyle=".w:netrw_liststyle.' fo='.&fo.' l:fo='.&l:fo) + " look for longest filename (cpf=characters per filename) + " cpf: characters per file + " fpl: files per line + " fpc: files per column + setlocal ma noro +" call Decho("setlocal ma noro") + let b:netrw_cpf= 0 + if line("$") >= w:netrw_bannercnt + exe 'silent keepjumps '.w:netrw_bannercnt.',$g/^./if virtcol("$") > b:netrw_cpf|let b:netrw_cpf= virtcol("$")|endif' + else +" call Dret("NetrwWideListing") + return + endif +" call Decho("max file strlen+1=".b:netrw_cpf) + let b:netrw_cpf= b:netrw_cpf + 1 + + " determine qty files per line (fpl) + let w:netrw_fpl= winwidth(0)/b:netrw_cpf + if w:netrw_fpl <= 0 + let w:netrw_fpl= 1 + endif +" call Decho("fpl= ".winwidth(0)."/[b:netrw_cpf=".b:netrw_cpf.']='.w:netrw_fpl) + + " make wide display + exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^.*$/\=escape(printf("%-'.b:netrw_cpf.'s",submatch(0)),"\\")/' + let fpc = (line("$") - w:netrw_bannercnt + w:netrw_fpl)/w:netrw_fpl + let newcolstart = w:netrw_bannercnt + fpc + let newcolend = newcolstart + fpc - 1 +" call Decho("bannercnt=".w:netrw_bannercnt." fpl=".w:netrw_fpl." fpc=".fpc." newcol[".newcolstart.",".newcolend."]") + silent! let keepregstar = @* + while line("$") >= newcolstart + if newcolend > line("$") | let newcolend= line("$") | endif + let newcolqty= newcolend - newcolstart + exe newcolstart + if newcolqty == 0 + exe "silent keepjumps norm! 0\$hx".w:netrw_bannercnt."G$p" + else + exe "silent keepjumps norm! 0\".newcolqty.'j$hx'.w:netrw_bannercnt.'G$p' endif - else - let s:haskdeinit= 0 - endif -" call Decho("setting s:haskdeinit=".s:haskdeinit) + exe "silent keepjumps ".newcolstart.','.newcolend.'d' + exe 'silent keepjumps '.w:netrw_bannercnt + endwhile + silent! let @*= keepregstar + exe "silent keepjumps ".w:netrw_bannercnt.',$s/\s\+$//e' + setlocal noma nomod ro +" call Dret("NetrwWideListing") endif - if a:remote == 1 - " create a local copy - let fname= fnamemodify(tempname(),":t:r").".".exten -" call Decho("a:remote=".a:remote.": create a local copy of <".a:fname."> as <".fname.">") - exe "silent keepjumps bot 1new ".a:fname - setlocal bh=delete -" call Decho("exe w! ".fname) - exe "w! ".fname - q - endif -" call Decho("exten<".exten."> "."netrwFileHandlers#NFH_".exten."():exists=".exists("*netrwFileHandlers#NFH_".exten)) +endfun - " set up redirection - if &srr =~ "%s" - if (has("win32") || has("win95") || has("win64") || has("win16")) - let redir= substitute(&srr,"%s","nul","") - else - let redir= substitute(&srr,"%s","/dev/null","") - endif - elseif (has("win32") || has("win95") || has("win64") || has("win16")) - let redir= &srr . "nul" +" --------------------------------------------------------------------- +" s:PerformListing: {{{2 +fun! s:PerformListing(islocal) +" call Dfunc("s:PerformListing(islocal=".a:islocal.") buf(%)=".bufnr("%")."<".bufname("%").">") + + call s:NetrwSafeOptions() + setlocal noro ma +" call Decho("setlocal noro ma") + +" if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1 " Decho +" call Decho("(netrw) Processing your browsing request...") +" endif " Decho + +" call Decho('w:netrw_liststyle='.(exists("w:netrw_liststyle")? w:netrw_liststyle : 'n/a')) + if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") + " force a refresh for tree listings +" call Decho("force refresh for treelisting: clear buffer<".expand("%")."> with :%d") + keepjumps %d + endif + + " save current directory on directory history list + call s:NetrwBookmarkDir(3,b:netrw_curdir) + + " Set up the banner {{{3 +" call Decho("set up banner") + keepjumps put ='\" ============================================================================' + keepjumps put ='\" Netrw Directory Listing (netrw '.g:loaded_netrw.')' + keepjumps put ='\" '.b:netrw_curdir + keepjumps 1d + let w:netrw_bannercnt= 3 + exe "keepjumps ".w:netrw_bannercnt + + let sortby= g:netrw_sort_by + if g:netrw_sort_direction =~ "^r" + let sortby= sortby." reversed" + endif + + " Sorted by... {{{3 +" call Decho("handle specified sorting: g:netrw_sort_by<".g:netrw_sort_by.">") + if g:netrw_sort_by =~ "^n" +" call Decho("directories will be sorted by name") + " sorted by name + keepjumps put ='\" Sorted by '.sortby + keepjumps put ='\" Sort sequence: '.g:netrw_sort_sequence + let w:netrw_bannercnt= w:netrw_bannercnt + 2 else - let redir= &srr . "/dev/null" +" call Decho("directories will be sorted by size or time") + " sorted by size or date + keepjumps put ='\" Sorted by '.sortby + let w:netrw_bannercnt= w:netrw_bannercnt + 1 endif -" call Decho("redir{".redir."} srr{".&srr."}") + exe "keepjumps ".w:netrw_bannercnt - " extract any viewing options. Assumes that they're set apart by quotes. - if exists("g:netrw_browsex_viewer") - if g:netrw_browsex_viewer =~ '\s' - let viewer = substitute(g:netrw_browsex_viewer,'\s.*$','','') - let viewopt = substitute(g:netrw_browsex_viewer,'^\S\+\s*','','')." " - let oviewer = '' - let cnt = 1 - while !executable(viewer) && viewer != oviewer - let viewer = substitute(g:netrw_browsex_viewer,'^\(\(^\S\+\s\+\)\{'.cnt.'}\S\+\)\(.*\)$','\1','') - let viewopt = substitute(g:netrw_browsex_viewer,'^\(\(^\S\+\s\+\)\{'.cnt.'}\S\+\)\(.*\)$','\3','')." " - let cnt = cnt + 1 - let oviewer = viewer -" call Decho("!exe: viewer<".viewer."> viewopt<".viewopt.">") - endwhile + " show copy/move target, if any + if exists("s:netrwmftgt") && exists("s:netrwmfloc") +" call Decho("show copy/move target<".s:netrwmftgt.">") + if s:netrwmfloc + keepjumps put ='\" Copy/Move Tgt: '.s:netrwmftgt.' (local)' else - let viewer = g:netrw_browsex_viewer - let viewopt = "" + keepjumps put ='\" Copy/Move Tgt: '.s:netrwmftgt.' (remote)' endif -" call Decho("viewer<".viewer."> viewopt<".viewopt.">") - endif - - " execute the file handler - if exists("g:netrw_browsex_viewer") && g:netrw_browsex_viewer == '-' -" call Decho("g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">") - let ret= netrwFileHandlers#Invoke(exten,fname) - - elseif exists("g:netrw_browsex_viewer") && executable(viewer) -" call Decho("g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">") -" call Decho("exe silent !".viewer." ".viewopt.g:netrw_shq.escape(fname,'%#').g:netrw_shq.redir) - exe "silent !".viewer." ".viewopt.g:netrw_shq.escape(fname,'%#').g:netrw_shq.redir - let ret= v:shell_error - - elseif has("win32") || has("win64") -" call Decho('exe silent !start rundll32 url.dll,FileProtocolHandler '.g:netrw_shq.escape(fname, '%#').g:netrw_shq) - exe 'silent !start rundll32 url.dll,FileProtocolHandler '.g:netrw_shq.escape(fname, '%#').g:netrw_shq - call inputsave()|call input("Press to continue")|call inputrestore() - let ret= v:shell_error - - elseif has("unix") && executable("gnome-open") && !s:haskdeinit -" call Decho("exe silent !gnome-open ".g:netrw_shq.escape(fname,'%#').g:netrw_shq." ".redir) - exe "silent !gnome-open ".g:netrw_shq.escape(fname,'%#').g:netrw_shq.redir - let ret= v:shell_error - - elseif has("unix") && executable("kfmclient") && s:haskdeinit -" call Decho("exe silent !kfmclient exec ".g:netrw_shq.escape(fname,'%#').g:netrw_shq." ".redir) - exe "silent !kfmclient exec ".g:netrw_shq.escape(fname,'%#').g:netrw_shq." ".redir - let ret= v:shell_error - - elseif has("macunix") && executable("open") -" call Decho("exe silent !open '".escape(fname,'%#')."' ".redir) - exe silent !open '".escape(fname,'%#')."' ".redir - let ret= v:shell_error - + let w:netrw_bannercnt= w:netrw_bannercnt + 1 else - " netrwFileHandlers#Invoke() always returns 0 - let ret= netrwFileHandlers#Invoke(exten,fname) +" call Decho("s:netrwmftgt does not exist, don't make Copy/Move Tgt") endif + exe "keepjumps ".w:netrw_bannercnt - " if unsuccessful, attempt netrwFileHandlers#Invoke() - if ret - let ret= netrwFileHandlers#Invoke(exten,fname) - endif - - redraw! - - " cleanup: remove temporary file, - " delete current buffer if success with handler, - " return to prior buffer (directory listing) - if a:remote == 1 && fname != a:fname -" call Decho("deleting temporary file<".fname.">") - call s:System("delete",fname) - endif - - if a:remote == 1 - setlocal bh=delete bt=nofile - if g:netrw_use_noswf - setlocal noswf + " Hiding... -or- Showing... {{{3 +" call Decho("handle hiding/showing (g:netrw_hide=".g:netrw_list_hide." g:netrw_list_hide<".g:netrw_list_hide.">)") + if g:netrw_list_hide != "" && g:netrw_hide + if g:netrw_hide == 1 + keepjumps put ='\" Hiding: '.g:netrw_list_hide + else + keepjumps put ='\" Showing: '.g:netrw_list_hide + endif + let w:netrw_bannercnt= w:netrw_bannercnt + 1 + endif + exe "keepjumps ".w:netrw_bannercnt + keepjumps put ='\" Quick Help: :help -:go up dir D:delete R:rename s:sort-by x:exec' + keepjumps put ='\" ============================================================================' + let w:netrw_bannercnt= w:netrw_bannercnt + 2 + + " bannercnt should index the line just after the banner + let w:netrw_bannercnt= w:netrw_bannercnt + 1 + exe "keepjumps ".w:netrw_bannercnt +" call Decho("bannercnt=".w:netrw_bannercnt." (should index line just after banner) line($)=".line("$")) + + " set up syntax highlighting {{{3 +" call Decho("set up syntax highlighting") + if has("syntax") + setlocal ft=netrw + if !exists("g:syntax_on") || !g:syntax_on + setlocal ft= endif - exe "norm! \" - redraw! endif -" call Dret("NetrwBrowseX") + " get list of files +" call Decho("Get list of files - islocal=".a:islocal) + if a:islocal + call s:LocalListing() + else " remote + call s:NetrwRemoteListing() + endif +" call Decho("w:netrw_bannercnt=".w:netrw_bannercnt." (banner complete)") + + " manipulate the directory listing (hide, sort) {{{3 + if line("$") >= w:netrw_bannercnt +" call Decho("manipulate directory listing (hide)") +" call Decho("g:netrw_hide=".g:netrw_hide." g:netrw_list_hide<".g:netrw_list_hide.">") + if g:netrw_hide && g:netrw_list_hide != "" + call s:NetrwListHide() + endif + if line("$") >= w:netrw_bannercnt +" call Decho("manipulate directory listing (sort) : g:netrw_sort_by<".g:netrw_sort_by.">") + + if g:netrw_sort_by =~ "^n" + " sort by name + call s:NetrwSetSort() + + if w:netrw_bannercnt < line("$") +" call Decho("g:netrw_sort_direction=".g:netrw_sort_direction." (bannercnt=".w:netrw_bannercnt.")") + if g:netrw_sort_direction =~ 'n' + " normal direction sorting + exe 'silent keepjumps '.w:netrw_bannercnt.',$sort' + else + " reverse direction sorting + exe 'silent keepjumps '.w:netrw_bannercnt.',$sort!' + endif + endif + " remove priority pattern prefix +" call Decho("remove priority pattern prefix") + exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\d\{3}\///e' + + elseif a:islocal + if w:netrw_bannercnt < line("$") +" call Decho("g:netrw_sort_direction=".g:netrw_sort_direction) + if g:netrw_sort_direction =~ 'n' +" call Decho('exe silent keepjumps '.w:netrw_bannercnt.',$sort') + exe 'silent keepjumps '.w:netrw_bannercnt.',$sort' + else +" call Decho('exe silent keepjumps '.w:netrw_bannercnt.',$sort!') + exe 'silent keepjumps '.w:netrw_bannercnt.',$sort!' + endif + endif + exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\d\{-}\///e' + endif + + elseif g:netrw_sort_direction =~ 'r' +" call Decho('reverse the sorted listing') + exe 'silent keepjumps '.w:netrw_bannercnt.'g/^/m '.w:netrw_bannercnt + endif + endif + + " convert to wide/tree listing {{{3 +" call Decho("modify display if wide/tree listing style") + call s:NetrwWideListing() + call s:NetrwTreeListing(b:netrw_curdir) + + if exists("w:netrw_bannercnt") && line("$") > w:netrw_bannercnt + " place cursor on the top-left corner of the file listing +" call Decho("place cursor on top-left corner of file listing") + exe 'silent keepjumps '.w:netrw_bannercnt + norm! 0 + endif + + " record previous current directory + let w:netrw_prvdir= b:netrw_curdir +" call Decho("record netrw_prvdir<".w:netrw_prvdir.">") + + " save certain window-oriented variables into buffer-oriented variables {{{3 + call s:SetBufWinVars() + call s:NetrwOptionRestore("w:") + + " set display to netrw display settings +" call Decho("set display to netrw display settings (noma nomod etc)") + setlocal noma nomod nonu nobl nowrap ro + if exists("s:treecurpos") + + call netrw#NetrwRestorePosn(s:treecurpos) + unlet s:treecurpos + endif + +" call Dret("s:PerformListing : curpos<".string(getpos(".")).">") +endfun + +" --------------------------------------------------------------------- +" s:SetupNetrwStatusLine: {{{2 +fun! s:SetupNetrwStatusLine(statline) +" call Dfunc("SetupNetrwStatusLine(statline<".a:statline.">)") + + if !exists("s:netrw_setup_statline") + let s:netrw_setup_statline= 1 +" call Decho("do first-time status line setup") + + if !exists("s:netrw_users_stl") + let s:netrw_users_stl= &stl + endif + if !exists("s:netrw_users_ls") + let s:netrw_users_ls= &laststatus + endif + + " set up User9 highlighting as needed + let keepa= @a + redir @a + try + hi User9 + catch /^Vim\%((\a\+)\)\=:E411/ + if &bg == "dark" + hi User9 ctermfg=yellow ctermbg=blue guifg=yellow guibg=blue + else + hi User9 ctermbg=yellow ctermfg=blue guibg=yellow guifg=blue + endif + endtry + redir END + let @a= keepa + endif + + " set up status line (may use User9 highlighting) + " insure that windows have a statusline + " make sure statusline is displayed + let &stl=a:statline + setlocal laststatus=2 +" call Decho("stl=".&stl) +" redraw! + +" call Dret("SetupNetrwStatusLine : stl=".&stl) endfun " --------------------------------------------------------------------- @@ -3997,9 +5587,9 @@ fun! s:NetrwRemoteRm(usrhost,path) range let svpos= netrw#NetrwSavePosn() let all= 0 - if exists("s:netrwmarkfilelist") + if exists("s:netrwmarkfilelist_{bufnr('%')}") " remove all marked files - for fname in s:netrwmarkfilelist + for fname in s:netrwmarkfilelist_{bufnr("%")} let ok= s:NetrwRemoteRmFile(a:path,fname,all) if ok =~ 'q\%[uit]' break @@ -4007,8 +5597,8 @@ fun! s:NetrwRemoteRm(usrhost,path) range let all= 1 endif endfor - unlet s:netrwmarkfilelist - unlet s:netrwmarkfilemtch + unlet s:netrwmarkfilelist_{bufnr("%")} + unlet s:netrwmarkfilemtch_{bufnr("%")} 2match none else @@ -4156,6 +5746,7 @@ fun! s:NetrwRemoteFtpCmd(path,listcmd) " because WinXX ftp uses unix style input let ffkeep= &ff setlocal ma ff=unix noro +" call Decho("setlocal ma ff=unix noro") " clear off any older non-banner lines " note that w:netrw_bannercnt indexes the line after the banner @@ -4260,8 +5851,8 @@ fun! s:NetrwRemoteRename(usrhost,path) range let rename_cmd = s:MakeSshCmd(g:netrw_rename_cmd) " rename files given by the markfilelist - if exists("s:netrwmarkfilelist") - for oldname in s:netrwmarkfilelist + if exists("s:netrwmarkfilelist_{bufnr('%')}") + for oldname in s:netrwmarkfilelist_{bufnr("%")} " call Decho("oldname<".oldname.">") if exists("subfrom") let newname= substitute(oldname,subfrom,subto,'') @@ -4289,8 +5880,8 @@ fun! s:NetrwRemoteRename(usrhost,path) range endfor 2match none - unlet s:netrwmarkfilelist - unlet s:netrwmarkfilemtch + unlet s:netrwmarkfilelist_{bufnr("%")} + unlet s:netrwmarkfilemtch_{bufnr("%")} else @@ -4326,755 +5917,6 @@ fun! s:NetrwRemoteRename(usrhost,path) range endfun " --------------------------------------------------------------------- -" s:NetrwListStyle: {{{2 -" islocal=0: remote browsing -" =1: local browsing -fun! s:NetrwListStyle(islocal) -" call Dfunc("NetrwListStyle(islocal=".a:islocal.") w:netrw_liststyle=".w:netrw_liststyle) - let fname = s:NetrwGetWord() - if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif - let w:netrw_liststyle = (w:netrw_liststyle + 1) % s:MAXLIST -" call Decho("fname<".fname.">") -" call Decho("chgd w:netrw_liststyle to ".w:netrw_liststyle) -" call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "doesn't exist").">") - - if w:netrw_liststyle == s:THINLIST - " use one column listing -" call Decho("use one column list") - let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge') - - elseif w:netrw_liststyle == s:LONGLIST - " use long list -" call Decho("use long list") - let g:netrw_list_cmd = g:netrw_list_cmd." -l" - - elseif w:netrw_liststyle == s:WIDELIST - " give wide list -" call Decho("use wide list") - let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge') - - elseif w:netrw_liststyle == s:TREELIST -" call Decho("use tree list") - let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge') - - else - call netrw#ErrorMsg(s:WARNING,"bad value for g:netrw_liststyle (=".w:netrw_liststyle.")",46) - let g:netrw_liststyle = s:THINLIST - let w:netrw_liststyle = g:netrw_liststyle - let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge') - endif - setlocal ma noro - - " clear buffer - this will cause NetrwBrowse/LocalBrowseCheck to do a refresh -" call Decho("clear buffer<".expand("%")."> with :%d") - %d - - " refresh the listing - let svpos= netrw#NetrwSavePosn() - call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) - call netrw#NetrwRestorePosn(svpos) - - " keep cursor on the filename - silent keepjumps $ - let result= search('\%(^\%(|\+\s\)\=\|\s\{2,}\)\zs'.escape(fname,'.\[]*$^').'\%(\s\{2,}\|$\)','bc') -" call Decho("search result=".result." w:netrw_bannercnt=".(exists("w:netrw_bannercnt")? w:netrw_bannercnt : 'N/A')) - if result <= 0 && exists("w:netrw_bannercnt") - exe "keepjumps ".w:netrw_bannercnt - endif - -" call Dret("NetrwListStyle".(exists("w:netrw_liststyle")? ' : w:netrw_liststyle='.w:netrw_liststyle : "")) -endfun - -" --------------------------------------------------------------------- -" s:NetrwWideListing: {{{2 -fun! s:NetrwWideListing() - - if w:netrw_liststyle == s:WIDELIST -" call Dfunc("NetrwWideListing() w:netrw_liststyle=".w:netrw_liststyle.' fo='.&fo.' l:fo='.&l:fo) - " look for longest filename (cpf=characters per filename) - " cpf: characters per file - " fpl: files per line - " fpc: files per column - setlocal ma noro - let b:netrw_cpf= 0 - if line("$") >= w:netrw_bannercnt - exe 'silent keepjumps '.w:netrw_bannercnt.',$g/^./if virtcol("$") > b:netrw_cpf|let b:netrw_cpf= virtcol("$")|endif' - else -" call Dret("NetrwWideListing") - return - endif -" call Decho("max file strlen+1=".b:netrw_cpf) - let b:netrw_cpf= b:netrw_cpf + 1 - - " determine qty files per line (fpl) - let w:netrw_fpl= winwidth(0)/b:netrw_cpf - if w:netrw_fpl <= 0 - let w:netrw_fpl= 1 - endif -" call Decho("fpl= ".winwidth(0)."/[b:netrw_cpf=".b:netrw_cpf.']='.w:netrw_fpl) - - " make wide display - exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^.*$/\=escape(printf("%-'.b:netrw_cpf.'s",submatch(0)),"\\")/' - let fpc = (line("$") - w:netrw_bannercnt + w:netrw_fpl)/w:netrw_fpl - let newcolstart = w:netrw_bannercnt + fpc - let newcolend = newcolstart + fpc - 1 -" call Decho("bannercnt=".w:netrw_bannercnt." fpl=".w:netrw_fpl." fpc=".fpc." newcol[".newcolstart.",".newcolend."]") - silent! let keepregstar = @* - while line("$") >= newcolstart - if newcolend > line("$") | let newcolend= line("$") | endif - let newcolqty= newcolend - newcolstart - exe newcolstart - if newcolqty == 0 - exe "silent keepjumps norm! 0\$hx".w:netrw_bannercnt."G$p" - else - exe "silent keepjumps norm! 0\".newcolqty.'j$hx'.w:netrw_bannercnt.'G$p' - endif - exe "silent keepjumps ".newcolstart.','.newcolend.'d' - exe 'silent keepjumps '.w:netrw_bannercnt - endwhile - silent! let @*= keepregstar - exe "silent keepjumps ".w:netrw_bannercnt.',$s/\s\+$//e' - setlocal noma nomod ro -" call Dret("NetrwWideListing") - endif - -endfun - -" --------------------------------------------------------------------- -" s:NetrwTreeDir: determine tree directory given current cursor position {{{2 -" (full path directory with trailing slash returned) -fun! s:NetrwTreeDir() -" call Dfunc("NetrwTreeDir() curline#".line(".")."<".getline(".")."> b:netrw_curdir<".b:netrw_curdir."> tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%").">") - - let treedir= b:netrw_curdir -" call Decho("set initial treedir<".treedir.">") - let s:treecurpos= getpos(".") - - if w:netrw_liststyle == s:TREELIST -" call Decho("w:netrrw_liststyle is TREELIST:") -" call Decho("line#".line(".")." getline(.)<".getline('.')."> treecurpos<".string(s:treecurpos).">") - if getline('.') =~ '/$' - let treedir= substitute(getline('.'),'^\%(| \)*\([^|].\{-}\)$','\1','e') - else - let treedir= "" - endif - -" call Decho("treedir<".treedir.">") - - " detect user attempting to close treeroot - if getline('.') !~ '|' && getline('.') != '..' -" call Decho("user attempted to close treeroot") - " now force a refresh -" call Decho("clear buffer<".expand("%")."> with :%d") - keepjumps %d -" call Dret("NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">") - return b:netrw_curdir - endif - - " elide all non-depth information - let depth = substitute(getline('.'),'^\(\%(| \)*\)[^|].\{-}$','\1','e') -" call Decho("depth<".depth."> 1st subst") - - " elide first depth - let depth = substitute(depth,'^| ','','') -" call Decho("depth<".depth."> 2nd subst") - - " construct treedir by searching backwards at correct depth -" call Decho("constructing treedir<".treedir."> depth<".depth.">") - while depth != "" && search('^'.depth.'[^|].\{-}/$','bW') - let dirname= substitute(getline("."),'^\(| \)*','','e') - let treedir= dirname.treedir - let depth = substitute(depth,'^| ','','') -" call Decho("constructing treedir<".treedir.">: dirname<".dirname."> while depth<".depth.">") - endwhile - if w:netrw_treetop =~ '/$' - let treedir= w:netrw_treetop.treedir - else - let treedir= w:netrw_treetop.'/'.treedir - endif -" call Decho("bufnr(.)=".bufnr(".")." line($)=".line("$")." line(.)=".line(".")) - endif - let treedir= substitute(treedir,'//$','/','') - -" " now force a refresh -" call Decho("clear buffer<".expand("%")."> with :%d") -" setlocal ma noro -" keepjumps %d - -" call Dret("NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">") - return treedir -endfun - -" --------------------------------------------------------------------- -" s:NetrwTreeDisplay: recursive tree display {{{2 -fun! s:NetrwTreeDisplay(dir,depth) -" call Dfunc("NetrwTreeDisplay(dir<".a:dir."> depth<".a:depth.">)") - - " insure that there are no folds - setlocal nofen - - " install ../ and shortdir - if a:depth == "" - call setline(line("$")+1,'../') -" call Decho("setline#".line("$")." ../ (depth is zero)") - endif - if a:dir =~ '^\a\+://' - if a:dir == w:netrw_treetop - let shortdir= a:dir - else - let shortdir= substitute(a:dir,'^.*/\([^/]\+\)/$','\1/','e') - endif - call setline(line("$")+1,a:depth.shortdir) - else - let shortdir= substitute(a:dir,'^.*/','','e') - call setline(line("$")+1,a:depth.shortdir.'/') - endif -" call Decho("setline#".line("$")." shortdir<".a:depth.shortdir.">") - - " append a / to dir if its missing one - let dir= a:dir - if dir !~ '/$' - let dir= dir.'/' - endif - - " display subtrees (if any) - let depth= "| ".a:depth -" call Decho("display subtrees with depth<".depth."> and current leaves") - for entry in w:netrw_treedict[a:dir] - let direntry= substitute(dir.entry,'/$','','e') -" call Decho("dir<".dir."> entry<".entry."> direntry<".direntry.">") - if entry =~ '/$' && has_key(w:netrw_treedict,direntry) -" call Decho("<".direntry."> is a key in treedict - display subtree for it") - call s:NetrwTreeDisplay(direntry,depth) - elseif entry =~ '/$' && has_key(w:netrw_treedict,direntry.'/') -" call Decho("<".direntry."/> is a key in treedict - display subtree for it") - call s:NetrwTreeDisplay(direntry.'/',depth) - else -" call Decho("<".entry."> is not a key in treedict (no subtree)") - call setline(line("$")+1,depth.entry) - endif - endfor -" call Dret("NetrwTreeDisplay") -endfun - -" --------------------------------------------------------------------- -" s:NetrwTreeListing: displays tree listing from treetop on down, using NetrwTreeDisplay() {{{2 -fun! s:NetrwTreeListing(dirname) - if w:netrw_liststyle == s:TREELIST -" call Dfunc("NetrwTreeListing() bufname<".expand("%").">") -" call Decho("curdir<".a:dirname.">") - - " update the treetop -" call Decho("update the treetop") - if !exists("w:netrw_treetop") - let w:netrw_treetop= a:dirname -" call Decho("w:netrw_treetop<".w:netrw_treetop."> (reusing)") - elseif (w:netrw_treetop =~ ('^'.a:dirname) && s:Strlen(a:dirname) < s:Strlen(w:netrw_treetop)) || a:dirname !~ ('^'.w:netrw_treetop) - let w:netrw_treetop= a:dirname -" call Decho("w:netrw_treetop<".w:netrw_treetop."> (went up)") - endif - - " insure that we have at least an empty treedict - if !exists("w:netrw_treedict") - let w:netrw_treedict= {} - endif - - " update the directory listing for the current directory -" call Decho("updating dictionary with ".a:dirname.":[..directory listing..]") -" call Decho("bannercnt=".w:netrw_bannercnt." line($)=".line("$")) - exe "silent! keepjumps ".w:netrw_bannercnt.',$g@^\.\.\=/$@d' - let w:netrw_treedict[a:dirname]= getline(w:netrw_bannercnt,line("$")) -" call Decho("treedict=".string(w:netrw_treedict)) - exe "silent! keepjumps ".w:netrw_bannercnt.",$d" - - " if past banner, record word - if exists("w:netrw_bannercnt") && line(".") > w:netrw_bannercnt - let fname= expand("") - else - let fname= "" - endif - - " display from treetop on down - call s:NetrwTreeDisplay(w:netrw_treetop,"") - - " place cursor - if !exists("s:nbcd_curpos") - if fname != "" -" call Decho("(NetrwTreeListing) place cursor <".fname.">") - call search('\<'.fname.'\>','cw') - elseif exists("w:netrw_bannercnt") - exe "keepjumps ".(w:netrw_bannercnt+1) -" call Decho("(NetrwTreeListing) place cursor line#".(w:netrw_bannercnt+1)) - endif - endif - -" call Dret("NetrwTreeListing : bufname<".expand("%").">") - endif -endfun - -" --------------------------------------------------------------------- -" s:NetrwSaveWordPosn: used by the "s" command in both remote and local {{{2 -" browsing. Along with NetrwRestoreWordPosn(), it keeps the cursor on -" the same word even though the sorting has changed its order of appearance. -fun! s:NetrwSaveWordPosn() -" call Dfunc("NetrwSaveWordPosn()") - let s:netrw_saveword= '^'.escape(getline("."),g:netrw_cd_escape).'$' -" call Dret("NetrwSaveWordPosn : saveword<".s:netrw_saveword.">") -endfun - -" --------------------------------------------------------------------- -" s:NetrwRestoreWordPosn: used by the "s" command; see NetrwSaveWordPosn() above {{{2 -fun! s:NetrwRestoreWordPosn() -" call Dfunc("NetrwRestoreWordPosn()") - silent! call search(s:netrw_saveword,'w') -" call Dret("NetrwRestoreWordPosn") -endfun - -" --------------------------------------------------------------------- -" s:NetrwMakeDir: this function makes a directory (both local and remote) {{{2 -fun! s:NetrwMakeDir(usrhost) -" call Dfunc("NetrwMakeDir(usrhost<".a:usrhost.">)") - - " get name of new directory from user. A bare will skip. - " if its currently a directory, also request will be skipped, but with - " a message. - call inputsave() - let newdirname= input("Please give directory name: ") - call inputrestore() -" call Decho("newdirname<".newdirname.">") - - if newdirname == "" -" call Dret("NetrwMakeDir : user aborted with bare ") - return - endif - - if a:usrhost == "" - - " Local mkdir: - " sanity checks - let fullnewdir= b:netrw_curdir.'/'.newdirname -" call Decho("fullnewdir<".fullnewdir.">") - if isdirectory(fullnewdir) - if !exists("g:netrw_quiet") - call netrw#ErrorMsg(s:WARNING,"<".newdirname."> is already a directory!",24) - endif -" call Dret("NetrwMakeDir : directory<".newdirname."> exists previously") - return - endif - if s:FileReadable(fullnewdir) - if !exists("g:netrw_quiet") - call netrw#ErrorMsg(s:WARNING,"<".newdirname."> is already a file!",25) - endif -" call Dret("NetrwMakeDir : file<".newdirname."> exists previously") - return - endif - - " requested new local directory is neither a pre-existing file or - " directory, so make it! - if exists("*mkdir") - call mkdir(fullnewdir,"p") - else - let netrw_origdir= s:NetrwGetcwd(1) - exe 'keepjumps cd '.b:netrw_curdir -" call Decho("netrw_origdir<".netrw_origdir.">: cd b:netrw_curdir<".b:netrw_curdir.">") -" call Decho("exe silent! !".g:netrw_local_mkdir.' '.g:netrw_shq.newdirname.g:netrw_shq) - exe "silent! !".g:netrw_local_mkdir.' '.g:netrw_shq.newdirname.g:netrw_shq - if !g:netrw_keepdir - exe 'keepjumps cd '.netrw_origdir -" call Decho("netrw_keepdir=".g:netrw_keepdir.": cd ".netrw_origdir." getcwd<".getcwd().">") - endif - endif - - if v:shell_error == 0 - " refresh listing -" call Decho("refresh listing") - let svpos= netrw#NetrwSavePosn() - call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./')) - call netrw#NetrwRestorePosn(svpos) - elseif !exists("g:netrw_quiet") - call netrw#ErrorMsg(s:ERROR,"unable to make directory<".newdirname.">",26) - endif - redraw! - - else - " Remote mkdir: - let mkdircmd = s:MakeSshCmd(g:netrw_mkdir_cmd) - let newdirname= substitute(b:netrw_curdir,'^\%(.\{-}/\)\{3}\(.*\)$','\1','').newdirname -" call Decho("exe silent! !".mkdircmd." ".g:netrw_shq.newdirname.g:netrw_shq) - exe "silent! !".mkdircmd." ".g:netrw_shq.newdirname.g:netrw_shq - if v:shell_error == 0 - " refresh listing - let svpos= netrw#NetrwSavePosn() - call s:NetrwRefresh(0,s:NetrwBrowseChgDir(0,'./')) - call netrw#NetrwRestorePosn(svpos) - elseif !exists("g:netrw_quiet") - call netrw#ErrorMsg(s:ERROR,"unable to make directory<".newdirname.">",27) - endif - redraw! - endif - -" call Dret("NetrwMakeDir") -endfun - -" --------------------------------------------------------------------- -" s:NetrwBookmarkDir: {{{2 -" 0: (user: ) bookmark current directory -" 1: (user: ) change to the bookmarked directory -" 2: (user: ) list bookmarks -" 3: (browsing) record current directory history -" 4: (user: ) go up (previous) bookmark -" 5: (user: ) go down (next) bookmark -fun! s:NetrwBookmarkDir(chg,curdir) -" call Dfunc("NetrwBookmarkDir(chg=".a:chg." curdir<".a:curdir.">) cnt=".v:count." bookmarkcnt=".g:NETRW_BOOKMARKMAX." histcnt=".g:NETRW_DIRHIST_CNT." bookmax=".g:NETRW_BOOKMARKMAX." histmax=".g:netrw_dirhistmax) - - if a:chg == 0 - " bookmark the current directory -" call Decho("(user: ) bookmark the current directory") - if v:count > 0 - " handle bookmark# specified via the count - let g:NETRW_BOOKMARKDIR_{v:count}= a:curdir - if !exists("g:NETRW_BOOKMARKMAX") - let g:NETRW_BOOKMARKMAX= v:count - elseif v:count > g:NETRW_BOOKMARKMAX - let g:NETRW_BOOKMARKMAX= v:count - endif - else - " handle no count specified - let g:NETRW_BOOKMARKMAX = g:NETRW_BOOKMARKMAX + 1 - let g:NETRW_BOOKMARKDIR_{g:NETRW_BOOKMARKMAX} = a:curdir - endif - echo "bookmarked the current directory" - - elseif a:chg == 1 - " change to the bookmarked directory -" call Decho("(user: ) change to the bookmarked directory") - if exists("g:NETRW_BOOKMARKDIR_{v:count}") - exe "e ".g:NETRW_BOOKMARKDIR_{v:count} - else - echomsg "Sorry, bookmark#".v:count." doesn't exist!" - endif - - elseif a:chg == 2 - redraw! - let didwork= 0 - " list user's bookmarks -" call Decho("(user: ) list user's bookmarks") - if exists("g:NETRW_BOOKMARKMAX") -" call Decho("list bookmarks [0,".g:NETRW_BOOKMARKMAX."]") - let cnt= 0 - while cnt <= g:NETRW_BOOKMARKMAX - if exists("g:NETRW_BOOKMARKDIR_{cnt}") -" call Decho("Netrw Bookmark#".cnt.": ".g:NETRW_BOOKMARKDIR_{cnt}) - echo "Netrw Bookmark#".cnt.": ".g:NETRW_BOOKMARKDIR_{cnt} - let didwork= 1 - endif - let cnt= cnt + 1 - endwhile - endif - - " list directory history - let cnt = g:NETRW_DIRHIST_CNT - let first = 1 - let histcnt = 0 - while ( first || cnt != g:NETRW_DIRHIST_CNT ) -" call Decho("first=".first." cnt=".cnt." dirhist_cnt=".g:NETRW_DIRHIST_CNT) - let histcnt= histcnt + 1 - if exists("g:NETRW_DIRHIST_{cnt}") -" call Decho("Netrw History#".histcnt.": ".g:NETRW_DIRHIST_{cnt}) - echo "Netrw History#".histcnt.": ".g:NETRW_DIRHIST_{cnt} - let didwork= 1 - endif - let first = 0 - let cnt = ( cnt - 1 ) % g:netrw_dirhistmax - if cnt < 0 - let cnt= cnt + g:netrw_dirhistmax - endif - endwhile - if didwork - call inputsave()|call input("Press to continue")|call inputrestore() - endif - - elseif a:chg == 3 - " saves most recently visited directories (when they differ) -" call Decho("(browsing) record curdir history") - if !exists("g:NETRW_DIRHIST_0") || g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT} != a:curdir - let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT + 1 ) % g:netrw_dirhistmax -" let g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}= substitute(a:curdir,'[/\\]$','','e') - let g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}= a:curdir -" call Decho("save dirhist#".g:NETRW_DIRHIST_CNT."<".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}.">") - endif - - elseif a:chg == 4 - " u: change to the previous directory stored on the history list -" call Decho("(user: ) chg to prev dir from history") - let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT - 1 ) % g:netrw_dirhistmax - if g:NETRW_DIRHIST_CNT < 0 - let g:NETRW_DIRHIST_CNT= g:NETRW_DIRHIST_CNT + g:netrw_dirhistmax - endif - if exists("g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}") -" call Decho("changedir u#".g:NETRW_DIRHIST_CNT."<".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}.">") - if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir") - setlocal ma noro - %d - setlocal nomod - endif -" call Decho("exe e! ".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}) - exe "e! ".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT} - else - let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT + 1 ) % g:netrw_dirhistmax - echo "Sorry, no predecessor directory exists yet" - endif - - elseif a:chg == 5 - " U: change to the subsequent directory stored on the history list -" call Decho("(user: ) chg to next dir from history") - let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT + 1 ) % g:netrw_dirhistmax - if exists("g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}") -" call Decho("changedir U#".g:NETRW_DIRHIST_CNT."<".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}.">") - if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir") - setlocal ma noro - %d - setlocal nomod - endif -" call Decho("exe e! ".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}) - exe "e! ".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT} - else - let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT - 1 ) % g:netrw_dirhistmax - if g:NETRW_DIRHIST_CNT < 0 - let g:NETRW_DIRHIST_CNT= g:NETRW_DIRHIST_CNT + g:netrw_dirhistmax - endif - echo "Sorry, no successor directory exists yet" - endif - endif - call s:NetrwBookmarkMenu() -" call Dret("NetrwBookmarkDir") -endfun - -" --------------------------------------------------------------------- -" s:NetrwBookmarkMenu: Uses menu priorities {{{2 -" .2.[cnt] for bookmarks, and -" .3.[cnt] for history -" (see s:NetrwMenu()) -fun! s:NetrwBookmarkMenu() - if !exists("s:netrw_menucnt") - return - endif -" call Dfunc("NetrwBookmarkMenu() bookmarkcnt=".g:NETRW_BOOKMARKMAX." histcnt=".g:NETRW_DIRHIST_CNT." menucnt=".s:netrw_menucnt) - if has("menu") && has("gui_running") && &go =~ 'm' - if exists("g:NetrwTopLvlMenu") - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Bookmark' - endif - - " show bookmarked places - let cnt = 0 - while cnt <= g:NETRW_BOOKMARKMAX - if exists("g:NETRW_BOOKMARKDIR_{cnt}") - let bmdir= escape(g:NETRW_BOOKMARKDIR_{cnt},'.') -" call Decho('silent! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmark.'.bmdir.' :e '.g:NETRW_BOOKMARKDIR_{cnt}) - exe 'silent! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmarks.'.bmdir.' :e '.g:NETRW_BOOKMARKDIR_{cnt}."\" - endif - let cnt= cnt + 1 - endwhile - - " show directory browsing history - let cnt = g:NETRW_DIRHIST_CNT - let first = 1 - let histcnt = 0 - while ( first || cnt != g:NETRW_DIRHIST_CNT ) - let histcnt = histcnt + 1 - let priority = g:NETRW_DIRHIST_CNT + histcnt - if exists("g:NETRW_DIRHIST_{cnt}") - let bmdir= escape(g:NETRW_DIRHIST_{cnt},'.') -" call Decho('silent! menu '.g:NetrwMenuPriority.".3.".priority." ".g:NetrwTopLvlMenu.'History.'.bmdir.' :e '.g:NETRW_DIRHIST_{cnt}) - exe 'silent! menu '.g:NetrwMenuPriority.".3.".priority." ".g:NetrwTopLvlMenu.'History.'.bmdir.' :e '.g:NETRW_DIRHIST_{cnt}."\" - endif - let first = 0 - let cnt = ( cnt - 1 ) % g:netrw_dirhistmax - if cnt < 0 - let cnt= cnt + g:netrw_dirhistmax - endif - endwhile - endif -" call Dret("NetrwBookmarkMenu") -endfun - -" --------------------------------------------------------------------- -" s:NetrwPrevWinOpen: open file/directory in previous window. {{{2 -" If there's only one window, then the window will first be split. -" Returns: -" choice = 0 : didn't have to choose -" choice = 1 : saved modified file in window first -" choice = 2 : didn't save modified file, opened window -" choice = 3 : cancel open -fun! s:NetrwPrevWinOpen(islocal) -" call Dfunc("NetrwPrevWinOpen(islocal=".a:islocal.")") - - " get last window number and the word currently under the cursor - let lastwinnr = winnr("$") - let curword = s:NetrwGetWord() - let choice = 0 -" call Decho("lastwinnr=".lastwinnr." curword<".curword.">") - - let didsplit = 0 - if lastwinnr == 1 - " if only one window, open a new one first -" call Decho("only one window, so open a new one (g:netrw_alto=".g:netrw_alto.")") - if g:netrw_preview -" call Decho("exe ".(g:netrw_alto? "top " : "bot ")."vert ".g:netrw_winsize."wincmd s") - exe (g:netrw_alto? "top " : "bot ")."vert ".g:netrw_winsize."wincmd s" - else -" call Decho("exe ".(g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s") - exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s" - endif - let didsplit = 1 - - else - call s:SaveBufVars() -" call Decho("wincmd p") - wincmd p - call s:RestoreBufVars() - " if the previous window's buffer has been changed (is modified), - " and it doesn't appear in any other extant window, then ask the - " user if s/he wants to abandon modifications therein. - let bnr = winbufnr(0) - let bnrcnt = 0 - if &mod -" call Decho("detected: prev window's buffer has been modified: bnr=".bnr." winnr#".winnr()) - let eikeep= &ei - set ei=all - windo if winbufnr(0) == bnr | let bnrcnt=bnrcnt+1 | endif - exe bnr."wincmd p" - let &ei= eikeep -" call Decho("bnr=".bnr." bnrcnt=".bnrcnt." buftype=".&bt." winnr#".winnr()) - if bnrcnt == 1 - let bufname= bufname(winbufnr(winnr())) - let choice= confirm("Save modified file<".bufname.">?","&Yes\n&No\n&Cancel") -" call Decho("bufname<".bufname."> choice=".choice." winnr#".winnr()) - - if choice == 1 - " Yes -- write file & then browse - let v:errmsg= "" - silent w - if v:errmsg != "" - call netrw#ErrorMsg(s:ERROR,"unable to write <".bufname.">!",30) - if didsplit - q - else - wincmd p - endif -" call Dret("NetrwPrevWinOpen ".choice." : unable to write <".bufname.">") - return choice - endif - - elseif choice == 2 - " No -- don't worry about changed file, just browse anyway - setlocal nomod - call netrw#ErrorMsg(s:WARNING,bufname." changes to ".bufname." abandoned",31) - wincmd p - - else - " Cancel -- don't do this - if didsplit - q - else - wincmd p - endif -" call Dret("NetrwPrevWinOpen ".choice." : cancelled") - return choice - endif - endif - endif - endif - - if a:islocal < 2 - if a:islocal - call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(a:islocal,curword)) - else - call s:NetrwBrowse(a:islocal,s:NetrwBrowseChgDir(a:islocal,curword)) - endif - endif -" call Dret("NetrwPrevWinOpen ".choice) - return choice -endfun - -" --------------------------------------------------------------------- -" s:NetrwMenu: generates the menu for gvim and netrw {{{2 -fun! s:NetrwMenu(domenu) - - if !exists("g:NetrwMenuPriority") - let g:NetrwMenuPriority= 80 - endif - - if has("menu") && has("gui_running") && &go =~ 'm' && g:netrw_menu -" call Dfunc("NetrwMenu(domenu=".a:domenu.")") - - if !exists("s:netrw_menu_enabled") && a:domenu -" call Decho("initialize menu") - let s:netrw_menu_enabled= 1 - exe 'silent! menu '.g:NetrwMenuPriority.'.1 '.g:NetrwTopLvlMenu.'Help ' - call s:NetrwBookmarkMenu() " provide some history! uses priorities 2,3, reserves 4 - exe 'silent! menu '.g:NetrwMenuPriority.'.5 '.g:NetrwTopLvlMenu.'-Sep1- :' - exe 'silent! menu '.g:NetrwMenuPriority.'.6 '.g:NetrwTopLvlMenu.'Go\ Up\ Directory- -' - exe 'silent! menu '.g:NetrwMenuPriority.'.7 '.g:NetrwTopLvlMenu.'Apply\ Special\ Viewerx x' - exe 'silent! menu '.g:NetrwMenuPriority.'.8.1 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Current\ Directorymb mb' - exe 'silent! menu '.g:NetrwMenuPriority.'.8.2 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Bookmarkgb gb' - exe 'silent! menu '.g:NetrwMenuPriority.'.8.3 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Listq q' - exe 'silent! menu '.g:NetrwMenuPriority.'.8.4 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Prev\ Diru u' - exe 'silent! menu '.g:NetrwMenuPriority.'.8.5 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Next\ DirU U' - exe 'silent! menu '.g:NetrwMenuPriority.'.9.1 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ File\ Hiding\ List'." \NetrwHideEdit" - exe 'silent! menu '.g:NetrwMenuPriority.'.9.2 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ Sorting\ SequenceS S' - exe 'silent! menu '.g:NetrwMenuPriority.'.9.3 '.g:NetrwTopLvlMenu.'Browsing\ Control.Refresh\ Listing'." \NetrwRefresh" - exe 'silent! menu '.g:NetrwMenuPriority.'.9.4 '.g:NetrwTopLvlMenu.'Browsing\ Control.Settings/Options:NetrwSettings '.":NetrwSettings\" - exe 'silent! menu '.g:NetrwMenuPriority.'.10 '.g:NetrwTopLvlMenu.'Delete\ File/DirectoryD D' - exe 'silent! menu '.g:NetrwMenuPriority.'.11.1 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ Current\ Window '."\" - exe 'silent! menu '.g:NetrwMenuPriority.'.11.2 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.Preview\ File/Directoryp p' - exe 'silent! menu '.g:NetrwMenuPriority.'.11.3 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ Previous\ WindowP P' - exe 'silent! menu '.g:NetrwMenuPriority.'.11.4 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ New\ Windowo o' - exe 'silent! menu '.g:NetrwMenuPriority.'.11.5 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ New\ Vertical\ Windowv v' - exe 'silent! menu '.g:NetrwMenuPriority.'.12 '.g:NetrwTopLvlMenu.'Make\ Subdirectoryd d' - exe 'silent! menu '.g:NetrwMenuPriority.'.13.1 '.g:NetrwTopLvlMenu.'Marked\ Files.Mark\ Filemf mf' - exe 'silent! menu '.g:NetrwMenuPriority.'.13.2 '.g:NetrwTopLvlMenu.'Marked\ Files.Mark\ Files\ by\ Regexpmr mr' - exe 'silent! menu '.g:NetrwMenuPriority.'.13.3 '.g:NetrwTopLvlMenu.'Marked\ Files.Hide-Show-List\ Controla a' - exe 'silent! menu '.g:NetrwMenuPriority.'.13.4 '.g:NetrwTopLvlMenu.'Marked\ Files.Copy\ To\ Targetmc mc' - exe 'silent! menu '.g:NetrwMenuPriority.'.13.5 '.g:NetrwTopLvlMenu.'Marked\ Files.DeleteD D' - exe 'silent! menu '.g:NetrwMenuPriority.'.13.6 '.g:NetrwTopLvlMenu.'Marked\ Files.Diffmd md' - exe 'silent! menu '.g:NetrwMenuPriority.'.13.7 '.g:NetrwTopLvlMenu.'Marked\ Files.Editme me' - exe 'silent! menu '.g:NetrwMenuPriority.'.13.8 '.g:NetrwTopLvlMenu.'Marked\ Files.Exe\ Cmdmx mx' - exe 'silent! menu '.g:NetrwMenuPriority.'.13.9 '.g:NetrwTopLvlMenu.'Marked\ Files.Move\ To\ Targetmm mm' - exe 'silent! menu '.g:NetrwMenuPriority.'.13.10 '.g:NetrwTopLvlMenu.'Marked\ Files.ObtainO O' - exe 'silent! menu '.g:NetrwMenuPriority.'.13.11 '.g:NetrwTopLvlMenu.'Marked\ Files.Printmp mp' - exe 'silent! menu '.g:NetrwMenuPriority.'.13.12 '.g:NetrwTopLvlMenu.'Marked\ Files.ReplaceR R' - exe 'silent! menu '.g:NetrwMenuPriority.'.13.13 '.g:NetrwTopLvlMenu.'Marked\ Files.Set\ Targetmt mt' - exe 'silent! menu '.g:NetrwMenuPriority.'.13.14 '.g:NetrwTopLvlMenu.'Marked\ Files.TagmT mT' - exe 'silent! menu '.g:NetrwMenuPriority.'.13.15 '.g:NetrwTopLvlMenu.'Marked\ Files.Zip/Unzip/Compress/Uncompressmz mz' - exe 'silent! menu '.g:NetrwMenuPriority.'.14 '.g:NetrwTopLvlMenu.'Obtain\ FileO O' - exe 'silent! menu '.g:NetrwMenuPriority.'.16.1 '.g:NetrwTopLvlMenu.'Style.Listing\ Style\ (thin-long-wide-tree)i i' - exe 'silent! menu '.g:NetrwMenuPriority.'.16.2 '.g:NetrwTopLvlMenu.'Style.Normal-Hide-Showa a' - exe 'silent! menu '.g:NetrwMenuPriority.'.16.3 '.g:NetrwTopLvlMenu.'Style.Reverse\ Sorting\ Order'."r r" - exe 'silent! menu '.g:NetrwMenuPriority.'.16.4 '.g:NetrwTopLvlMenu.'Style.Sorting\ Method\ (name-time-size)s s' - exe 'silent! menu '.g:NetrwMenuPriority.'.17 '.g:NetrwTopLvlMenu.'Rename\ File/DirectoryR R' - exe 'silent! menu '.g:NetrwMenuPriority.'.18 '.g:NetrwTopLvlMenu.'Set\ Current\ Directoryc c' - let s:netrw_menucnt= 28 - - elseif !a:domenu - let s:netrwcnt = 0 - let curwin = winnr() - windo if getline(2) =~ "Netrw" | let s:netrwcnt= s:netrwcnt + 1 | endif - exe curwin."wincmd w" - - if s:netrwcnt <= 1 -" call Decho("clear menus") - exe 'silent! unmenu '.g:NetrwTopLvlMenu -" call Decho('exe silent! unmenu '.g:NetrwTopLvlMenu.'*') - silent! unlet s:netrw_menu_enabled - endif - endif -" call Dret("NetrwMenu") - endif - -endfun - -" ========================================== " Local Directory Browsing Support: {{{1 " ========================================== @@ -5088,13 +5930,18 @@ fun! netrw#LocalBrowseCheck(dirname) " The &ft == "netrw" test was installed because the BufEnter event " would hit when re-entering netrw windows, creating unexpected " refreshes (and would do so in the middle of NetrwSaveOptions(), too) -" call Dfunc("LocalBrowseCheck(dirname<".a:dirname.">") -" call Decho("isdir=".isdirectory(a:dirname)." ft=".&ft." b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : " doesn't exist")."> dirname<".a:dirname.">") - if isdirectory(a:dirname) && (&ft != "netrw" || (exists("b:netrw_curdir") && b:netrw_curdir != a:dirname)) - silent! call s:NetrwBrowse(1,a:dirname) +" call Dfunc("netrw#LocalBrowseCheck(dirname<".a:dirname.">") +" call Decho("isdir=".isdirectory(a:dirname)) + if isdirectory(a:dirname) +" call Decho(" ft=".&ft." b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : " doesn't exist")."> dirname<".a:dirname.">"." line($)=".line("$")) + if &ft != "netrw" || (exists("b:netrw_curdir") && b:netrw_curdir != a:dirname) + silent! call s:NetrwBrowse(1,a:dirname) + elseif &ft == "netrw" && line("$") == 1 + silent! call s:NetrwBrowse(1,a:dirname) + endif endif -" call Dret("LocalBrowseCheck") " not a directory, ignore it +" call Dret("netrw#LocalBrowseCheck") endfun " --------------------------------------------------------------------- @@ -5118,20 +5965,30 @@ fun! s:LocalListing() let filelist= filelist."\n" endif let filelist= filelist.glob(s:ComposePath(dirname,".*")) -" call Decho("glob(dirname<".dirname."/.*>)=".glob(dirname.".*")) +" call Decho("glob(dirname<".dirname."/.*>)=".filelist) - " if the directory name includes a "$", and possibly other characters, - " the glob() doesn't include "." and ".." entries. - if filelist !~ '[\\/]\.[\\/]\=\(\n\|$\)' -" call Decho("forcibly tacking on .") - if filelist == "" - let filelist= s:ComposePath(dirname,"./") - else - let filelist= filelist."\n".s:ComposePath(b:netrw_curdir,"./") - endif -" call Decho("filelist<".filelist.">") + " Coding choice: either elide ./ if present + " or include ./ if not present + if filelist =~ '[\\/]\.[\\/]\=\(\n\|$\)' + " elide /path/. from glob() entries if present + let filelist = substitute(filelist,'\n','\t','g') + let filelist = substitute(filelist,'^[^\t]\+[/\\]\.\t','','') + let filelist = substitute(filelist,'[^\t]\+[/\\]\.$','','') + let filelist = substitute(filelist,'\t\zs[^\t]\+[/\\]\.\t','','') + let filelist = substitute(filelist,'\t','\n','g') endif +" if filelist !~ '[\\/]\.[\\/]\=\(\n\|$\)' + " include ./ in the glob() entry if its missing +" call Decho("forcibly tacking on .") +" if filelist == "" +" let filelist= s:ComposePath(dirname,"./") +" else +" let filelist= filelist."\n".s:ComposePath(b:netrw_curdir,"./") +" endif +" call Decho("filelist<".filelist.">") +" endif if filelist !~ '[\\/]\.\.[\\/]\=\(\n\|$\)' + " include ../ in the glob() entry if its missing " call Decho("forcibly tacking on ..") let filelist= filelist."\n".s:ComposePath(b:netrw_curdir,"../") " call Decho("filelist<".filelist.">") @@ -5162,9 +6019,33 @@ fun! s:LocalListing() let filename = filelist let filelist = "" endif - let pfile= filename - if isdirectory(filename) + if filename !~ '/\.$' && filename !~ '/\.\.$' && fnamemodify(filename,"") != resolve(filename) + " indicate a symbolic link +" call Decho("indicate <".filename."> is a symbolic link with trailing @") + let pfile= filename."@" + elseif isdirectory(filename) +" call Decho("indicate <".filename."> is a directory with trailing /") let pfile= filename."/" + elseif exists("b:netrw_curdir") && b:netrw_curdir !~ '^.*://' && !isdirectory(filename) + if (has("win32") || has("win95") || has("win64") || has("win16")) + if filename =~ '\.[eE][xX][eE]$' || filename =~ '\.[cC][oO][mM]$' || filename =~ '\.[bB][aA][tT]$' + " indicate an executable +" call Decho("indicate <".filename."> is executable with trailing *") + let pfile= filename."*" + else + " normal file + let pfile= filename + endif + elseif executable(filename) + " indicate an executable +" call Decho("indicate <".filename."> is executable with trailing *") + let pfile= filename."*" + else + " normal file + let pfile= filename + endif + else + let pfile= filename endif if pfile =~ '//$' let pfile= substitute(pfile,'//$','/','e') @@ -5221,16 +6102,17 @@ endfun " buffers to be refreshed after a user has executed some shell command, " on the chance that s/he removed/created a file/directory with it. fun! s:LocalBrowseShellCmdRefresh() -" call Dfunc("LocalBrowseShellCmdRefresh() browselist=".string(s:netrw_browselist)) +" call Dfunc("LocalBrowseShellCmdRefresh() browselist=".string(s:netrw_browselist)." ".tabpagenr("$")." tabs") " determine which buffers currently reside in a tab let itab = 1 let buftablist = [] while itab <= tabpagenr("$") - let buftablist= buftablist + tabpagebuflist() - let itab= itab + 1 + let buftablist = buftablist + tabpagebuflist() + let itab = itab + 1 tabn endwhile " call Decho("buftablist".string(buftablist)) +" call Decho("s:netrw_browselist<".string(s:netrw_browselist).">") " GO through all buffers on netrw_browselist (ie. just local-netrw buffers): " | refresh any netrw window " | wipe out any non-displaying netrw buffer @@ -5267,10 +6149,10 @@ fun! s:NetrwLocalRm(path) range let all = 0 let svpos = netrw#NetrwSavePosn() - if exists("s:netrwmarkfilelist") + if exists("s:netrwmarkfilelist_{bufnr('%')}") " remove all marked files " call Decho("remove all marked files") - for fname in s:netrwmarkfilelist + for fname in s:netrwmarkfilelist_{bufnr("%")} let ok= s:NetrwLocalRmFile(a:path,fname,all) if ok =~ 'q\%[uit]' break @@ -5278,8 +6160,8 @@ fun! s:NetrwLocalRm(path) range let all= 1 endif endfor - unlet s:netrwmarkfilelist - unlet s:netrwmarkfilemtch + unlet s:netrwmarkfilelist_{bufnr("%")} + unlet s:netrwmarkfilemtch_{bufnr("%")} 2match none else @@ -5409,8 +6291,8 @@ fun! s:NetrwLocalRename(path) range let svpos= netrw#NetrwSavePosn() " rename files given by the markfilelist - if exists("s:netrwmarkfilelist") - for oldname in s:netrwmarkfilelist + if exists("s:netrwmarkfilelist_{bufnr('%')}") + for oldname in s:netrwmarkfilelist_{bufnr("%")} " call Decho("oldname<".oldname.">") if exists("subfrom") let newname= substitute(oldname,subfrom,subto,'') @@ -5429,8 +6311,8 @@ fun! s:NetrwLocalRename(path) range let ret= rename(oldname,newname) endfor 2match none - unlet s:netrwmarkfilelist - unlet s:netrwmarkfilemtch + unlet s:netrwmarkfilelist_{bufnr("%")} + unlet s:netrwmarkfilemtch_{bufnr("%")} else @@ -5490,7 +6372,7 @@ fun! s:LocalFastBrowser() endif " append current buffer to fastbrowse list - if g:netrw_fastbrowse <= 1 && (empty(s:netrw_browselist) || bufnr("%") > s:netrw_browselist[-1]) + if empty(s:netrw_browselist) || bufnr("%") > s:netrw_browselist[-1] " call Decho("appendng current buffer to browselist") call add(s:netrw_browselist,bufnr("%")) " call Decho("browselist=".string(s:netrw_browselist)) @@ -5523,486 +6405,10 @@ fun! s:LocalFastBrowser() augroup! AuNetrwShellCmd endif -" call Dret("LocalFastBrowser") +" call Dret("LocalFastBrowser : browselist<".string(s:netrw_browselist).">") endfun " --------------------------------------------------------------------- -" netrw#Explore: launch the local browser in the directory of the current file {{{2 -" dosplit==0: the window will be split iff the current file has -" been modified -" dosplit==1: the window will be split before running the local -" browser -fun! netrw#Explore(indx,dosplit,style,...) -" call Dfunc("netrw#Explore(indx=".a:indx." dosplit=".a:dosplit." style=".a:style.",a:1<".a:1.">) &modified=".&modified." a:0=".a:0) - if !exists("b:netrw_curdir") - let b:netrw_curdir= getcwd() -" call Decho("set b:netrw_curdir<".b:netrw_curdir."> (used getcwd)") - endif - let curfile= b:netrw_curdir -" call Decho("curfile<".curfile.">") - - " save registers - silent! let keepregstar = @* - silent! let keepregplus = @+ - silent! let keepregslash= @/ - - " if dosplit or file has been modified - if a:dosplit || &modified || a:style == 6 -" call Decho("case: dosplit=".a:dosplit." modified=".&modified." a:style=".a:style) - call s:SaveWinVars() - - if a:style == 0 " Explore, Sexplore -" call Decho("style=0: Explore or Sexplore") - exe g:netrw_winsize."wincmd s" - - elseif a:style == 1 "Explore!, Sexplore! -" call Decho("style=1: Explore! or Sexplore!") - exe g:netrw_winsize."wincmd v" - - elseif a:style == 2 " Hexplore -" call Decho("style=2: Hexplore") - exe "bel ".g:netrw_winsize."wincmd s" - - elseif a:style == 3 " Hexplore! -" call Decho("style=3: Hexplore!") - exe "abo ".g:netrw_winsize."wincmd s" - - elseif a:style == 4 " Vexplore -" call Decho("style=4: Vexplore") - exe "lefta ".g:netrw_winsize."wincmd v" - - elseif a:style == 5 " Vexplore! -" call Decho("style=5: Vexplore!") - exe "rightb ".g:netrw_winsize."wincmd v" - - elseif a:style == 6 " Texplore - call s:SaveBufVars() -" call Decho("style = 6: Texplore") - tabnew - call s:RestoreBufVars() - endif - call s:RestoreWinVars() - endif - norm! 0 - - if a:0 > 0 -" call Decho("a:1<".a:1.">") - if a:1 =~ '^\~' && (has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin)) - let dirname= substitute(a:1,'\~',expand("$HOME"),'') -" call Decho("using dirname<".dirname."> (case: ~ && unix||cygwin)") - elseif a:1 == '.' - let dirname= exists("b:netrw_curdir")? b:netrw_curdir : getcwd() - if dirname !~ '/$' - let dirname= dirname."/" - endif -" call Decho("using dirname<".dirname."> (case: ".(exists("b:netrw_curdir")? "b:netrw_curdir" : "getcwd()").")") - elseif a:1 =~ '\$' - let dirname= expand(a:1) - else - let dirname= a:1 -" call Decho("using dirname<".dirname.">") - endif - endif - - if dirname =~ '/\*\*/' - " handle .../**/... -" call Decho("case Explore .../**/...") - let prefixdir = substitute(dirname,'^\(.\{-}\)\*\*.*$','\1','') - if prefixdir =~ '^/' || (prefixdir =~ '^\a:/' && (has("win32") || has("win95") || has("win64") || has("win16"))) - let b:netrw_curdir = prefixdir - else - let b:netrw_curdir= getcwd().'/'.prefixdir - endif - let dirname = substitute(dirname,'^.\{-}\(\*\*/.*\)$','\1','') -" call Decho("pwd<".getcwd()."> dirname<".dirname.">") - endif - - if dirname =~ '^\*/' - " Explore */pattern -" call Decho("case Explore */pattern") - let pattern= substitute(dirname,'^\*/\(.*\)$','\1','') -" call Decho("Explore */pat: dirname<".dirname."> -> pattern<".pattern.">") - if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif - elseif dirname =~ '^\*\*//' - " Explore **//pattern -" call Decho("case Explore **//pattern") - let pattern = substitute(dirname,'^\*\*//','','') - let starstarpat = 1 -" call Decho("Explore **//pat: dirname<".dirname."> -> pattern<".pattern.">") - endif - - if dirname == "" && a:indx >= 0 - " Explore Hexplore Vexplore Sexplore -" call Decho("case Explore Hexplore Vexplore Sexplore") - let newdir= substitute(expand("%:p"),'^\(.*[/\\]\)[^/\\]*$','\1','e') - if newdir =~ '^scp:' || newdir =~ '^ftp:' -" call Decho("calling NetrwBrowse(0,newdir<".newdir.">)") - call s:NetrwBrowse(0,newdir) - else - if newdir == ""|let newdir= getcwd()|endif -" call Decho("calling LocalBrowseCheck(newdir<".newdir.">)") - call netrw#LocalBrowseCheck(newdir) - endif -" call Decho("curfile<".curfile.">") - if has("win32") || has("win95") || has("win64") || has("win16") - call search('\<'.substitute(curfile,'^.*[/\\]','','e').'\>','cW') - else - call search('\<'.substitute(curfile,'^.*/','','e').'\>','cW') - endif - - elseif dirname =~ '^\*\*/' || a:indx < 0 || dirname =~ '^\*/' - " Nexplore, Pexplore, Explore **/... , or Explore */pattern -" call Decho("case Nexplore, Pexplore, , , Explore dirname<".dirname.">") - if !mapcheck("","n") && !mapcheck("","n") && exists("b:netrw_curdir") -" call Decho("set up and maps") - let s:didstarstar= 1 - nnoremap :Pexplore - nnoremap :Nexplore - endif - - if has("path_extra") -" call Decho("has path_extra") - if !exists("w:netrw_explore_indx") - let w:netrw_explore_indx= 0 - endif - let indx = a:indx -" call Decho("set indx= [a:indx=".indx."]") -" - if indx == -1 - "Nexplore -" call Decho("case Nexplore: (indx=".indx.")") - if !exists("w:netrw_explore_list") " sanity check - call netrw#ErrorMsg(s:WARNING,"using Nexplore or improperly; see help for netrw-starstar",40) - silent! let @* = keepregstar - silent! let @+ = keepregstar - silent! let @/ = keepregslash -" call Dret("netrw#Explore") - return - endif - let indx= w:netrw_explore_indx - if indx < 0 | let indx= 0 | endif - if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif - let curfile= w:netrw_explore_list[indx] -" call Decho("indx=".indx." curfile<".curfile.">") - while indx < w:netrw_explore_listlen && curfile == w:netrw_explore_list[indx] - let indx= indx + 1 -" call Decho("indx=".indx." (Nexplore while loop)") - endwhile - if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif -" call Decho("Nexplore: indx= [w:netrw_explore_indx=".w:netrw_explore_indx."]=".indx) - - elseif indx == -2 - "Pexplore -" call Decho("case Pexplore: (indx=".indx.")") - if !exists("w:netrw_explore_list") " sanity check - call netrw#ErrorMsg(s:WARNING,"using Pexplore or improperly; see help for netrw-starstar",41) - silent! let @* = keepregstar - silent! let @+ = keepregstar - silent! let @/ = keepregslash -" call Dret("netrw#Explore") - return - endif - let indx= w:netrw_explore_indx - if indx < 0 | let indx= 0 | endif - if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif - let curfile= w:netrw_explore_list[indx] -" call Decho("indx=".indx." curfile<".curfile.">") - while indx >= 0 && curfile == w:netrw_explore_list[indx] - let indx= indx - 1 -" call Decho("indx=".indx." (Pexplore while loop)") - endwhile - if indx < 0 | let indx= 0 | endif -" call Decho("Pexplore: indx= [w:netrw_explore_indx=".w:netrw_explore_indx."]=".indx) - - else - " Explore -- initialize - " build list of files to Explore with Nexplore/Pexplore -" call Decho("case Explore: initialize (indx=".indx.")") - let w:netrw_explore_indx= 0 - if !exists("b:netrw_curdir") - let b:netrw_curdir= getcwd() - endif -" call Decho("b:netrw_curdir<".b:netrw_curdir.">") - - if exists("pattern") -" call Decho("pattern exists: building list pattern<".pattern."> cwd<".getcwd().">") - if exists("starstarpat") -" call Decho("starstarpat<".starstarpat.">") - try - exe "silent vimgrep /".pattern."/gj "."**/*" - catch /^Vim\%((\a\+)\)\=:E480/ - call netrw#ErrorMsg(s:WARNING,'no files matched pattern<'.pattern.'>',45) - if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif - silent! let @* = keepregstar - silent! let @+ = keepregstar - silent! let @/ = keepregslash -" call Dret("netrw#Explore : no files matched pattern") - return - endtry - let s:netrw_curdir = b:netrw_curdir - let w:netrw_explore_list = getqflist() - let w:netrw_explore_list = map(w:netrw_explore_list,'s:netrw_curdir."/".bufname(v:val.bufnr)') - else -" call Decho("no starstarpat") - exe "vimgrep /".pattern."/gj ".b:netrw_curdir."/*" - let w:netrw_explore_list = map(getqflist(),'bufname(v:val.bufnr)') - if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif - endif - else -" call Decho("no pattern: building list based on ".b:netrw_curdir."/".dirname) - let w:netrw_explore_list= split(expand(b:netrw_curdir."/".dirname),'\n') - if &hls | let keepregslash= s:ExplorePatHls(dirname) | endif - endif - - let w:netrw_explore_listlen = len(w:netrw_explore_list) -" call Decho("w:netrw_explore_list<".string(w:netrw_explore_list)."> listlen=".w:netrw_explore_listlen) - - if w:netrw_explore_listlen == 0 || (w:netrw_explore_listlen == 1 && w:netrw_explore_list[0] =~ '\*\*\/') - call netrw#ErrorMsg(s:WARNING,"no files matched",42) - silent! let @* = keepregstar - silent! let @+ = keepregstar - silent! let @/ = keepregslash -" call Dret("netrw#Explore : no files matched") - return - endif - endif - - " NetrwStatusLine support - for exploring support - let w:netrw_explore_indx= indx -" call Decho("explorelist<".join(w:netrw_explore_list,',')."> len=".w:netrw_explore_listlen) - - " wrap the indx around, but issue a note - if indx >= w:netrw_explore_listlen || indx < 0 -" call Decho("wrap indx (indx=".indx." listlen=".w:netrw_explore_listlen.")") - let indx = (indx < 0)? ( w:netrw_explore_listlen - 1 ) : 0 - let w:netrw_explore_indx= indx - call netrw#ErrorMsg(s:NOTE,"no more files match Explore pattern",43) - sleep 1 - endif - - exe "let dirfile= w:netrw_explore_list[".indx."]" -" call Decho("dirfile=w:netrw_explore_list[indx=".indx."]= <".dirfile.">") - let newdir= substitute(dirfile,'/[^/]*$','','e') -" call Decho("newdir<".newdir.">") - -" call Decho("calling LocalBrowseCheck(newdir<".newdir.">)") - call netrw#LocalBrowseCheck(newdir) - if !exists("w:netrw_liststyle") - let w:netrw_liststyle= g:netrw_liststyle - endif - if w:netrw_liststyle == s:THINLIST || w:netrw_liststyle == s:LONGLIST - call search('^'.substitute(dirfile,"^.*/","","").'\>',"W") - else - call search('\<'.substitute(dirfile,"^.*/","","").'\>',"w") - endif - let w:netrw_explore_mtchcnt = indx + 1 - let w:netrw_explore_bufnr = bufnr("%") - let w:netrw_explore_line = line(".") - call s:SetupNetrwStatusLine('%f %h%m%r%=%9*%{NetrwStatusLine()}') -" call Decho("explore: mtchcnt=".w:netrw_explore_mtchcnt." bufnr=".w:netrw_explore_bufnr." line#".w:netrw_explore_line) - - else -" call Decho("vim does not have path_extra") - if !exists("g:netrw_quiet") - call netrw#ErrorMsg(s:WARNING,"your vim needs the +path_extra feature for Exploring with **!",44) - endif - silent! let @* = keepregstar - silent! let @+ = keepregstar - silent! let @/ = keepregslash -" call Dret("netrw#Explore : missing +path_extra") - return - endif - - else -" call Decho("case Explore newdir<".dirname.">") - if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && dirname =~ '/' - silent! unlet w:netrw_treedict - silent! unlet w:netrw_treetop - endif - let newdir= dirname - if !exists("b:netrw_curdir") - call netrw#LocalBrowseCheck(getcwd()) - else - call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,newdir)) - endif - endif - - silent! let @* = keepregstar - silent! let @+ = keepregstar - silent! let @/ = keepregslash -" call Dret("netrw#Explore : @/<".@/.">") -endfun - -" --------------------------------------------------------------------- -" s:ExplorePatHls: converts an Explore pattern into a regular expression search pattern {{{2 -fun! s:ExplorePatHls(pattern) -" call Dfunc("s:ExplorePatHls(pattern<".a:pattern.">)") - let repat= substitute(a:pattern,'^**/\{1,2}','','') -" call Decho("repat<".repat.">") - let repat= escape(repat,'][.\') -" call Decho("repat<".repat.">") - let repat= '\<'.substitute(repat,'\*','\\(\\S\\+ \\)*\\S\\+','g').'\>' -" call Dret("s:ExplorePatHls repat<".repat.">") - return repat -endfun - -" --------------------------------------------------------------------- -" s:SetupNetrwStatusLine: {{{2 -fun! s:SetupNetrwStatusLine(statline) -" call Dfunc("SetupNetrwStatusLine(statline<".a:statline.">)") - - if !exists("s:netrw_setup_statline") - let s:netrw_setup_statline= 1 -" call Decho("do first-time status line setup") - - if !exists("s:netrw_users_stl") - let s:netrw_users_stl= &stl - endif - if !exists("s:netrw_users_ls") - let s:netrw_users_ls= &laststatus - endif - - " set up User9 highlighting as needed - let keepa= @a - redir @a - try - hi User9 - catch /^Vim\%((\a\+)\)\=:E411/ - if &bg == "dark" - hi User9 ctermfg=yellow ctermbg=blue guifg=yellow guibg=blue - else - hi User9 ctermbg=yellow ctermfg=blue guibg=yellow guifg=blue - endif - endtry - redir END - let @a= keepa - endif - - " set up status line (may use User9 highlighting) - " insure that windows have a statusline - " make sure statusline is displayed - let &stl=a:statline - setlocal laststatus=2 -" call Decho("stl=".&stl) - redraw! - -" call Dret("SetupNetrwStatusLine : stl=".&stl) -endfun - -" --------------------------------------------------------------------- -" NetrwStatusLine: {{{2 -fun! NetrwStatusLine() - -" vvv NetrwStatusLine() debugging vvv -" let g:stlmsg="" -" if !exists("w:netrw_explore_bufnr") -" let g:stlmsg="!X" -" elseif w:netrw_explore_bufnr != bufnr("%") -" let g:stlmsg="explore_bufnr!=".bufnr("%") -" endif -" if !exists("w:netrw_explore_line") -" let g:stlmsg=" !X" -" elseif w:netrw_explore_line != line(".") -" let g:stlmsg=" explore_line!={line(.)<".line(".").">" -" endif -" if !exists("w:netrw_explore_list") -" let g:stlmsg=" !X" -" endif -" ^^^ NetrwStatusLine() debugging ^^^ - - if !exists("w:netrw_explore_bufnr") || w:netrw_explore_bufnr != bufnr("%") || !exists("w:netrw_explore_line") || w:netrw_explore_line != line(".") || !exists("w:netrw_explore_list") - " restore user's status line - let &stl = s:netrw_users_stl - let &laststatus = s:netrw_users_ls - if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif - if exists("w:netrw_explore_line")|unlet w:netrw_explore_line|endif - return "" - else - return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen - endif -endfun - -" --------------------------------------------------------------------- -" s:NetrwGetcwd: get the current directory. {{{2 -" Change backslashes to forward slashes, if any. -" If doesc is true, escape certain troublesome characters -fun! s:NetrwGetcwd(doesc) -" call Dfunc("NetrwGetcwd(doesc=".a:doesc.")") - let curdir= substitute(getcwd(),'\\','/','ge') - if curdir !~ '[\/]$' - let curdir= curdir.'/' - endif - if a:doesc - let curdir= escape(curdir,g:netrw_cd_escape) - endif -" call Dret("NetrwGetcwd <".curdir.">") - return curdir -endfun - -" --------------------------------------------------------------------- -" s:SetSort: sets up the sort based on the g:netrw_sort_sequence {{{2 -" What this function does is to compute a priority for the patterns -" in the g:netrw_sort_sequence. It applies a substitute to any -" "files" that satisfy each pattern, putting the priority / in -" front. An "*" pattern handles the default priority. -fun! s:SetSort() -" call Dfunc("SetSort() bannercnt=".w:netrw_bannercnt) - if w:netrw_liststyle == s:LONGLIST - let seqlist = substitute(g:netrw_sort_sequence,'\$','\\%(\t\\|\$\\)','ge') - else - let seqlist = g:netrw_sort_sequence - endif - " sanity check -- insure that * appears somewhere - if seqlist == "" - let seqlist= '*' - elseif seqlist !~ '\*' - let seqlist= seqlist.',*' - endif - let priority = 1 - while seqlist != "" - if seqlist =~ ',' - let seq = substitute(seqlist,',.*$','','e') - let seqlist = substitute(seqlist,'^.\{-},\(.*\)$','\1','e') - else - let seq = seqlist - let seqlist = "" - endif - let eseq= escape(seq,'/') - if priority < 10 - let spriority= "00".priority.'\/' - elseif priority < 100 - let spriority= "0".priority.'\/' - else - let spriority= priority.'\/' - endif -" call Decho("priority=".priority." spriority<".spriority."> seq<".seq."> seqlist<".seqlist.">") - - " sanity check - if w:netrw_bannercnt > line("$") - " apparently no files were left after a Hiding pattern was used -" call Dret("SetSort : no files left after hiding") - return - endif - if seq == '*' - exe 'silent keepjumps '.w:netrw_bannercnt.',$v/^\d\{3}\//s/^/'.spriority.'/' - else - exe 'silent keepjumps '.w:netrw_bannercnt.',$g/'.eseq.'/s/^/'.spriority.'/' - endif - let priority = priority + 1 - endwhile - - " Following line associated with priority -- items that satisfy a priority - " pattern get prefixed by ###/ which permits easy sorting by priority. - " Sometimes files can satisfy multiple priority patterns -- only the latest - " priority pattern needs to be retained. So, at this point, these excess - " priority prefixes need to be removed, but not directories that happen to - " be just digits themselves. - exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\(\d\{3}\/\)\%(\d\{3}\/\)\+\ze./\1/e' - -" call Dret("SetSort") -endfun - -" ===================================================================== " Support Functions: {{{1 " --------------------------------------------------------------------- @@ -6016,6 +6422,8 @@ fun! s:ComposePath(base,subdir) else let ret = a:base . a:subdir endif + elseif a:subdir =~ '^\a:[/\\][^/\\]' && (has("win32") || has("win95") || has("win64") || has("win16")) + let ret= a:subdir elseif a:base =~ '^\a\+://' let urlbase = substitute(a:base,'^\(\a\+://.\{-}/\)\(.*\)$','\1','') let curpath = substitute(a:base,'^\(\a\+://.\{-}/\)\(.*\)$','\2','') @@ -6063,6 +6471,7 @@ fun! netrw#ErrorMsg(level,msg,errnum) if bufexists("NetrwMessage") && bufwinnr("NetrwMessage") > 0 exe bufwinnr("NetrwMessage")."wincmd w" set ma noro +" call Decho("set ma noro") call setline(line("$")+1,level.a:msg) $ else @@ -6085,7 +6494,7 @@ fun! netrw#ErrorMsg(level,msg,errnum) else " (optional) netrw will show messages using echomsg. Even if the " message doesn't appear, at least it'll be recallable via :messages - redraw! +" redraw! if a:level == s:WARNING echohl WarningMsg elseif a:level == s:ERROR @@ -6140,6 +6549,7 @@ fun! s:GetTempfile(fname) " sanity check -- does the temporary file's directory exist? if !isdirectory(substitute(tmpfile,'[^/]\+$','','e')) +" call Decho("ro=".&ro." ma=".&ma." mod=".&mod." wrap=".&wrap) call netrw#ErrorMsg(s:ERROR,"your <".substitute(tmpfile,'[^/]\+$','','e')."> directory is missing!",2) " call Dret("s:GetTempfile getcwd<".getcwd().">") return "" @@ -6186,6 +6596,7 @@ fun! s:GetTempfile(fname) endif endif +" call Decho("ro=".&ro." ma=".&ma." mod=".&mod." wrap=".&wrap) " call Dret("s:GetTempfile <".tmpfile.">") return tmpfile endfun @@ -6220,7 +6631,7 @@ fun! s:RemoteSystem(cmd) let cmd = s:MakeSshCmd(g:netrw_ssh_cmd." USEPORT HOSTNAME") let remotedir= substitute(b:netrw_curdir,'^.*//[^/]\+/\(.*\)$','\1','') if remotedir != "" - let cmd= cmd.' "cd '."'".remotedir."';" + let cmd= cmd.' "lcd '."'".remotedir."';" else let cmd= cmd.' "' endif @@ -6256,13 +6667,8 @@ fun! s:NetrwEnew(curdir) if exists("b:netrw_prvdir") |let netrw_prvdir = b:netrw_prvdir |endif call s:NetrwOptionRestore("w:") - if getline(2) =~ '^" Netrw Directory Listing' -" call Decho("generate a buffer with keepjumps keepalt enew! (1)") - keepjumps keepalt enew! - else -" call Decho("generate a buffer with keepjumps enew! (2)") - keepjumps enew! - endif +" call Decho("generate a buffer with keepjumps keepalt enew!") + keepjumps keepalt enew! call s:NetrwOptionSave("w:") " copy function-local-variables to buffer variable equivalents @@ -6290,14 +6696,94 @@ fun! s:NetrwEnew(curdir) nno [ :silent call TreeListMove('[') nno ] :silent call TreeListMove(']') else - exe "silent! file ".b:netrw_curdir + exe "silent! keepalt file ".b:netrw_curdir endif endif -" call Dret("s:NetrwEnew : buf#".bufnr("%")."<".bufname("%").">") +" call Dret("s:NetrwEnew : buf#".bufnr("%")."<".bufname("%")."> expand(%)<".expand("%")."> expand(#)<".expand("#").">") endfun " ------------------------------------------------------------------------ +" netrw#NetrwSavePosn: saves position of cursor on screen {{{2 +fun! netrw#NetrwSavePosn() +" call Dfunc("netrw#NetrwSavePosn()") + " Save current line and column + let w:netrw_winnr= winnr() + let w:netrw_line = line(".") + let w:netrw_col = virtcol(".") + + " Save top-of-screen line + norm! H0 + let w:netrw_hline= line(".") + + " set up string holding position parameters + let ret = "let w:netrw_winnr=".w:netrw_winnr."|let w:netrw_line=".w:netrw_line."|let w:netrw_col=".w:netrw_col."|let w:netrw_hline=".w:netrw_hline + + call netrw#NetrwRestorePosn() +" call Dret("netrw#NetrwSavePosn : winnr=".w:netrw_winnr." line=".w:netrw_line." col=".w:netrw_col." hline=".w:netrw_hline) + return ret +endfun + +" ------------------------------------------------------------------------ +" netrw#NetrwRestorePosn: restores the cursor and file position as saved by NetrwSavePosn() {{{2 +fun! netrw#NetrwRestorePosn(...) +" call Dfunc("netrw#NetrwRestorePosn() a:0=".a:0." winnr=".(exists("w:netrw_winnr")? w:netrw_winnr : -1)." line=".(exists("w:netrw_line")? w:netrw_line : -1)." col=".(exists("w:netrw_col")? w:netrw_col : -1)." hline=".(exists("w:netrw_hline")? w:netrw_hline : -1)) + let eikeep= &ei + set ei=all + if expand("%") == "NetrwMessage" + exe s:winBeforeErr."wincmd w" + endif + + if a:0 > 0 + exe a:1 + endif + + " restore window + if exists("w:netrw_winnr") +" call Decho("restore window: exe silent! ".w:netrw_winnr."wincmd w") + exe "silent! ".w:netrw_winnr."wincmd w" + endif + if v:shell_error == 0 + " as suggested by Bram M: redraw on no error + " allows protocol error messages to remain visible +" redraw! + endif + + " restore top-of-screen line + if exists("w:netrw_hline") +" call Decho("restore topofscreen: exe norm! ".w:netrw_hline."G0z") + exe "norm! ".w:netrw_hline."G0z\" + endif + + " restore position + if exists("w:netrw_line") && exists("w:netrw_col") +" call Decho("restore posn: exe norm! ".w:netrw_line."G0".w:netrw_col."|") + exe "norm! ".w:netrw_line."G0".w:netrw_col."\" + endif + + let &ei= eikeep +" call Dret("netrw#NetrwRestorePosn") +endfun + +" --------------------------------------------------------------------- +" s:NetrwSaveWordPosn: used to keep cursor on same word after refresh, {{{2 +" changed sorting, etc. Also see s:NetrwRestoreWordPosn(). +fun! s:NetrwSaveWordPosn() +" call Dfunc("NetrwSaveWordPosn()") + let s:netrw_saveword= '^'.escape(getline("."),g:netrw_cd_escape).'$' +" call Dret("NetrwSaveWordPosn : saveword<".s:netrw_saveword.">") +endfun + +" --------------------------------------------------------------------- +" s:NetrwRestoreWordPosn: used to keep cursor on same word after refresh, {{{2 +" changed sorting, etc. Also see s:NetrwSaveWordPosn(). +fun! s:NetrwRestoreWordPosn() +" call Dfunc("NetrwRestoreWordPosn()") + silent! call search(s:netrw_saveword,'w') +" call Dret("NetrwRestoreWordPosn") +endfun + +" --------------------------------------------------------------------- " s:RemotePathAnalysis: {{{2 fun! s:RemotePathAnalysis(dirname) " call Dfunc("s:RemotePathAnalysis()") @@ -6429,7 +6915,7 @@ fun! s:SetRexDir(islocal,dirname) " set up Rex and leftmouse-double-click if a:islocal exe 'com! Rexplore call netrw#LocalBrowseCheck("'.escape(a:dirname,g:netrw_cd_escape).'")' - if !g:netrw_noretmap + if g:netrw_retmap silent! unmap <2-leftmouse> if !hasmapto("NetrwReturn") nmap <2-leftmouse> NetrwReturn @@ -6438,7 +6924,7 @@ fun! s:SetRexDir(islocal,dirname) endif else exe 'com! Rexplore call s:NetrwBrowse(0,"'.escape(a:dirname,g:netrw_cd_escape).'")' - if !g:netrw_noretmap + if g:netrw_retmap silent! unmap <2-leftmouse> if !hasmapto("NetrwReturn") nmap <2-leftmouse> NetrwReturn @@ -6450,7 +6936,7 @@ fun! s:SetRexDir(islocal,dirname) endfun " --------------------------------------------------------------------- -" s:Strlen: this function returns the length of a string, even if its {{{1 +" s:Strlen: this function returns the length of a string, even if its {{{2 " using two-byte etc characters. Depends on virtcol(). " Currently, its only used if g:Align_xstrlen is set to a " nonzero value. diff --git a/vimfiles/autoload/netrwSettings.vim b/vimfiles/autoload/netrwSettings.vim index fe3c04a..a2b7c11 100644 --- a/vimfiles/autoload/netrwSettings.vim +++ b/vimfiles/autoload/netrwSettings.vim @@ -126,6 +126,7 @@ fun! netrwSettings#NetrwSettings() put = 'let g:netrw_mkdir_cmd = '.g:netrw_mkdir_cmd put = 'let g:netrw_preview = '.g:netrw_preview put = 'let g:netrw_rename_cmd = '.g:netrw_rename_cmd + put = 'let g:netrw_retmap = '.g:netrw_retmap put = 'let g:netrw_rm_cmd = '.g:netrw_rm_cmd put = 'let g:netrw_rmdir_cmd = '.g:netrw_rmdir_cmd put = 'let g:netrw_rmf_cmd = '.g:netrw_rmf_cmd @@ -133,6 +134,7 @@ fun! netrwSettings#NetrwSettings() put = 'let g:netrw_sort_by = '.g:netrw_sort_by put = 'let g:netrw_sort_direction = '.g:netrw_sort_direction put = 'let g:netrw_sort_sequence = '.g:netrw_sort_sequence + put = 'let g:netrw_special_syntax = '.g:netrw_special_syntax put = 'let g:netrw_ssh_browse_reject = '.g:netrw_ssh_browse_reject put = 'let g:netrw_scpport = '.g:netrw_scpport put = 'let g:netrw_sshport = '.g:netrw_sshport diff --git a/vimfiles/autoload/visincr.vim b/vimfiles/autoload/visincr.vim index 8361e42..d0ab614 100644 --- a/vimfiles/autoload/visincr.vim +++ b/vimfiles/autoload/visincr.vim @@ -1,7 +1,7 @@ " visincr.vim: Visual-block incremented lists " Author: Charles E. Campbell, Jr. Ph.D. -" Date: Sep 19, 2006 -" Version: 17 +" Date: Dec 19, 2007 +" Version: 19 " " Visincr assumes that a block of numbers selected by a " ctrl-v (visual block) has been selected for incrementing. @@ -26,32 +26,43 @@ if &cp || exists("g:loaded_visincr") finish endif let s:keepcpo = &cpo -let g:loaded_visincr = "v17" +let g:loaded_visincr = "v19" set cpo&vim " --------------------------------------------------------------------- " Methods: {{{1 -let s:I = 0 -let s:II = 1 -let s:IMDY = 2 -let s:IYMD = 3 -let s:IDMY = 4 -let s:ID = 5 -let s:IM = 6 -let s:IA = 7 -let s:IX = 8 -let s:IIX = 9 -let s:IO = 10 -let s:IIO = 11 -let s:IR = 12 -let s:IIR = 13 -let s:RI = 14 -let s:RII = 15 -let s:RIMDY = 16 -let s:RIYMD = 17 -let s:RIDMY = 18 -let s:RID = 19 -let s:RIM = 20 +let s:I = 0 +let s:II = 1 +let s:IMDY = 2 +let s:IYMD = 3 +let s:IDMY = 4 +let s:ID = 5 +let s:IM = 6 +let s:IA = 7 +let s:IX = 8 +let s:IIX = 9 +let s:IO = 10 +let s:IIO = 11 +let s:IR = 12 +let s:IIR = 13 +let s:IPOW = 14 +let s:IIPOW = 15 +let s:RI = 16 +let s:RII = 17 +let s:RIMDY = 18 +let s:RIYMD = 19 +let s:RIDMY = 20 +let s:RID = 21 +let s:RIM = 22 +let s:RIA = 23 +let s:RIX = 24 +let s:RIIX = 25 +let s:RIO = 26 +let s:RIIO = 27 +let s:RIR = 28 +let s:RIIR = 29 +let s:RIPOW = 30 +let s:RIIPOW = 31 " ------------------------------------------------------------------------------ " Options: {{{1 @@ -60,7 +71,7 @@ if !exists("g:visincr_leaddate") let g:visincr_leaddate = '0' endif if !exists("g:visincr_datedivset") - let g:visincr_datedivset= '[-./]' + let g:visincr_datedivset= '[-./_:~,+*^]\=' endif " ============================================================================== @@ -86,17 +97,20 @@ fun! visincr#VisBlockIncr(method,...) " save boundary line numbers and set up method {{{3 let y1 = line("'<") let y2 = line("'>") - let method = (a:method >= s:RI)? a:method - s:RI : a:method + let method = (a:method >= s:RI)? (a:method - s:RI) : a:method let leaddate= g:visincr_leaddate +" call Decho("a:method=".a:method." s:RI=".s:RI." method=".method." leaddeate<".leaddate.">") - " get increment (default=1) {{{3 + " get increment (default=1; except for power increments, that's default=2) {{{3 if a:0 > 0 let incr= a:1 - if a:method == s:IX || a:method == s:IIX + if method == s:IX || method == s:IIX let incr= s:Hex2Dec(incr) - elseif a:method == s:IO || a:method == s:IIO + elseif method == s:IO || method == s:IIO let incr= s:Oct2Dec(incr) endif + elseif method == s:IPOW || method == s:IIPOW + let incr= 2 else let incr= 1 endif @@ -153,6 +167,14 @@ fun! visincr#VisBlockIncr(method,...) let restrict= '\c\%'.col(".").'c\(jan\|feb\|mar\|apr\|may\|jun\|jul\|aug\|sep\|oct\|nov\|dec\)' endif " call Decho(":IM restricted<".restrict.">") + + elseif a:method == s:RIPOW + let restrict= '\%'.col(".").'c\d' +" call Decho(":RIPOW restricted<".restrict.">") + + elseif a:method == s:RIIPOW + let restrict= '\%'.col(".").'c\s\{,'.width.'}\d' +" call Decho(":RIIPOW restricted<".restrict.">") endif " determine zfill {{{3 @@ -368,10 +390,19 @@ fun! visincr#VisBlockIncr(method,...) let pat = '^.*\%'.leftcol.'v\( \=[0-9]\{1,4}\)'.g:visincr_datedivset.'\( \=[0-9]\{1,2}\)'.g:visincr_datedivset.'\( \=[0-9]\{1,4}\)\%'.rghtcol.'v.*$' let datediv= substitute(curline,'^.*\%'.leftcol.'v\%( \=[0-9]\{1,4}\)\('.g:visincr_datedivset.'\).*$','\1','') + if strlen(datediv) > 1 + redraw! + echohl WarningMsg + echomsg "***visincr*** Your date looks odd, is g:visincr_datedivset<".g:visincr_datedivset."> what you want?" + endif +" call Decho("pat <".pat.">") " call Decho("datediv<".datediv.">") " IMDY: {{{3 if method == s:IMDY + if datediv == "" + let pat= '^.*\%'.leftcol.'v\( \=[0-9]\{1,2}\)\( \=[0-9]\{1,2}\)\( \=[0-9]\{1,4}\)\%'.rghtcol.'v.*$' + endif let m = substitute(substitute(curline,pat,'\1',''),' ','','ge')+0 let d = substitute(substitute(curline,pat,'\2',''),' ','','ge')+0 let y = substitute(substitute(curline,pat,'\3',''),' ','','ge')+0 @@ -380,6 +411,9 @@ fun! visincr#VisBlockIncr(method,...) " IYMD: {{{3 elseif method == s:IYMD + if datediv == "" + let pat= '^.*\%'.leftcol.'v\( \=[0-9]\{1,4}\)\( \=[0-9]\{1,2}\)\( \=[0-9]\{1,2}\)\%'.rghtcol.'v.*$' + endif let y = substitute(substitute(curline,pat,'\1',''),' ','','ge')+0 let m = substitute(substitute(curline,pat,'\2',''),' ','','ge')+0 let d = substitute(substitute(curline,pat,'\3',''),' ','','ge')+0 @@ -388,6 +422,9 @@ fun! visincr#VisBlockIncr(method,...) " IDMY: {{{3 elseif method == s:IDMY + if datediv == "" + let pat= '^.*\%'.leftcol.'v\( \=[0-9]\{1,2}\)\( \=[0-9]\{1,2}\)\( \=[0-9]\{1,4}\)\%'.rghtcol.'v.*$' + endif let d = substitute(substitute(curline,pat,'\1',''),' ','','ge')+0 let m = substitute(substitute(curline,pat,'\2',''),' ','','ge')+0 let y = substitute(substitute(curline,pat,'\3',''),' ','','ge')+0 @@ -454,7 +491,7 @@ fun! visincr#VisBlockIncr(method,...) return endif " IMDY IYMD IDMY ID IM - " I II IX IIX IO IIO IR IIR: {{{3 + " I II IX IIX IO IIO IR IIR IPOW IIPOW: {{{3 " construct a line from the first line that only has the number in it let rml = rghtcol - leftcol let rmlp1 = rml + 1 @@ -508,6 +545,7 @@ fun! visincr#VisBlockIncr(method,...) let ocnt = cnt " call Decho("cntlen=".cntlen." cnt=".cnt." ocnt=".ocnt." (before I*[XOR] subs)") + " elide leading zeros if method == s:IX || method == s:IIX let cnt= substitute(cnt,'^0*\([1-9a-fA-F]\|0$\)','\1',"ge") elseif method == s:IO || method == s:IIO @@ -539,6 +577,20 @@ fun! visincr#VisBlockIncr(method,...) else let maxcnt= s:Dec2Rom(s:Rom2Dec(cnt) + incr*(y2 - y1)) endif + elseif method == s:IPOW || method == s:IIPOW + let maxcnt = cnt + let i = 1 + if incr > 0 + while i <= (y2-y1) + let maxcnt= maxcnt*incr + let i= i + 1 + endwhile + else + while i <= (y2-y1) + let maxcnt= maxcnt/(-incr) + let i= i + 1 + endwhile + endif else let maxcnt= printf("%d",cnt + incr*(y2 - y1)) endif @@ -596,9 +648,9 @@ fun! visincr#VisBlockIncr(method,...) let ins= ins - 1 endwhile - " back up to left-of-block (plus optional left-hand-side modeling) {{{3 + " back up to left-of-block (plus optional left-hand-side modeling) (left-justification support) {{{3 norm! 0 - if method == s:I || method == s:IO || method == s:IX || method == s:IR + if method == s:I || method == s:IO || method == s:IX || method == s:IR || method == s:IPOW let bkup= leftcol " call Decho("bkup= [leftcol=".leftcol."] (due to method)") elseif maxcntlen > 0 @@ -627,7 +679,7 @@ fun! visincr#VisBlockIncr(method,...) silent! exe 's/\%'.leftcol.'v\( \+\)/\=substitute(submatch(1)," ","'.zfill.'","ge")/e' endif - " set up for next line {{{3 + " update cnt: set up for next line {{{3 if l != y2 norm! j endif @@ -637,6 +689,12 @@ fun! visincr#VisBlockIncr(method,...) let cnt= s:Dec2Oct(s:Oct2Dec(cnt) + incr) elseif method == s:IR || method == s:IIR let cnt= s:Dec2Rom(s:Rom2Dec(cnt) + incr) + elseif method == s:IPOW || method == s:IIPOW + if incr > 0 + let cnt= cnt*incr + elseif incr < 0 + let cnt= cnt/(-incr) + endif else let cnt= cnt + incr endif diff --git a/vimfiles/colors/reloaded.vim b/vimfiles/colors/reloaded.vim index 4f8aa5c..5d111b2 100644 --- a/vimfiles/colors/reloaded.vim +++ b/vimfiles/colors/reloaded.vim @@ -10,18 +10,17 @@ if exists("syntax_on") endif let g:colors_name="reloaded" - hi LineNr term=bold gui=bold guifg=White guibg=DarkGray hi Normal ctermfg=Green ctermbg=Black hi Normal guifg=Green guibg=Black - hi NonText ctermfg=DarkGray ctermbg=Black - hi NonText guifg=DarkGray guibg=Black + hi NonText ctermfg=DarkGreen ctermbg=Black + hi NonText guifg=DarkGreen guibg=Black hi Statement ctermfg=Green ctermbg=Black hi Statement guifg=Green guibg=Black hi Comment ctermfg=DarkGreen ctermbg=Black cterm=bold term=bold hi Comment guifg=DarkGreen guibg=Black gui=bold term=bold - hi Constant ctermfg=Black ctermbg=Green - hi Constant guifg=Black guibg=Green + hi Constant ctermfg=Green ctermbg=DarkGreen + hi Constant guifg=Green guibg=DarkGreen hi Identifier ctermfg=Green ctermbg=Black hi Identifier guifg=Green guibg=Black hi Type ctermfg=Green ctermbg=Black @@ -48,19 +47,24 @@ let g:colors_name="reloaded" hi WarningMsg guifg=Yellow guibg=Black hi VertSplit ctermfg=White ctermbg=Black hi VertSplit guifg=White guibg=Black - hi Directory ctermfg=Green ctermbg=DarkBlue - hi Directory guifg=Green guibg=DarkBlue + hi Directory ctermfg=DarkGreen ctermbg=Black + hi Directory guifg=DarkGreen guibg=Black hi Visual ctermfg=White ctermbg=DarkGray cterm=underline term=none hi Visual guifg=White guibg=DarkGray gui=underline term=none hi Title ctermfg=White ctermbg=DarkBlue hi Title guifg=White guibg=DarkBlue - hi StatusLine term=bold cterm=bold,underline ctermfg=White ctermbg=Black - hi StatusLine term=bold gui=bold,underline guifg=White guibg=Black + hi StatusLine term=bold cterm=bold,underline ctermfg=Green ctermbg=Black + hi StatusLine term=bold gui=bold,underline guifg=Green guibg=Black hi StatusLineNC term=bold cterm=bold,underline ctermfg=Gray ctermbg=Black hi StatusLineNC term=bold gui=bold,underline guifg=Gray guibg=Black - hi LineNr term=bold cterm=bold ctermfg=White ctermbg=DarkGray - hi LineNr term=bold gui=bold guifg=White guibg=DarkGray + hi LineNr term=bold cterm=bold ctermfg=Black ctermbg=DarkGreen + hi LineNr term=bold gui=bold guifg=Black guibg=DarkGreen + hi SpecialKey guifg=DarkGreen guibg=Black + hi SpecialKey ctermfg=DarkGreen ctermbg=Black + + hi cursorline guifg=Black guibg=DarkGreen + hi cursorline ctermfg=Black ctermbg=DarkGreen + hi cursorcolumn guifg=Black guibg=Green + hi cursorcolumn ctermfg=Black ctermbg=Green - hi cursorline ctermbg=White - hi cursorline guibg=DarkGray diff --git a/vimfiles/doc/Align.txt b/vimfiles/doc/Align.txt new file mode 100644 index 0000000..a79a566 --- /dev/null +++ b/vimfiles/doc/Align.txt @@ -0,0 +1,1387 @@ +*align.txt* The Alignment Tool Mar 06, 2008 + +Author: Charles E. Campbell, Jr. + (remove NOSPAM from Campbell's email first) +Copyright: (c) 2004-2008 by Charles E. Campbell, Jr. *Align-copyright* + The VIM LICENSE applies to Align.vim, AlignMaps.vim, and Align.txt + (see |copyright|) except use "Align and AlignMaps" instead of "Vim" + NO WARRANTY, EXPRESS OR IMPLIED. USE AT-YOUR-OWN-RISK. + +============================================================================== +1. Contents *align* *align-contents* + + 1. Contents.................: |align-contents| + 2. Alignment Manual.........: |align-manual| + 3. Alignment Usage..........: |align-usage| + Alignment Concepts.......: |align-concepts| + Alignment Commands.......: |align-commands| + Alignment Control........: |align-control| + Separators.............: |alignctrl-separators| + Initial Whitespace.....: |alignctrl-w| |alignctrl-W| |alignctrl-I| + Justification..........: |alignctrl-l| |alignctrl-r| |alignctrl-c| + Justification Control..: |alignctrl--| |alignctrl-+| |alignctrl-:| + Cyclic/Sequential......: |alignctrl-=| |alignctrl-C| + Separator Justification: |alignctrl-<| |alignctrl->| |alignctrl-|| + Line (de)Selection.....: |alignctrl-g| |alignctrl-v| + Temporary Settings.....: |alignctrl-m| + Padding................: |alignctrl-p| |alignctrl-P| + Current Options........: |alignctrl-settings| |alignctrl-| + Alignment................: |align-align| + Maps.....................: |align-maps| + \a,....................: |alignmap-a,| + \a?....................: |alignmap-a?| + \a<....................: |alignmap-a<| + \abox..................: |alignmap-abox| + \acom..................: |alignmap-acom| + \anum..................: |alignmap-anum| + \ascom.................: |alignmap-ascom| + \adec..................: |alignmap-adec| + \adef..................: |alignmap-adef| + \afnc..................: |alignmap-afnc| + \adcom.................: |alignmap-adcom| + \aocom.................: |alignmap-aocom| + \tsp...................: |alignmap-tsp| + \tsq...................: |alignmap-tsq| + \tt....................: |alignmap-tt| + \t=....................: |alignmap-t=| + \T=....................: |alignmap-T=| + \Htd...................: |alignmap-Htd| + 4. Alignment Tool History...: |align-history| + +============================================================================== +2. Align Manual *alignman* *alignmanual* *align-manual* + + To Enable: put and into your .vim/plugin + To see a user's guide, see |align-usage| + To see examples, see |alignctrl| and |alignmaps| +> +/=============+=========+=====================================================\ +|| \ Default/ || +|| Commands \ Value/ Explanation || +|| | | || +++==============+====+=======================================================++ +|| AlignCtrl | | =Clrc-+:pPIWw [..list-of-separator-patterns..] || +|| | +-------------------------------------------------------+| +|| | | may be called as a command or as a function: || +|| | | :AlignCtrl =lp0P0W & \\ || +|| | | :call Align#AlignCtrl('=lp0P0W','&','\\') || +|| | | || +|| | +-------------------------------------------------------++ +|| 1st arg | = | = all separator patterns are equivalent and are || +|| | | simultaneously active. Patterns are |regexp|. || +|| | | C cycle through separator patterns. Patterns are || +|| | | |regexp| and are active sequentially. || +|| | | || +|| | < | < left justify separator Separators are justified, || +|| | | > right justify separator too. Separator styles || +|| | | | center separator are cyclic. || +|| | | || +|| | l | l left justify Justification styles are always || +|| | | r right justify cyclic (ie. lrc would mean left j., || +|| | | c center then right j., then center, repeat. || +|| | | - skip this separator || +|| | | + re-use last justification method || +|| | | : treat rest of text as a field || +|| | | || +|| | p1 | p### pad separator on left by # blanks || +|| | P1 | P### pad separator on right by # blanks || +|| | | || +|| | I | I preserve and apply first line's leading white || +|| | | space to all lines || +|| | | W preserve leading white space on every line, even || +|| | | if it varies from line to line || +|| | | w don't preserve leading white space || +|| | | || +|| | | g second argument is a selection pattern -- only || +|| | | align on lines that have a match (inspired by || +|| | | :g/selection pattern/command) || +|| | | v second argument is a selection pattern -- only || +|| | | align on lines that _don't_ have a match (inspired || +|| | | by :v/selection pattern/command) || +|| | | || +|| | | m Map support: AlignCtrl will immediately do an || +|| | | AlignPush() and the next call to Align() will do || +|| | | an AlignPop at the end. This feature allows maps || +|| | | to preserve user settings. || +|| | | || +|| | | default || +|| | | AlignCtrl default || +|| | | will clear the AlignCtrl || +|| | | stack & set the default: AlignCtrl "Ilp1P1=" '=' || +|| | | || +|| +----+-------------------------------------------------------+| +|| More args | More arguments are interpreted as describing separators || +|| +------------------------------------------------------------+| +|| No args | AlignCtrl will display its current settings || +||==============+============================================================+| +||[range]Align | [..list-of-separators..] || +||[range]Align! | [AlignCtrl settings] [..list-of-separators..] || +|| +------------------------------------------------------------+| +|| | Aligns text over the given range. The range may be || +|| | selected via visual mode (v, V, or ctrl-v) or via || +|| | the command line. The Align operation may be invoked || +|| | as a command or as a function; as a function, the first || +|| | argument is 0=separators only, 1=AlignCtrl option string || +|| | followed by a list of separators. || +|| | :[range]Align || +|| | :[range]Align [list of separators] || +|| | :[range]call Align#Align(0) || +|| | :[range]call Align#Align(0,"list","of","separators",...) || +\=============================================================================/ + +============================================================================== +3. Alignment Usage *alignusage* *align-usage* + + +ALIGNMENT CONCEPTS *align-concept* *align-concepts* + + The typical text to be aligned is considered to be: + + * composed of two or more fields + * separated by one or more separator pattern(s): + * two or more lines +> + ws field ws separator ws field ws separator ... + ws field ws separator ws field ws separator ... +< + where "ws" stands for "white space" such as blanks and/or tabs, + and "fields" are arbitrary text. For example, consider > + + x= y= z= 3; + xx= yy= zz= 4; + zzz= yyy= zzz= 5; + a= b= c= 3; +< + Assume that it is desired to line up all the "=" signs; these, + then, are the separators. The fields are composed of all the + alphameric text. Assuming they lie on lines 1-4, one may align + those "=" signs with: > + :AlignCtrl l + :1,4Align = +< The result is: > + x = y = z = 3; + xx = yy = zz = 4; + zzz = yyy = zzz = 5; + a = b = c = 3; + +< Note how each "=" sign is surrounded by a single space; the + default padding is p1P1 (p1 means one space before the separator, + and P1 means one space after it). If you wish to change the + padding, say to no padding, use (see |alignctrl-p|) > + :AlignCtrl lp0P0 + +< Next, note how each field is left justified; that's what the "l" + (a small letter "ell") does. If right-justification of the fields + had been desired, an "r" could've been used: > + :AlignCtrl r +< yielding > + x = y = z = 3; + xx = yy = zz = 4; + zzz = yyy = zzz = 5; + a = b = c = 3; +< There are more options available for field justification: see + |alignctrl-c|. + + Separators, although commonly only one character long, are actually + specified by regular expressions (see |regexp|), and one may left + justify, right justify, or center them, too (see |alignctrl-<|). + + Assume that for some reason a left-right-left-right-... justification + sequence was wished. This wish is simply achieved with > + :AlignCtrl lr + :1,4Align = +< because the justification commands are considered to be "cylic"; ie. + lr is the same as lrlrlrlrlrlrlr... + + There's a lot more discussed under |alignctrl|; hopefully the examples + there will help, too. + + +ALIGNMENT COMMANDS *align-command* *align-commands* + + The script includes two primary commands and two + minor commands: + + AlignCtrl : this command/function sets up alignment options + which persist until changed for later Align calls. + It controls such things as: how to specify field + separators, initial white space, padding about + separators, left/right/center justification, etc. > + ex. AlignCtrl wp0P1 + Interpretation: during subsequent alignment + operations, preserve each line's initial + whitespace. Use no padding before separators + but provide one padding space after separators. +< + Align : this command/function operates on the range given it to + align text based on one or more separator patterns. The + patterns may be provided via AlignCtrl or via Align + itself. > + + ex. :%Align , + Interpretation: align all commas over the entire + file. +< The :Align! format permits alignment control commands + to precede the alignment patterns. > + ex. :%Align! p2P2 = +< This will align all "=" in the file with two padding + spaces on both sides of each "=" sign. + NOTE ON PATTERNS:~ + Align and AlignCtrl use || to obtain their + input patterns; hence, to get a \ you'll need to enter + two backslashes: \\. + + AlignPush : this command/function pushes the current AlignCtrl + state onto an internal stack. > + ex. :AlignPush + Interpretation: save the current AlignCtrl + settings, whatever they may be. They'll + also remain as the current settings until + AlignCtrl is used to change them. +< + AlignPop : this command/function pops the current AlignCtrl + state from an internal stack. > + ex. :AlignPop + Interpretation: presumably AlignPush was + used (at least once) previously; this command + restores the AlignCtrl settings when AlignPush + was last used. +< + +ALIGNMENT OPTIONS *align-option* *align-options* + + *align-utf8* *align-utf* *align-codepoint* *align-strlen* + For those of you who are using 2-byte (or more) characters such as is + available with utf-8, Align now provides a special option which you + may choose based upon your needs: + + Number of codepoints (Latin a + combining circumflex is two codepoints)~ +> + let g:Align_xstrlen= 1: +< + 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.)~ +> + let g:Align_xstrlen= 2 +< + 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.)~ +> + let g:Align_xstrlen= 2 +< + By putting one of these settings into your <.vimrc>, Align will use an + internal (interpreted) function to determine a string's length instead + of the built-in to Vim's |strlen()| function. As the function is + interpreted, Align will run a bit slower but will handle such strings + correctly. The last setting (g:Align_xstrlen= 2) probably will run + the slowest but be the most accurate. + (thanks to Tony Mechelynck for these) + + +ALIGNMENT CONTROL *alignctrl* *align-control* + + This command doesn't do the alignment operation itself; instead, it + controls the subsequent alignment operation(s). + + The first argument to AlignCtrl is a string which may contain one or + more alignment control commands. Most of the commands are single + letter commands; the exceptions are the p# and P# commands which + interpret digits following the p or P as specifying padding about the + separator. + + The typical text line is considered to be composed of two or more + fields separated by one or more separator pattern(s): +> + ws field ws separator ws field ws separator ... < where "ws" +< + stands for "white space" such as blanks and/or tabs. + + + Separators *alignctrl-separators* + + As a result, separators may not have white space (tabs or blanks) on + their outsides (ie. ": :" is fine as a separator, but " :: " is + not). Usually such separators are not needed. + + However, if you really need to have such separators with leading or + trailing whitespace, consider handling them by performing a substitute + first (ie. s/ :: /@/g), do the alignment on the temporary pattern + (ie. @), and then perform a substitute to revert the separators back + to their desired condition (ie. s/@/ :: /g). + + The Align() function will first convert tabs over the region into + spaces and then apply alignment control. Except for initial white + space, white space surrounding the fields is ignored. One has three + options just for handling initial white space: + + + --- *alignctrl-w* + wWI INITIAL WHITE SPACE *alignctrl-W* + --- *alignctrl-I* + w : ignore all selected lines' initial white space + W : retain all selected lines' initial white space + I : retain only the first line's initial white space and + re-use it for subsequent lines + + Example: Leading white space options: > + +---------------+-------------------+-----------------+ + |AlignCtrl w= :=| AlignCtrl W= := | AlignCtrl I= := | + +------------------+---------------+-------------------+-----------------+ + | Original | w option | W option | I option | + +------------------+---------------+-------------------+-----------------+ + | a := baaa |a := baaa | a : = baaa | a := baaa | + | caaaa := deeee |caaaa := deeee | caaaa : = deeee| caaaa := deeee| + | ee := f |ee := f | ee : = f | ee := f | + +------------------+---------------+-------------------+-----------------+ +< + The original has at least one leading white space on every line. + Using Align with w eliminated each line's leading white space. + Using Align with W preserved each line's leading white space. + Using Align with I applied the first line's leading white space + (three spaces) to each line. + + + ------ *alignctrl-l* + lrc-+: FIELD JUSTIFICATION *alignctrl-r* + ------ *alignctrl-c* + + With "lrc", the fields will be left-justified, right-justified, or + centered as indicated by the justification specifiers (lrc). The + "lrc" options are re-used by cycling through them as needed: + + l means llllll.... + r means rrrrrr.... + lr means lrlrlr.... + llr means llrllr.... + + Example: Justification options: Align = > + +------------+-------------------+-------------------+-------------------+ + | Original | AlignCtrl l | AlignCtrl r | AlignCtrl lr | + +------------+-------------------+-------------------+-------------------+ + | a=bb=ccc=1 |a = bb = ccc = 1| a = bb = ccc = 1|a = bb = ccc = 1| + | ccc=a=bb=2 |ccc = a = bb = 2|ccc = a = bb = 2|ccc = a = bb = 2| + | dd=eee=f=3 |dd = eee = f = 3| dd = eee = f = 3|dd = eee = f = 3| + +------------+-------------------+-------------------+-------------------+ + | Alignment |l l l l| r r r r|l r l r| + +------------+-------------------+-------------------+-------------------+ +< + AlignCtrl l : The = separator is repeatedly re-used, as the + cycle only consists of one character (the "l"). + Every time left-justification is used for fields. + AlignCtrl r : The = separator is repeatedly re-used, as the + cycle only consists of one character (the "l"). + Every time right-justification is used for fields + AlignCtrl lr: Again, the "=" separator is repeatedly re-used, + but the fields are justified alternately between + left and right. + + Even more separator control is available. With "-+:": + + - : skip treating the separator as a separator. *alignctrl--* + + : repeat use of the last "lrc" justification *alignctrl-+* + : : treat the rest of the line as a single field *alignctrl-:* + + Example: More justification options: Align = > + +------------+---------------+--------------------+---------------+ + | Original | AlignCtrl -l | AlignCtrl rl+ | AlignCtrl l: | + +------------+---------------+--------------------+---------------+ + | a=bb=ccc=1 |a=bb = ccc=1 | a = bb = ccc = 1 |a = bb=ccc=1 | + | ccc=a=bb=2 |ccc=a = bb=2 |ccc = a = bb = 2 |ccc = a=bb=2 | + | dd=eee=f=3 |dd=eee = f=3 | dd = eee = f = 3 |dd = eee=f=3 | + +------------+---------------+--------------------+---------------+ + | Alignment |l l | r l l l |l l | + +------------+---------------+--------------------+---------------+ +< + In the first example in "More justification options": + + The first "=" separator is skipped by the "-" specification, + and so "a=bb", "ccc=a", and "dd=eee" are considered as single fields. + + The next "=" separator has its (left side) field left-justified. + Due to the cyclic nature of separator patterns, the "-l" + specification is equivalent to "-l-l-l ...". + + Hence the next specification is a "skip", so "ccc=1", etc are fields. + + In the second example in "More justification options": + + The first field is right-justified, the second field is left + justified, and all remaining fields repeat the last justification + command (ie. they are left justified, too). + + Hence rl+ is equivalent to rlllllllll ... + (whereas plain rl is equivalent to rlrlrlrlrl ... ). + + In the third example in "More justification options": + + The text following the first separator is treated as a single field. + + Thus using the - and : operators one can apply justification to a + single separator. + + ex. 1st separator only: AlignCtrl l: + 2nd separator only: AlignCtrl -l: + 3rd separator only: AlignCtrl --l: + etc. + + + --- *alignctrl-=* + =C CYCLIC VS ALL-ACTIVE SEPARATORS *alignctrl-C* + --- + + The separators themselves may be considered as equivalent and + simultaneously active ("=") or sequentially cycled through ("C"). + Separators are regular expressions (|regexp|) and are specified as the + second, third, etc arguments. When the separator patterns are + equivalent and simultaneously active, there will be one pattern + constructed: > + + AlignCtrl ... pat1 pat2 pat3 + \(pat1\|pat2\|pat3\) +< + Each separator pattern is thus equivalent and simultaneously active. + The cyclic separator AlignCtrl option stores a list of patterns, only + one of which is active for each field at a time. + + Example: Equivalent/Simultaneously-Active vs Cyclic Separators > + +-------------+------------------+---------------------+----------------------+ + | Original | AlignCtrl = = + -| AlignCtrl = = | AlignCtrl C = + - | + +-------------+------------------+---------------------+----------------------+ + |a = b + c - d|a = b + c - d |a = b + c - d |a = b + c - d | + |x = y = z + 2|x = y = z + 2 |x = y = z + 2|x = y = z + 2 | + |w = s - t = 0|w = s - t = 0 |w = s - t = 0 |w = s - t = 0 | + +-------------+------------------+---------------------+----------------------+ +< + The original is initially aligned with all operators (=+-) being + considered as equivalent and simultaneously active field separators. + Thus the "AlignCtrl = = + -" example shows no change. + + The second example only accepts the '=' as a field separator; + consequently "b + c - d" is now a single field. + + The third example illustrates cyclic field separators and is analyzed + in the following illustration: > + + field1 separator field2 separator field3 separator field4 + a = b + c - d + x = y = z + 2 + w = s - t = 0 +< + The word "cyclic" is used because the patterns form a cycle of use; in + the above case, its = + - = + - = + - = + -... + + Example: Cyclic separators > + Label : this is some text discussing ":"s | ex. abc:def:ghi + Label : this is some text with a ":" in it | ex. abc:def +< + apply AlignCtrl lWC : | | + (select lines)Align > + Label : this is some text discussing ":"s | ex. abc:def:ghi + Label : this is some text with a ":" in it | ex. abcd:efg +< + In the current example, + : is the first separator So the first ":"s are aligned + | is the second separator but subsequent ":"s are not. + | is the third separator The "|"s are aligned, too. + : is the fourth separator Since there aren't two bars, + | is the fifth separator the subsequent potential cycles + | is the sixth separator don't appear. + ... + + In this case it would probably have been a better idea to have used > + AlignCtrl WCl: : | +< as that alignment control would guarantee that no more cycling + would be used after the vertical bar. + + Example: Cyclic separators + + Original: > + a| b&c | (d|e) & f-g-h + aa| bb&cc | (dd|ee) & ff-gg-hh + aaa| bbb&ccc | (ddd|eee) & fff-ggg-hhh +< + AlignCtrl C | | & - > + a | b&c | (d|e) & f - g-h + aa | bb&cc | (dd|ee) & ff - gg-hh + aaa | bbb&ccc | (ddd|eee) & fff - ggg-hhh +< + In this example, + the first and second separators are "|", + the third separator is "&", and + the fourth separator is "-", + + (cycling) + the fifth and sixth separators are "|", + the seventh separator is "&", and + the eighth separator is "-", etc. + + Thus the first "&"s are (not yet) separators, and hence are treated as + part of the field. Ignoring white space for the moment, the AlignCtrl + shown here means that Align will work with > + + field | field | field & field - field | field | field & field - ... +< + + --- *alignctrl-<* + <>| SEPARATOR JUSTIFICATION *alignctrl->* + --- *alignctrl-|* + + Separators may be of differing lengths as shown in the example below. + Hence they too may be justified left, right, or centered. + Furthermore, separator justification specification is cyclic: + + < means <<<<<... justify separator(s) to the left + > means >>>>>... justify separator(s) to the right + | means |||||... center separator(s) + + Example: Separator Justification: Align -\+ > + +-----------------+ + | Original | + +-----------------+ + | a - bbb - c | + | aa -- bb -- ccc | + | aaa --- b --- cc| + +---------------------+-+-----------------+-+---------------------+ + | AlignCtrl < | AlignCtrl > | AlignCtrl | | + +---------------------+---------------------+---------------------+ + | a - bbb - c | a - bbb - c | a - bbb - c | + | aa -- bb -- ccc | aa -- bb -- ccc | aa -- bb -- ccc | + | aaa --- b --- cc | aaa --- b --- cc | aaa --- b --- cc | + +---------------------+---------------------+---------------------+ +< + + --- *alignctrl-g* + gv SELECTIVE APPLICATION *alignctrl-v* + --- + + + These two options provide a way to select (g) or to deselect (v) lines + based on a pattern. Ideally :g/pat/Align would work; unfortunately + it results in Align() being called on each line satisfying the pattern + separately. > + + AlignCtrl g pattern +< + Align will only consider those lines which have the given pattern. > + + AlignCtrl v pattern +< + Align will only consider those lines without the given pattern. As an + example of use, consider the following example: > + + :AlignCtrl v ^\s*/\* + Original :Align = :Align = + +----------------+------------------+----------------+ + |one= 2; |one = 2; |one = 2; | + |three= 4; |three = 4; |three = 4; | + |/* skip=this */ |/* skip = this */ |/* skip=this */ | + |five= 6; |five = 6; |five = 6; | + +----------------+------------------+----------------+ +< + The first "Align =" aligned with all "="s, including that one in the + "skip=this" comment. + + The second "Align =" had a AlignCtrl v-pattern which caused it to skip + (ignore) the "skip=this" line when aligning. + + To remove AlignCtrl's g and v patterns, use (as appropriate) > + + AlignCtrl g + AlignCtrl v +< + To see what g/v patterns are currently active, just use the reporting + capability of a plain AlignCtrl call: > + + AlignCtrl +< + + --- + m MAP SUPPORT *alignctrl-m* + --- + + This option primarily supports the development of maps. The AlignCtrl + call will first do an AlignPush() (ie. retain current alignment + control settings). The next Align() will, in addition to its + alignment job, finish up with an AlignPop(). Thus the AlignCtrl + settings that follow the "m" are only temporarily in effect for just + the next Align(). + + + --- + p### *alignctrl-p* + P### PADDING *alignctrl-P* + --- + + These two options control pre-padding and post-padding with blanks + about the separator. One may pad separators with zero to nine spaces; + the padding number(s) is/are treated as a cyclic parameter. Thus one + may specify padding separately for each field or re-use a padding + pattern. > + + Example: AlignCtrl p102P0 + +---------+----------------------------------+ + | Original| a=b=c=d=e=f=g=h=1 | + | Align = | a =b=c =d =e=f =g =h=1 | + +---------+----------------------------------+ + | prepad | 1 0 2 1 0 2 1 0 | + +---------+----------------------------------+ +< + This example will cause Align to: + + pre-pad the first "=" with a single blank, + pre-pad the second "=" with no blanks, + pre-pad the third "=" with two blanks, + pre-pad the fourth "=" with a single blank, + pre-pad the fifth "=" with no blanks, + pre-pad the sixth "=" with two blanks, + etc. + + --------------- *alignctrl-settings* + No option given DISPLAY STATUS *alignctrl-* + --------------- *alignctrl-no-option* + + AlignCtrl, when called with no arguments, will display the current + alignment control settings. A typical display is shown below: > + + AlignCtrl<=> qty=1 AlignStyle Padding<1|1> + Pat1<\(=\)> +< + Interpreting, this means that the separator patterns are all + equivalent; in this case, there's only one (qty=1). Fields will be + padded on the right with spaces (left justification), and separators + will be padded on each side with a single space. + + One may get a string which can be fed back into AlignCtrl: > + + :let alignctrl= AlignCtrl() +< + This form will put a string describing the current AlignCtrl options, + except for the "g" and "v" patterns, into a variable. The AlignCtrl() + function will still echo its settings, however. One can feed any + non-supported "option" to AlignCtrl() to prevent this, however: > + + :let alignctrl= AlignCtrl("d") +< + +ALIGNMENT *align-align* + + Once the alignment control has been determined, the user specifies a + range of lines for the Align command/function to do its thing. + Alignment is often done on a line-range basis, but one may also + restrict alignment to a visual block using ctrl-v. For any visual + mode, one types the colon (:) and then "Align". One may, of course, + specify a range of lines: > + + :[range]Align [list-of-separators] +< + where the |range| is the usual Vim-powered set of possibilities; the + list of separators is the same as the AlignCtrl capability. There is + only one list of separators, but either AlignCtrl or Align can be used + to specify that list. + + An alternative form of the Align command can handle both alignment + control and the separator list: > + + :[range]Align! [alignment-control-string] [list-of-separators] +< + The alignment control string will be applied only for this particular + application of Align (it uses |alignctrl-m|). The "g pattern" and + "v pattern" alignment controls (see |alignctrl-g| and |alignctrl-v|) + are also available via this form of the Align command. + + Align makes two passes over the text to be aligned. The first pass + determines how many fields there are and determines the maximum sizes + of each field; these sizes are then stored in a vector. The second + pass pads the field (left/right/centered as specified) to bring its + length up to the maximum size of the field. Then the separator and + its AlignCtrl-specified padding is appended. + + Pseudo-Code:~ + During pass 1 + | For all fields in the current line + || Determine current separator + || Examine field specified by current separator + || Determine length of field and save if largest thus far + Initialize newline based on initial whitespace option (wWI) + During pass 2 + | For all fields in current line + || Determine current separator + || Extract field specified by current separator + || Prepend/append padding as specified by AlignCtrl + || (right/left/center)-justify to fit field into max-size field + || Append separator with AlignCtrl-specified separator padding + || Delete current line, install newly aligned line + + The g and v AlignCtrl patterns cause the passes not to consider lines + for alignment, either by requiring that the g-pattern be present or + that the v-pattern not be present. + + The whitespace on either side of a separator is ignored. + + +ALIGNMENT MAPS *alignmaps* *align-maps* + + There are a number of maps using AlignCtrl() and Align() in the + file. This file may also be put into the plugins + subdirectory. Since AlignCtrl and Align supercede textab and its + file, the maps either have a leading "t" (for "textab") + or the more complicated ones an "a" (for "alignment") for backwards + compatibility. + + \a, : useful for breaking up comma-separated + declarations prior to \adec |alignmap-a,| + \a? : aligns (...)? ...:... expressions on ? and : |alignmap-a?| + \a< : aligns << and >> for c++ |alignmap-a<| + \a= : aligns := assignments |alignmap-a=| + \abox : draw a C-style comment box around text lines |alignmap-abox| + \acom : useful for aligning comments |alignmap-acom| + \adcom: useful for aligning comments in declarations |alignmap-adcom| + \anum : useful for aligning numbers |alignmap-anum| + NOTE: For the visual-mode use of \anum, is needed! + See http://mysite.verizon.net/astronaut/vim/index.html#VIS + \aenum: align a European-style number |alignmap-anum| + \aunum: align a USA-style number |alignmap-anum| + \adec : useful for aligning declarations |alignmap-adec| + \adef : useful for aligning definitions |alignmap-adef| + \afnc : useful for aligning ansi-c style functions' + argument lists |alignmap-afnc| + \adcom: a variant of \acom, restricted to comment |alignmap-adcom| + containing lines only, but also only for + those which don't begin with a comment. + Good for certain declaration styles. + \aocom: a variant of \acom, restricted to comment |alignmap-aocom| + containing lines only + \tab : align a table based on tabs *alignmap-tab* + (converts to spaces) + \tml : useful for aligning the trailing backslashes |alignmap-tml| + used to continue lines (shell programming, etc) + \tsp : use Align to make a table separated by blanks |alignmap-tsp| + (left justified) + \ts, : like \t, but swaps whitespace on the right of *alignmap-ts,* + the commas to their left + \Tsp : use Align to make a table separated by blanks |alignmap-Tsp| + (right justified) + \tsq : use Align to make a table separated by blanks |alignmap-tsq| + (left justified) -- "strings" are not split up + \tt : useful for aligning LaTeX tabular tables |alignmap-tt| + \Htd : tabularizes html tables: |alignmap-Htd| + ...field... ...field... + + *alignmap-t|* *alignmap-t#* *alignmap-t,* *alignmap-t:* + *alignmap-t;* *alignmap-t<* *alignmap-t?* *alignmap-t~* + *alignmap-m=* + \tx : make a left-justified alignment on + character "x" where "x" is: ,:<=@|# |alignmap-t=| + \Tx : make a right-justified alignment on + character "x" where "x" is: ,:<=@# |alignmap-T=| + \m= : like \t= but aligns with %... style comments + + The leading backslash is actually (see |mapleader| for how to + customize the leader to be whatever you like). These maps use the + package and are defined in the file. + Although the maps use AlignCtrl options, they typically use the "m" + option which pushes the options (AlignPush). The associated Align + call which follows will then AlignPop the user's original options + back. + + ALIGNMENT MAP USE WITH MARK AND MOVE~ + In the examples below, one may select the text with a "ma" at the + first line, move to the last line, then execute the map. + + ALIGNMENT MAP USE WITH VISUAL MODE~ + Alternatively, one may select the text with the "V" visual mode + selector. + + ALIGNMENT MAP USE WITH MENUS~ + One may use the mark-and-move style (ma, move, use the menu) or + the visual mode style (use the V visual mode, move, then select + the alignment map with menu selection). The alignment map menu + items are under DrChip.AlignMaps . + + One may change the top level menu name to whatever is wished; by + default, its > + let g:DrChipTopLvlMenu= "DrChip." +< If you set the variable to the empty string (""), then no menu items + will be produced. Of course, one must have a vim with +menu, the gui + must be running, and *'go'* must have the menu bar suboption (ie. m + must be included). + + COMPLEX ALIGNMENT MAP METHOD~ + For those complex alignment maps which do alignment on constructs + (e.g. \acom, \adec, etc), a series of substitutes is used to insert + "@" symbols in appropriate locations. Align() is then used to do + alignment directly on "@"s; then it is followed by further substitutes + to do clean-up. However, the maps \WS and \WE protect any original + embedded "@" symbols by first converting them to characters, + doing the requested job, and then converting them back. + + + --------------------------- + Alignment Map Examples: \a, *alignmap-a,* + --------------------------- + + Original: illustrates comma-separated declaration splitting: > + int a,b,c; + struct ABC_str abc,def; +< + Becomes: > + int a; + int b; + int c; + struct ABC_str abc; + struct ABC_str def; +< + + --------------------------- + Alignment Map Examples: \a? *alignmap-a?* + --------------------------- + + Original: illustrates ()?: aligning > + printf("<%s>\n", + (x == ABC)? "abc" : + (x == DEFG)? "defg" : + (x == HIJKL)? "hijkl" : "???"); +< + Becomes: select "(x == ..." lines, then \a? > + printf("<%s>\n", + (x == ABC)? "abc" : + (x == DEFG)? "defg" : + (x == HIJKL)? "hijkl" : "???"); +< + + --------------------------- + Alignment Map Examples: \a< *alignmap-a<* + --------------------------- + + Original: illustrating aligning of << and >> > + cin << x; + cin << y; + cout << "this is x=" << x; + cout << "but y=" << y << "is not"; +< + Becomes: select "(x == ..." lines, then \a< > + cin << x; + cin << y; + cout << "this is x=" << x; + cout << "but y=" << y << "is not"; +< + + --------------------------- + Alignment Map Examples: \a= *alignmap-a=* + --------------------------- + + Original: illustrates how to align := assignments > + aa:=bb:=cc:=1; + a:=b:=c:=1; + aaa:=bbb:=ccc:=1; +< + Bcomes: select the three assignment lines, then \a:= > + aa := bb := cc := 1; + a := b := c := 1; + aaa := bbb := ccc := 1; +< + + --------------------------- + Alignment Map Examples: \abox *alignmap-abox* + --------------------------- + + Original: illustrates how to comment-box some text > + This is some plain text + which will + soon be surrounded by a + comment box. +< + Becomes: Select "This..box." with ctrl-v, press \abox > + /*************************** + * This is some plain text * + * which will * + * soon be surrounded by a * + * comment box. * + ***************************/ +< + + --------------------------- + Alignment Map Examples: \acom *alignmap-acom* + --------------------------- + + Original: illustrates aligning C-style comments (works for //, too) > + if(itworks) { /* this */ + then= dothis; /* is a */ + } /* set of three comments */ +< + Becomes: Select the three lines, press \acom > + if(itworks) { /* this */ + then= dothis; /* is a */ + } /* set of three comments */ +< + Also see |alignmap-aocom| + + + --------------------------- + Alignment Map Examples: \anum *alignmap-anum* + --------------------------- + + Original: illustrates how to get numbers lined up > + -1.234 .5678 -.901e-4 + 1.234 5.678 9.01e-4 + 12.34 56.78 90.1e-4 + 123.4 567.8 901.e-4 +< + Becomes: Go to first line, ma. Go to last line, press \anum > + -1.234 .5678 -.901e-4 + 1.234 5.678 9.01e-4 + 12.34 56.78 90.1e-4 + 123.4 567.8 901.e-4 +< + Original: > + | -1.234 .5678 -.901e-4 | + | 1.234 5.678 9.01e-4 | + | 12.34 56.78 90.1e-4 | + | 123.4 567.8 901.e-4 | +< + Becomes: Select the numbers with ctrl-v (visual-block mode), > + press \anum + | -1.234 .5678 -.901e-4 | + | 1.234 5.678 9.01e-4 | + | 12.34 56.78 90.1e-4 | + | 123.4 567.8 901.e-4 | +< + Original: > + -1,234 ,5678 -,901e-4 + 1,234 5,678 9,01e-4 + 12,34 56,78 90,1e-4 + 123,4 567,8 901,e-4 +< + Becomes: Go to first line, ma. Go to last line, press \anum > + -1,234 ,5678 -,901e-4 + 1,234 5,678 9,01e-4 + 12,34 56,78 90,1e-4 + 123,4 567,8 901,e-4 +< + In addition: + \aenum is provided to support European-style numbers + \aunum is provided to support USA-style numbers + + One may get \aenum behavior for \anum > + let g:alignmaps_euronumber= 1 +< or \aunum behavior for \anum if one puts > + let g:alignmaps_usanumber= 1 +< in one's <.vimrc>. + + + --------------------------- + Alignment Map Examples: \ascom *alignmap-ascom* + --------------------------- + + Original: > + /* A Title */ + int x; /* this is a comment */ + int yzw; /* this is another comment*/ +< + Becomes: Select the three lines, press \ascom > + /* A Title */ + int x; /* this is a comment */ + int yzw; /* this is another comment */ +< + + --------------------------- + Alignment Map Examples: \adec *alignmap-adec* + --------------------------- + + Original: illustrates how to clean up C/C++ declarations > + int a; + float b; + double *c=NULL; + char x[5]; + struct abc_str abc; + struct abc_str *pabc; + int a; /* a */ + float b; /* b */ + double *c=NULL; /* b */ + char x[5]; /* x[5] */ + struct abc_str abc; /* abc */ + struct abc_str *pabc; /* pabc */ + static int a; /* a */ + static float b; /* b */ + static double *c=NULL; /* b */ + static char x[5]; /* x[5] */ + static struct abc_str abc; /* abc */ + static struct abc_str *pabc; /* pabc */ +< + Becomes: Select the declarations text, then \adec > + int a; + float b; + double *c = NULL; + char x[5]; + struct abc_str abc; + struct abc_str *pabc; + int a; /* a */ + float b; /* b */ + double *c = NULL; /* b */ + char x[5]; /* x[5] */ + struct abc_str abc; /* abc */ + struct abc_str *pabc; /* pabc */ + static int a; /* a */ + static float b; /* b */ + static double *c = NULL; /* b */ + static char x[5]; /* x[5] */ + static struct abc_str abc; /* abc */ + static struct abc_str *pabc; /* pabc */ +< + + --------------------------- + Alignment Map Examples: \adef *alignmap-adef* + --------------------------- + + Original: illustrates how to line up #def'initions > + #define ONE 1 + #define TWO 22 + #define THREE 333 + #define FOUR 4444 +< + Becomes: Select four definition lines, apply \adef > + # define ONE 1 + # define TWO 22 + # define THREE 333 + # define FOUR 4444 +< + + --------------------------- + Alignment Map Examples: \afnc *alignmap-afnc* + --------------------------- + + This map is an exception to the usual selection rules. + It uses "]]" to find the function body's leading "{". + Just put the cursor anywhere in the function arguments and + the entire function declaration should be processed. + + Because "]]" looks for that "{" in the first column, the + "original" and "becomes" examples are in the first column, + too. + + Original: illustrates lining up ansi-c style function definitions > + int f( + struct abc_str ***a, /* one */ + long *b, /* two */ + int c) /* three */ + { + } +< + Becomes: put cursor anywhere before the '{', press \afnc > + int f( + struct abc_str ***a, /* one */ + long *b, /* two */ + int c) /* three */ + { + } +< + + --------------------------- + Alignment Map Examples: \adcom *alignmap-adcom* + --------------------------- + + Original: illustrates aligning comments that don't begin + lines (optionally after some whitespace). > + struct { + /* this is a test */ + int x; /* of how */ + double y; /* to use adcom */ + }; +< + Becomes: Select the inside lines of the structure, + then press \adcom. The comment-only + line is ignored but the other two comments + get aligned. > + struct { + /* this is a test */ + int x; /* of how */ + double y; /* to use adcom */ + }; +< + + --------------------------- + Alignment Map Examples: \aocom *alignmap-aocom* + --------------------------- + + Original: illustrates how to align C-style comments (works for //, too) + but restricted only to aligning with those lines containing + comments. See the difference from \acom (|alignmap-acom|). > + if(itworks) { /* this comment */ + then= dothis; + } /* only appears on two lines */ +< + Becomes: Select the three lines, press \aocom > + if(itworks) { /* this comment */ + then= dothis; + } /* only appears on two lines */ +< + Also see |alignmap-acom| + + + --------------------------- + Alignment Map Examples: \tsp *alignmap-tsp* + --------------------------- + + Normally Align can't use white spaces for field separators as such + characters are ignored surrounding field separators. The \tsp and + \Tsp maps get around this limitation. + + Original: > + one two three four five + six seven eight nine ten + eleven twelve thirteen fourteen fifteen +< + Becomes: Select the lines, \tsp > + one two three four five + six seven eight nine ten + eleven twelve thirteen fourteen fifteen +< + Becomes: Select the lines, \Tsp > + one two three four five + six seven eight nine ten + eleven twelve thirteen fourteen fifteen +< + + --------------------------- + Alignment Map Examples: \tsq *alignmap-tsq* + --------------------------- + + The \tsp map is useful for aligning tables based on white space, + but sometimes one wants double-quoted strings to act as a single + object in spite of embedded spaces. The \tsq map was invented + to support this. (thanks to Leif Wickland) + + Original: > + "one two" three + four "five six" +< + Becomes: Select the lines, \tsq > + "one two" three + four "five six" +< + + --------------------------- + Alignment Map Examples: \tt *alignmap-tt* + --------------------------- + + Original: illustrates aligning a LaTex Table > + \begin{tabular}{||c|l|r||} + \hline\hline + one&two&three\\ \hline + four&five&six\\ + seven&eight&nine\\ + \hline\hline + \end{tabular} +< + Becomes: Select the three lines inside the table > + (ie. one..,four..,seven..) and press \tt + \begin{tabular}{||c|l|r||} + \hline\hline + one & two & three \\ \hline + four & five & six \\ + seven & eight & nine \\ + \hline\hline + \end{tabular} +< + + ---------------------------- + Alignment Map Examples: \tml *alignmap-tml* + ---------------------------- + + Original: illustrates aligning multi-line continuation marks > + one \ + two three \ + four five six \ + seven \\ \ + eight \nine \ + ten \ +< + Becomes: > + one \ + two three \ + four five six \ + seven \\ \ + eight \nine \ + ten \ +< + + --------------------------- + Alignment Map Examples: \t= *alignmap-t=* + --------------------------- + + Original: illustrates left-justified aligning of = > + aa=bb=cc=1;/*one*/ + a=b=c=1;/*two*/ + aaa=bbb=ccc=1;/*three*/ +< + Becomes: Select the three equations, press \t= > + aa = bb = cc = 1; /* one */ + a = b = c = 1; /* two */ + aaa = bbb = ccc = 1; /* three */ +< + + --------------------------- + Alignment Map Examples: \T= *alignmap-T=* + --------------------------- + + Original: illustrates right-justified aligning of = > + aa=bb=cc=1; /* one */ + a=b=c=1; /* two */ + aaa=bbb=ccc=1; /* three */ +< + Becomes: Select the three equations, press \T= > + aa = bb = cc = 1; /* one */ + a = b = c = 1; /* two */ + aaa = bbb = ccc = 1; /* three */ +< + + --------------------------- + Alignment Map Examples: \Htd *alignmap-Htd* + --------------------------- + + Original: for aligning tables with html > + ...field one......field two... + ...field three......field four... +< + Becomes: Select ... lines, press \Htd > + ...field one... ...field two... + ...field three... ...field four... +< +============================================================================== +4. Alignment Tool History *align-history* {{{1 + +ALIGN HISTORY {{{2 + 33 : Sep 20, 2007 * s:Strlen() introduced to support various ways + used to represent characters and their effects + on string lengths. See |align-strlen|. + * Align now accepts "..." -- so it can accept + whitespace as separators. + 32 : Aug 18, 2007 * uses || instead of || plus a + custom argument splitter to allow patterns with + backslashes to slide in unaltered. + 31 : Aug 06, 2007 * :[range]Align! [AlignCtrl settings] pattern(s) + implemented. + 30 : Feb 12, 2007 * now uses |setline()| + 29 : Jan 18, 2006 * cecutil updated to use keepjumps + Feb 23, 2006 * Align now converted to vim 7.0 style using + auto-loading functions. + 28 : Aug 17, 2005 * report option workaround + Oct 24, 2005 * AlignCtrl l: wasn't behaving as expected; fixed + 27 : Apr 15, 2005 : cpo workaround + ignorecase workaround + 26 : Aug 20, 2004 : loaded_align now also indicates version number + GetLatestVimScripts :AutoInstall: now supported + 25 : Jul 27, 2004 : For debugging, uses Dfunc(), Dret(), and Decho() + 24 : Mar 03, 2004 : (should've done this earlier!) visualmode(1) + not supported until v6.2, now Align will avoid + calling it for earlier versions. Visualmode + clearing won't take place then, of course. + 23 : Oct 07, 2003 : Included Leif Wickland's ReplaceQuotedSpaces() + function which supports \tsq + 22 : Jan 29, 2003 : Now requires 6.1.308 or later to clear visualmode() + 21 : Jan 10, 2003 : BugFix: similar problem to #19; new code + bypasses "norm! v\" until initialization + is over. + 20 : Dec 30, 2002 : BugFix: more on "unable to highlight" fixed + 19 : Nov 21, 2002 : BugFix: some terminals gave an "unable to highlight" + message at startup; Hari Krishna Dara tracked it + down; a silent! now included to prevent noise. + 18 : Nov 04, 2002 : BugFix: re-enabled anti-repeated-loading + 17 : Nov 04, 2002 : BugFix: forgot to have AlignPush() push s:AlignSep + AlignCtrl now clears visual-block mode when used so + that Align won't try to use old visual-block + selection marks '< '> + 16 : Sep 18, 2002 : AlignCtrl <>| options implemented (separator + justification) + 15 : Aug 22, 2002 : bug fix: AlignCtrl's ":" now acts as a modifier of + the preceding alignment operator (lrc) + 14 : Aug 20, 2002 : bug fix: AlignCtrl default now keeps &ic unchanged + bug fix: Align, on end-field, wasn't using correct + alignop bug fix: Align, on end-field, was appending + padding + 13 : Aug 19, 2002 : bug fix: zero-length g/v patterns are accepted + bug fix: always skip blank lines + bug fix: AlignCtrl default now also clears g and v + patterns + 12 : Aug 16, 2002 : moved keep_ic above zero-length pattern checks + added "AlignCtrl default" + fixed bug with last field getting separator spaces + at end line + 11 : Jul 08, 2002 : prevent separator patterns which match zero length + -+: included as additional alignment/justification + styles + 10 : Jun 26, 2002 : =~# used instead of =~ (for matching case) + ignorecase option handled + 9 : Jun 25, 2002 : implemented cyclic padding + +ALIGNMENT MAP HISTORY *alignmap-history* {{{2 + v39 Mar 06, 2008 : * \t= only does /* ... */ aligning when in *.c + *.cpp files. + v38 Aug 18, 2007 : * \tt altered so that it works with the new + use of || plus a custom argument + splitter + v36 Sep 27, 2006 : * AlignWrapperStart() now has tests that marks + y and z are not set + May 15, 2007 * \anum and variants improved + v35 Sep 01, 2006 : * \t= and cousins used "`"s. They now use \xff + characters. + * \acom now works with doxygen style /// comments + * used in \t= \T= \w= and \m= instead + of backquotes. + v34 Feb 23, 2006 : * AlignMaps now converted to vim 7.0 style using + auto-loading functions. + v33 Oct 12, 2005 : * \ts, now uses P1 in its AlignCtrl call + v32 Jun 28, 2005 : * s:WrapperStart() changed to AlignWrapperStart() + s:WrapperEnd() changed to AlignWrapperEnd() + These changes let the AlignWrapper...()s to be + used outside of AlignMaps.vim + v31 Feb 01, 2005 : * \adcom included, with help + * \a, now works across multiple lines with + different types + * AlignMaps now uses for its mark and + window-position saving and restoration + Mar 04, 2005 * improved \a, + Apr 06, 2005 * included \aenum, \aunum, and provided + g:alignmaps_{usa|euro]number} options + v30 Aug 20, 2004 : * \a, : handles embedded assignments and does \adec + * \acom now can handle Doxygen-style comments + * g:loaded_alignmaps now also indicates version + * internal maps \WE and \WS are now re-entrant + v29 Jul 27, 2004 : * \tml aligns trailing multi-line single + backslashes (thanks to Raul Benavente!) + v28 May 13, 2004 : * \a, had problems with leading blanks; fixed! + v27 Mar 31, 2004 : * \T= was having problems with == and != + * Fixed more problems with \adec + v26 Dec 09, 2003 : * \ascom now also ignores lines without comments + * \tt \& now not matched + * \a< handles both << and >> + v25 Nov 14, 2003 : * included \anum (aligns numbers with periods and + commas). \anum also supported with ctrl-v mode. + * \ts, \Ts, : (aligns on commas, then swaps leading + spaces with commas) + * \adec ignores preprocessor lines and lines with + with comments-only + v23 Sep 10, 2003 : * Bugfix for \afnc - no longer overwrites marks y,z + * fixed bug in \tsp, \tab, \Tsp, and \Tab - lines + containing backslashes were having their + backslashes removed. Included Leif Wickland's + patch for \tsq. + * \adef now ignores lines holding comments only + v18 Aug 22, 2003 : \a< lines up C++'s << operators + saves/restores gdefault option (sets to nogd) + all b:..varname.. are now b:alignmaps_..varname.. + v17 Nov 04, 2002 : \afnc now handles // comments correctly and + commas within comments + v16 Sep 10, 2002 : changed : to :silent! for \adec + v15 Aug 27, 2002 : removed some s + v14 Aug 20, 2002 : \WS, \WE mostly moved to functions, marks y and z + now restored + v11 Jul 08, 2002 : \abox bug fix + v9 Jun 25, 2002 : \abox now handles leading initial whitespace + : various bugfixes to \afnc, \T=, etc + +============================================================================== +Modelines: {{{1 +vim:tw=78:ts=8:ft=help:fdm=marker: diff --git a/vimfiles/doc/SrchRplcHiGrp.txt b/vimfiles/doc/SrchRplcHiGrp.txt new file mode 100644 index 0000000..979bf8b --- /dev/null +++ b/vimfiles/doc/SrchRplcHiGrp.txt @@ -0,0 +1,199 @@ +*SrchRplcHiGrp.txt* Search and Replace Restricted to a Highlighting Group + +Author: David Fishburn January 22, 2008 + + +============================================================================== +1. Contents *srchrplchigrp* *srchrplchigrp-contents* + + 1. Contents......................: |srchrplchigrp-contents| + 2. Commands......................: |srchrplchigrp-commands| + SR............................: |SR| + SRDispHiGrp...................: |SRDispHiGrp| + SRChooseHiGrp.................: |SRChooseHiGrp| + SRHiGrp.......................: |SRHiGrp| + 3. Examples......................: |srchrplchigrp-examples| + + +============================================================================== +2. Commands *srchrplchigrp-commands* + + SR = Search and Replace *SR* + + SRDispHiGrp *SRDispHiGrp* + Displays the syntax id and name the of the syntax group + which has been chosen. + + SRChooseHiGrp[!] *SRChooseHiGrp* + Before you can run the search and replace command (:SRHiGrp), + you must choose which syntax group id you want to operate on. + The top level syntax id of the current cursor position is + chosen (ie. the top-level one versus the final one). + + The optional bang lets SRChooseHiGrp use the translated + syntax ID. This is final one versus the top-level one. + + Assuming we were using a SQL file and placed the cursor on the + FROM word, then using the SyntaxAttr plugin + (http://vim.sourceforge.net/script.php?script_id=383) + it displays both the top-level and translated + (or final) highlight group as follows: > + group: sqlKeyword->Statement guifg=#ffff00(#ffff00) +< + + Examples: > + :SRChooseHiGrp +< Will operate on only sqlKeyword syntax groups +> + :SRChooseHiGrp! +< Will operate on all Statement syntax groups. Based on + |group-name|, the Statement group will highlight the + same color for the following highlight groups: + Conditional + Repeat + Label + Operator + Keyword + Exception + Therefore SRChooseHiGrp! will operate over all of the + above syntax groups. + + SRSearch *SRSearch* + This command will perform a forward search starting at the current + cursor position for a specified highlight group name. The range defaults + to the entire file. It supports all visual modes, characterwise (v), + linewise (V) and blockwise (). + + It optionally takes takes one parameter. You can supply a hightlight + group name: > + :SRSearch Statement +< + The command supports highlight group name completion. > + :SRSearch C +< Depending on which syntax groups are defined (given your filetype and + various plugins) this will cycle through all highlight group names + beginning with the letter 'C'. + + Alternatively, you can use the SRChooseHiGrp or SRChooseHiGrp! + command to select the highlight group. Running SRSearch + without a parameter will check if a valid group name was + selected via SRChooseHiGrp and begin the search. If no valid + group name was specified, an error message will be reported. + + SRHiGrp[!] *SRHiGrp* + This command will perform a search and replace over a visual + range. It works in all visual modes, characterwise (v), + linewise (V) and blockwise (). + + It optionally takes takes 2 parameters. + + Parameter 1 controls what characters are matched. The default + for this value is \(\w\+\>\). This expression is appended to + the \%# which starts the match from the current cursor + position. This expression must specify a submatch \(...\). + + Parameter 2 controls what to do with the matched string. The + default for this value is \U\1. This expression will cause + the matched string to be UPPER cased. The \1 refers to the + submatch from the first parameter. + + If the parameters are not supplied, the user will be prompted + to enter the expression(s). + + The optional bang (!) works the same as SRHiGrp, but will + operate on all syntax groups that are NOT the chosen one + (SRChooseHiGrp). + + Syntax: > + [range]SRHiGrp[!] 'from-pattern','to-string' +< +============================================================================== +3. Examples *srchrplchigrp-examples* + + SRHiGrp + ------- + + First place your cursor on an item that is syntax colored the way + you want: +> + :SRChooseHiGrp +< + Next, visually select a block of text + (all visual modes are supported) +> + :SRHiGrp + or + :SRHiGrp '\(\w\+\>\)' + or + :SRHiGrp '\(\w\+\>\)', '\U\1' +< + If you had the following in a SQL file: +> + if exists( select 1 + from sys.sysprocedure sp + key join sys.sysuserperm sup + where sp.proc_name = 'sp_http_course_detail' + and sup.user_name = user_name() ) then + drop procedure sp_http_course_detail; + end if; +< + Where the keywords (if, exists, select, from ...) are all + highlighted yellow (based on my colorscheme). After I visually + select the area and run the command taking default prompts: +> + :'<,'>SRHiGrp +< + The result is: +> + IF EXISTS( SELECT 1 + FROM sys.sysprocedure sp + KEY JOIN sys.sysuserperm sup + WHERE sp.proc_name = 'sp_http_course_detail' + AND sup.user_name = user_name() ) THEN + DROP PROCEDURE sp_http_course_detail; + END IF; +< + Where the keywords (if, exists, select, from ...) are all + highlighted yellow (based on my colorscheme). After I visually + select the area and run the command taking default prompts: > + + :'<,'>SRHiGrp! +< + The result is: +> + if exists( select 1 + from SYS.SYSPROCEDURE SP + key join SYS.SYSUSERPERM SUP + where SP.PROC_NAME = 'SP_HTTP_COURSE_DETAIL' + and SUP.USER_NAME = USER_NAME() ) then + drop procedure SP_HTTP_COURSE_DETAIL; + end if; +< + + SRSearch + -------- + + SRSearch simply does a forward search for the specified highlight + group. A few examples: > + :SRSearch sqlKeyword + :1,5SRSearch sqlKeyword + :'<,'>SRSearch sqlKeyword +< + Optionally, you can first choose the hightlight group by placing your + cursor on the highlight you want and: > + :SRChooseHiGrp + :SRSearch +< + Using Vim's tab completion you can also: > + :SRSearch s +< + Each time you press tab, it will cycle through the currently defined + syntax highlight groups beginning with the letter 's'. + + The results of the search is displayed in the command line and is + highlighted in the color of the syntax group. This will remind you + which group was searched for. > + SRSearch - Match found - Group ID: 171 Name: sqlKeyword + SRSearch - Match NOT found - Group ID: 171 Name: sqlKeyword +< +vim:tw=78:ts=8:ft=help:norl: diff --git a/vimfiles/doc/pi_getscript.txt b/vimfiles/doc/pi_getscript.txt index e7c0e45..407d9c5 100644 --- a/vimfiles/doc/pi_getscript.txt +++ b/vimfiles/doc/pi_getscript.txt @@ -1,408 +1,414 @@ -*pi_getscript.txt* For Vim version 7.0. Last change: 2006 Nov 1 -> - GETSCRIPT REFERENCE MANUAL by Charles E. Campbell, Jr. -< -Authors: Charles E. Campbell, Jr. - (remove NOSPAM from the email address) - *GetLatestVimScripts-copyright* -Copyright: (c) 2004-2006 by Charles E. Campbell, Jr. *glvs-copyright* - The VIM LICENSE applies to getscript.vim and - pi_getscript.txt (see |copyright|) except use - "getscript" instead of "Vim". No warranty, express or implied. - Use At-Your-Own-Risk. - -Getscript is a plugin that simplifies retrieval of the latest versions of the -scripts that you yourself use! Typing |:GLVS| will invoke getscript; it will -then use the (see |GetLatestVimScripts_dat|) file to -get the latest versions of scripts listed therein from http://vim.sf.net/. - -============================================================================== -1. Contents *glvs-contents* *glvs* *getscript* - *GetLatestVimScripts* - - 1. Contents........................................: |glvs-contents| - 2. GetLatestVimScripts -- Getting Started..........: |glvs-install| - 3. GetLatestVimScripts Usage.......................: |glvs-usage| - 4. GetLatestVimScripts Data File...................: |glvs-data| - 5. GetLatestVimScripts Friendly Plugins............: |glvs-plugins| - 6. GetLatestVimScripts AutoInstall.................: |glvs-autoinstall| - 7. GetLatestViMScripts Options.....................: |glvs-options| - 8. GetLatestVimScripts Algorithm...................: |glvs-alg| - 9. GetLatestVimScripts History.....................: |glvs-hist| - - -============================================================================== -2. GetLatestVimScripts -- Getting Started *getscript-start* - *getlatestvimscripts-install* - - VERSION FROM VIM DISTRIBUTION *glvs-dist-install* - -Vim 7.0 does not include the GetLatestVimScripts.dist file which -serves as an example and a template. So, you'll need to create -your own! See |GetLatestVimScripts_dat|. - - VERSION FROM VIM SF NET *glvs-install* - -NOTE: The last step, that of renaming/moving the GetLatestVimScripts.dist -file, is for those who have just downloaded GetLatestVimScripts.tar.bz2 for -the first time. - -The GetLatestVimScripts.dist file serves as an example and a template for your -own personal list. Feel free to remove all the scripts mentioned within it; -the "important" part of it is the first two lines. - -Your computer needs to have wget for GetLatestVimScripts to do its work. - - 1. if compressed: gunzip getscript.vba.gz - 2. Unix: - vim getscript.vba - :so % - :q - cd ~/.vim/GetLatest - mv GetLatestVimScripts.dist GetLatestVimScripts.dat - (edit GetLatestVimScripts.dat to install your own personal - list of desired plugins -- see |GetLatestVimScripts_dat|) - - 3. Windows: - vim getscript.vba - :so % - :q - cd **path-to-vimfiles**/GetLatest - mv GetLatestVimScripts.dist GetLatestVimScripts.dat - (edit GetLatestVimScripts.dat to install your own personal - list of desired plugins -- see |GetLatestVimScripts_dat|) - - -============================================================================== -3. GetLatestVimScripts Usage *glvs-usage* *:GLVS* - -Unless its been defined elsewhere, > - :GLVS -will invoke GetLatestVimScripts(). If some other plugin has defined that -command, then you may type -> - :GetLatestVimScripts -< -The script will attempt to update and, if permitted, will automatically -install scripts from http://vim.sourceforge.net/. To do so it will peruse a -file, -> - .vim/GetLatest/GetLatestVimScripts.dat (unix) -< -or > - ..wherever..\vimfiles\GetLatest\GetLatestVimScripts.dat (windows) -(see |glvs-data|), and examine plugins in your [.vim|vimfiles]/plugin -directory (see |glvs-plugins|). - -Scripts which have been downloaded will appear in the -~/.vim/GetLatest (unix) or ..wherever..\vimfiles\GetLatest (windows) -subdirectory. GetLatestVimScripts will attempt to automatically -install them if you have the following line in your <.vimrc>: > - - let g:GetLatestVimScripts_allowautoinstall=1 - -The file will be automatically be updated to -reflect the latest version of script(s) so downloaded. -(also see |glvs-options|) - - -============================================================================== -4. GetLatestVimScripts Data File *getscript-data* *glvs-data* - *:GetLatestVimScripts_dat* -The data file must have for its first two lines -the following text: -> - ScriptID SourceID Filename - -------------------------- -< -Following those two lines are three columns; the first two are numeric -followed by a text column. The GetLatest/GetLatestVimScripts.dist file -contains an example of such a data file. Anything following a #... is -ignored, so you may embed comments in the file. - -The first number on each line gives the script's ScriptID. When you're about -to use a web browser to look at scripts on http://vim.sf.net/, just before you -click on the script's link, you'll see a line resembling - - http://vim.sourceforge.net/scripts/script.php?script_id=40 - -The "40" happens to be a ScriptID that GetLatestVimScripts needs to -download the associated page. - -The second number on each line gives the script's SourceID. The SourceID -records the count of uploaded scripts as determined by vim.sf.net; hence it -serves to indicate "when" a script was uploaded. Setting the SourceID to 1 -insures that GetLatestVimScripts will assume that the script it has is -out-of-date. - -The SourceID is extracted by GetLatestVimScripts from the script's page on -vim.sf.net; whenever its greater than the one stored in the -GetLatestVimScripts.dat file, the script will be downloaded -(see |GetLatestVimScripts_dat|). - -If your script's author has included a special comment line in his/her plugin, -the plugin itself will be used by GetLatestVimScripts to build your - file, including any dependencies on other scripts it -may have. As an example, consider: > - - " GetLatestVimScripts: 884 1 :AutoInstall: AutoAlign.vim - -This comment line tells getscript.vim to check vimscript #884 and that the -script is automatically installable. Getscript will also use this line to -help build the GetLatestVimScripts.dat file, by including a line such as: > - - 884 1 AutoAlign.vim -< -in it an AutoAlign.vim line isn't already in GetLatestVimScripts.dat file. -See |glvs-plugins| for more. Thus, GetLatestVimScripts thus provides a -comprehensive ability to keep your plugins up-to-date! - - *GetLatestVimScripts_dat* -As an example of a file: -> - ScriptID SourceID Filename - -------------------------- - 294 1 Align.vim - 120 2 decho.vim - 40 3 DrawIt.tar.gz - 451 4 EasyAccents.vim - 195 5 engspchk.vim - 642 6 GetLatestVimScripts.vim - 489 7 Manpageview.vim -< -Note: the first two lines are required, but essentially act as comments. - - -============================================================================== -5. GetLatestVimScripts Friendly Plugins *getscript-plugins* *glvs-plugins* - -If a plugin author includes the following comment anywhere in their plugin, -GetLatestVimScripts will find it and use it to automatically build the user's -GetLatestVimScripts.dat files: -> - src_id - v - " GetLatestVimScripts: ### ### yourscriptname - ^ - scriptid -< -As an author, you should include such a line in to refer to your own script -plus any additional lines describing any plugin dependencies it may have. -Same format, of course! - -If your command is auto-installable (see |glvs-autoinstall|), and most scripts -are, then you may include :AutoInstall: at the start of "yourscriptname". - -GetLatestVimScripts commands for those scripts are then appended, if not -already present, to the user's GetLatest/GetLatestVimScripts.dat file. Its a -relatively painless way to automate the acquisition of any scripts your -plugins depend upon. - -Now, as an author, you probably don't want GetLatestVimScripts to download -your own scripts for you yourself, thereby overwriting your not-yet-released -hard work. GetLatestVimScripts provides a solution for this: put -> - 0 0 yourscriptname -< -into your file and GetLatestVimScripts will skip -examining the "yourscriptname" scripts for those GetLatestVimScripts comment -lines. As a result, those lines won't be inadvertently installed into your - file and subsequently used to download your own -scripts. This is especially important to do if you've included the -:AutoInstall: option. - -Be certain to use the same "yourscriptname" in the "0 0 yourscriptname" line -as you've used in your GetLatestVimScripts comment! - - -============================================================================== -6. GetLatestVimScripts AutoInstall *getscript-autoinstall* - *glvs-autoinstall* - -GetLatestVimScripts now supports "AutoInstall". Not all scripts are -supportive of auto-install, as they may have special things you need to do to -install them (please refer to the script's "install" directions). On the -other hand, most scripts will be auto-installable. - -To let GetLatestVimScripts do an autoinstall, the data file's comment field -should begin with (surrounding blanks are ignored): > - - :AutoInstall: -< -Both colons are needed, and it should begin the comment (yourscriptname) -field. - -One may prevent any autoinstalling by putting the following line in your -<.vimrc>: > - - let g:GetLatestVimScripts_allowautoinstall= 0 -< -With :AutoInstall: enabled, as it is by default, files which end with - - ---.tar.bz2 : decompressed & untarred in .vim/ directory - ---.vba.bz2 : decompressed in .vim/ directory, then vimball handles it - ---.vim.bz2 : decompressed & moved into .vim/plugin directory - ---.tar.gz : decompressed & untarred in .vim/ directory - ---.vba.gz : decompressed in .vim/ directory, then vimball handles it - ---.vim.gz : decompressed & moved into .vim/plugin directory - ---.vba : unzipped in .vim/ directory - ---.vim : moved to .vim/plugin directory - ---.zip : unzipped in .vim/ directory - -and which merely need to have their components placed by the untar/gunzip or -move-to-plugin-directory process should be auto-installable. Vimballs, of -course, should always be auto-installable. - -When is a script not auto-installable? Let me give an example: - - .vim/after/syntax/blockhl.vim - -The script provides block highlighting for C/C++ programs; it is -available at: - - http://vim.sourceforge.net/scripts/script.php?script_id=104 - -Currently, vim's after/syntax only supports by-filetype scripts (in -blockhl.vim's case, that's after/syntax/c.vim). Hence, auto-install would -possibly overwrite the current user's after/syntax/c.vim file. - -In my own case, I use (renamed to after/syntax/c.vim) to -allow a after/syntax/c/ directory: - - http://vim.sourceforge.net/scripts/script.php?script_id=1023 - -The script allows multiple syntax files to exist separately in the -after/syntax/c subdirectory. I can't bundle aftersyntax.vim in and build an -appropriate tarball for auto-install because of the potential for the -after/syntax/c.vim contained in it to overwrite a user's c.vim. - - -============================================================================== -7. GetLatestVimScripts Options *glvs-options* -> - g:GetLatestVimScripts_wget -< default= "wget" - This variable holds the name of the command for obtaining - scripts. -> - g:GetLatestVimScripts_options -< default= "-q -O" - This variable holds the options to be used with the - g:GetLatestVimScripts_wget command. -> - g:getLatestVimScripts_allowautoinstall -< default= 1 - This variable indicates whether GetLatestVimScripts is allowed - to attempt to automatically install scripts. Note that it - doesn't understand vimballs (yet). Furthermore, the plugin - author has to have explicitly indicated that his/her plugin - is automatically installable. - - -============================================================================== -8. GetLatestVimScripts Algorithm *glvs-algorithm* *glvs-alg* - -The Vim sourceforge page dynamically creates a page by keying off of the -so-called script-id. Within the webpage of - - http://vim.sourceforge.net/scripts/script.php?script_id=40 - -is a line specifying the latest source-id (src_id). The source identifier -numbers are always increasing, hence if the src_id is greater than the one -recorded for the script in GetLatestVimScripts then its time to download a -newer copy of that script. - -GetLatestVimScripts will then download the script and update its internal -database of script ids, source ids, and scriptnames. - -The AutoInstall process will: - - Move the file from GetLatest/ to the following directory - Unix : $HOME/.vim - Windows: $HOME\vimfiles - if the downloaded file ends with ".bz2" - bunzip2 it - else if the downloaded file ends with ".gz" - gunzip it - if the resulting file ends with ".zip" - unzip it - else if the resulting file ends with ".tar" - tar -oxvf it - else if the resulting file ends with ".vim" - move it to the plugin subdirectory - - -============================================================================== -9. GetLatestVimScripts History *getscript-history* *glvs-hist* {{{1 - -v24 Apr 16, 2007 : * removed save&restore of the fo option during script - loading -v23 Nov 03, 2006 : * ignores comments (#...) - * handles vimballs -v22 Oct 13, 2006 : * supports automatic use of curl if wget is not - available -v21 May 01, 2006 : * now takes advantage of autoloading. -v20 Dec 23, 2005 : * Eric Haarbauer found&fixed a bug with unzip use; - unzip needs the -o flag to overwrite. -v19 Nov 28, 2005 : * v18's GetLatestVimScript line accessed the wrong - script! Fixed. -v18 Mar 21, 2005 : * bugfix to automatic database construction - * bugfix - nowrapscan caused an error - (tnx to David Green for the fix) - Apr 01, 2005 * if shell is bash, "mv" instead of "ren" used in - :AutoInstall:s, even though its o/s is windows - Apr 01, 2005 * when downloading errors occurred, GLVS was - terminating early. It now just goes on to trying - the next script (after trying three times to - download a script description page) - Apr 20, 2005 * bugfix - when a failure to download occurred, - GetLatestVimScripts would stop early and claim that - everything was current. Fixed. -v17 Aug 25, 2004 : * g:GetLatestVimScripts_allowautoinstall, which - defaults to 1, can be used to prevent all - :AutoInstall: -v16 Aug 25, 2004 : * made execution of bunzip2/gunzip/tar/zip silent - * fixed bug with :AutoInstall: use of helptags -v15 Aug 24, 2004 : * bugfix: the "0 0 comment" download prevention wasn't - always preventing downloads (just usually). Fixed. -v14 Aug 24, 2004 : * bugfix -- helptags was using dotvim, rather than - s:dotvim. Fixed. -v13 Aug 23, 2004 : * will skip downloading a file if its scriptid or srcid - is zero. Useful for script authors; that way their - own GetLatestVimScripts activity won't overwrite - their scripts. -v12 Aug 23, 2004 : * bugfix - a "return" got left in the distribution that - was intended only for testing. Removed, now works. - * :AutoInstall: implemented -v11 Aug 20, 2004 : * GetLatestVimScripts is now a plugin: - * :GetLatestVimScripts command - * (runtimepath)/GetLatest/GetLatestVimScripts.dat - now holds scripts that need updating -v10 Apr 19, 2004 : * moved history from script to doc -v9 Jan 23, 2004 : windows (win32/win16/win95) will use - double quotes ("") whereas other systems will use - single quotes ('') around the urls in calls via wget -v8 Dec 01, 2003 : makes three tries at downloading -v7 Sep 02, 2003 : added error messages if "Click on..." or "src_id=" - not found in downloaded webpage - Uses t_ti, t_te, and rs to make progress visible -v6 Aug 06, 2003 : final status messages now display summary of work - ( "Downloaded someqty scripts" or - "Everything was current") - Now GetLatestVimScripts is careful about downloading - GetLatestVimScripts.vim itself! - (goes to ) -v5 Aug 04, 2003 : missing an endif near bottom -v4 Jun 17, 2003 : redraw! just before each "considering" message -v3 May 27, 2003 : Protects downloaded files from errant shell - expansions with single quotes: '...' -v2 May 14, 2003 : extracts name of item to be obtained from the - script file. Uses it instead of comment field - for output filename; comment is used in the - "considering..." line and is now just a comment! - * Fixed a bug: a string-of-numbers is not the - same as a number, so I added zero to them - and they became numbers. Fixes comparison. - -============================================================================== -vim:tw=78:ts=8:ft=help:fdm=marker +*pi_getscript.txt* For Vim version 7.0. Last change: 2008 Jan 07 +> + GETSCRIPT REFERENCE MANUAL by Charles E. Campbell, Jr. +< +Authors: Charles E. Campbell, Jr. + (remove NOSPAM from the email address) + *GetLatestVimScripts-copyright* +Copyright: (c) 2004-2006 by Charles E. Campbell, Jr. *glvs-copyright* + The VIM LICENSE applies to getscript.vim and + pi_getscript.txt (see |copyright|) except use + "getscript" instead of "Vim". No warranty, express or implied. + Use At-Your-Own-Risk. + +Getscript is a plugin that simplifies retrieval of the latest versions of the +scripts that you yourself use! Typing |:GLVS| will invoke getscript; it will +then use the (see |GetLatestVimScripts_dat|) file to +get the latest versions of scripts listed therein from http://vim.sf.net/. + +============================================================================== +1. Contents *glvs-contents* *glvs* *getscript* + *GetLatestVimScripts* + + 1. Contents........................................: |glvs-contents| + 2. GetLatestVimScripts -- Getting Started..........: |glvs-install| + 3. GetLatestVimScripts Usage.......................: |glvs-usage| + 4. GetLatestVimScripts Data File...................: |glvs-data| + 5. GetLatestVimScripts Friendly Plugins............: |glvs-plugins| + 6. GetLatestVimScripts AutoInstall.................: |glvs-autoinstall| + 7. GetLatestViMScripts Options.....................: |glvs-options| + 8. GetLatestVimScripts Algorithm...................: |glvs-alg| + 9. GetLatestVimScripts History.....................: |glvs-hist| + + +============================================================================== +2. GetLatestVimScripts -- Getting Started *getscript-start* + *getlatestvimscripts-install* + + VERSION FROM VIM DISTRIBUTION *glvs-dist-install* + +Vim 7.0 does not include the GetLatestVimScripts.dist file which +serves as an example and a template. So, you'll need to create +your own! See |GetLatestVimScripts_dat|. + + VERSION FROM VIM SF NET *glvs-install* + +NOTE: The last step, that of renaming/moving the GetLatestVimScripts.dist +file, is for those who have just downloaded GetLatestVimScripts.tar.bz2 for +the first time. + +The GetLatestVimScripts.dist file serves as an example and a template for your +own personal list. Feel free to remove all the scripts mentioned within it; +the "important" part of it is the first two lines. + +Your computer needs to have wget for GetLatestVimScripts to do its work. + + 1. if compressed: gunzip getscript.vba.gz + 2. Unix: + vim getscript.vba + :so % + :q + cd ~/.vim/GetLatest + mv GetLatestVimScripts.dist GetLatestVimScripts.dat + (edit GetLatestVimScripts.dat to install your own personal + list of desired plugins -- see |GetLatestVimScripts_dat|) + + 3. Windows: + vim getscript.vba + :so % + :q + cd **path-to-vimfiles**/GetLatest + mv GetLatestVimScripts.dist GetLatestVimScripts.dat + (edit GetLatestVimScripts.dat to install your own personal + list of desired plugins -- see |GetLatestVimScripts_dat|) + + +============================================================================== +3. GetLatestVimScripts Usage *glvs-usage* *:GLVS* + +Unless its been defined elsewhere, > + :GLVS +will invoke GetLatestVimScripts(). If some other plugin has defined that +command, then you may type +> + :GetLatestVimScripts +< +The script will attempt to update and, if permitted, will automatically +install scripts from http://vim.sourceforge.net/. To do so it will peruse a +file, +> + .vim/GetLatest/GetLatestVimScripts.dat (unix) +< +or > + ..wherever..\vimfiles\GetLatest\GetLatestVimScripts.dat (windows) +(see |glvs-data|), and examine plugins in your [.vim|vimfiles]/plugin +directory (see |glvs-plugins|). + +Scripts which have been downloaded will appear in the +~/.vim/GetLatest (unix) or ..wherever..\vimfiles\GetLatest (windows) +subdirectory. GetLatestVimScripts will attempt to automatically +install them if you have the following line in your <.vimrc>: > + + let g:GetLatestVimScripts_allowautoinstall=1 + +The file will be automatically be updated to +reflect the latest version of script(s) so downloaded. +(also see |glvs-options|) + + +============================================================================== +4. GetLatestVimScripts Data File *getscript-data* *glvs-data* + *:GetLatestVimScripts_dat* +The data file must have for its first two lines +the following text: +> + ScriptID SourceID Filename + -------------------------- +< +Following those two lines are three columns; the first two are numeric +followed by a text column. The GetLatest/GetLatestVimScripts.dist file +contains an example of such a data file. Anything following a #... is +ignored, so you may embed comments in the file. + +The first number on each line gives the script's ScriptID. When you're about +to use a web browser to look at scripts on http://vim.sf.net/, just before you +click on the script's link, you'll see a line resembling + + http://vim.sourceforge.net/scripts/script.php?script_id=40 + +The "40" happens to be a ScriptID that GetLatestVimScripts needs to +download the associated page. + +The second number on each line gives the script's SourceID. The SourceID +records the count of uploaded scripts as determined by vim.sf.net; hence it +serves to indicate "when" a script was uploaded. Setting the SourceID to 1 +insures that GetLatestVimScripts will assume that the script it has is +out-of-date. + +The SourceID is extracted by GetLatestVimScripts from the script's page on +vim.sf.net; whenever its greater than the one stored in the +GetLatestVimScripts.dat file, the script will be downloaded +(see |GetLatestVimScripts_dat|). + +If your script's author has included a special comment line in his/her plugin, +the plugin itself will be used by GetLatestVimScripts to build your + file, including any dependencies on other scripts it +may have. As an example, consider: > + + " GetLatestVimScripts: 884 1 :AutoInstall: AutoAlign.vim + +This comment line tells getscript.vim to check vimscript #884 and that the +script is automatically installable. Getscript will also use this line to +help build the GetLatestVimScripts.dat file, by including a line such as: > + + 884 1 AutoAlign.vim +< +in it an AutoAlign.vim line isn't already in GetLatestVimScripts.dat file. +See |glvs-plugins| for more. Thus, GetLatestVimScripts thus provides a +comprehensive ability to keep your plugins up-to-date! + + *GetLatestVimScripts_dat* +As an example of a file: +> + ScriptID SourceID Filename + -------------------------- + 294 1 Align.vim + 120 2 decho.vim + 40 3 DrawIt.tar.gz + 451 4 EasyAccents.vim + 195 5 engspchk.vim + 642 6 GetLatestVimScripts.vim + 489 7 Manpageview.vim +< +Note: the first two lines are required, but essentially act as comments. + + +============================================================================== +5. GetLatestVimScripts Friendly Plugins *getscript-plugins* *glvs-plugins* + +If a plugin author includes the following comment anywhere in their plugin, +GetLatestVimScripts will find it and use it to automatically build the user's +GetLatestVimScripts.dat files: +> + src_id + v + " GetLatestVimScripts: ### ### yourscriptname + ^ + scriptid +< +As an author, you should include such a line in to refer to your own script +plus any additional lines describing any plugin dependencies it may have. +Same format, of course! + +If your command is auto-installable (see |glvs-autoinstall|), and most scripts +are, then you may include :AutoInstall: at the start of "yourscriptname". + +GetLatestVimScripts commands for those scripts are then appended, if not +already present, to the user's GetLatest/GetLatestVimScripts.dat file. Its a +relatively painless way to automate the acquisition of any scripts your +plugins depend upon. + +Now, as an author, you probably don't want GetLatestVimScripts to download +your own scripts for you yourself, thereby overwriting your not-yet-released +hard work. GetLatestVimScripts provides a solution for this: put +> + 0 0 yourscriptname +< +into your file and GetLatestVimScripts will skip +examining the "yourscriptname" scripts for those GetLatestVimScripts comment +lines. As a result, those lines won't be inadvertently installed into your + file and subsequently used to download your own +scripts. This is especially important to do if you've included the +:AutoInstall: option. + +Be certain to use the same "yourscriptname" in the "0 0 yourscriptname" line +as you've used in your GetLatestVimScripts comment! + + +============================================================================== +6. GetLatestVimScripts AutoInstall *getscript-autoinstall* + *glvs-autoinstall* + +GetLatestVimScripts now supports "AutoInstall". Not all scripts are +supportive of auto-install, as they may have special things you need to do to +install them (please refer to the script's "install" directions). On the +other hand, most scripts will be auto-installable. + +To let GetLatestVimScripts do an autoinstall, the data file's comment field +should begin with (surrounding blanks are ignored): > + + :AutoInstall: +< +Both colons are needed, and it should begin the comment (yourscriptname) +field. + +One may prevent any autoinstalling by putting the following line in your +<.vimrc>: > + + let g:GetLatestVimScripts_allowautoinstall= 0 +< +With :AutoInstall: enabled, as it is by default, files which end with + + ---.tar.bz2 : decompressed & untarred in .vim/ directory + ---.vba.bz2 : decompressed in .vim/ directory, then vimball handles it + ---.vim.bz2 : decompressed & moved into .vim/plugin directory + ---.tar.gz : decompressed & untarred in .vim/ directory + ---.vba.gz : decompressed in .vim/ directory, then vimball handles it + ---.vim.gz : decompressed & moved into .vim/plugin directory + ---.vba : unzipped in .vim/ directory + ---.vim : moved to .vim/plugin directory + ---.zip : unzipped in .vim/ directory + +and which merely need to have their components placed by the untar/gunzip or +move-to-plugin-directory process should be auto-installable. Vimballs, of +course, should always be auto-installable. + +When is a script not auto-installable? Let me give an example: + + .vim/after/syntax/blockhl.vim + +The script provides block highlighting for C/C++ programs; it is +available at: + + http://vim.sourceforge.net/scripts/script.php?script_id=104 + +Currently, vim's after/syntax only supports by-filetype scripts (in +blockhl.vim's case, that's after/syntax/c.vim). Hence, auto-install would +possibly overwrite the current user's after/syntax/c.vim file. + +In my own case, I use (renamed to after/syntax/c.vim) to +allow a after/syntax/c/ directory: + + http://vim.sourceforge.net/scripts/script.php?script_id=1023 + +The script allows multiple syntax files to exist separately in the +after/syntax/c subdirectory. I can't bundle aftersyntax.vim in and build an +appropriate tarball for auto-install because of the potential for the +after/syntax/c.vim contained in it to overwrite a user's c.vim. + + +============================================================================== +7. GetLatestVimScripts Options *glvs-options* +> + g:GetLatestVimScripts_wget +< default= "wget" + This variable holds the name of the command for obtaining + scripts. +> + g:GetLatestVimScripts_options +< default= "-q -O" + This variable holds the options to be used with the + g:GetLatestVimScripts_wget command. +> + g:getLatestVimScripts_allowautoinstall +< default= 1 + This variable indicates whether GetLatestVimScripts is allowed + to attempt to automatically install scripts. Note that it + doesn't understand vimballs (yet). Furthermore, the plugin + author has to have explicitly indicated that his/her plugin + is automatically installable. + + +============================================================================== +8. GetLatestVimScripts Algorithm *glvs-algorithm* *glvs-alg* + +The Vim sourceforge page dynamically creates a page by keying off of the +so-called script-id. Within the webpage of + + http://vim.sourceforge.net/scripts/script.php?script_id=40 + +is a line specifying the latest source-id (src_id). The source identifier +numbers are always increasing, hence if the src_id is greater than the one +recorded for the script in GetLatestVimScripts then it's time to download a +newer copy of that script. + +GetLatestVimScripts will then download the script and update its internal +database of script ids, source ids, and scriptnames. + +The AutoInstall process will: + + Move the file from GetLatest/ to the following directory + Unix : $HOME/.vim + Windows: $HOME\vimfiles + if the downloaded file ends with ".bz2" + bunzip2 it + else if the downloaded file ends with ".gz" + gunzip it + if the resulting file ends with ".zip" + unzip it + else if the resulting file ends with ".tar" + tar -oxvf it + else if the resulting file ends with ".vim" + move it to the plugin subdirectory + + +============================================================================== +9. GetLatestVimScripts History *getscript-history* *glvs-hist* {{{1 + +v29 Jan 07, 2008 : * Bram M pointed out that cpo is a global option and that + getscriptPlugin.vim was setting it but not restoring it. +v28 Jan 02, 2008 : * improved shell quoting character handling, cygwin + interface, register-a bypass + Oct 29, 2007 * Bill McCarthy suggested a change to getscript that avoids + creating pop-up windows +v24 Apr 16, 2007 : * removed save&restore of the fo option during script + loading +v23 Nov 03, 2006 : * ignores comments (#...) + * handles vimballs +v22 Oct 13, 2006 : * supports automatic use of curl if wget is not + available +v21 May 01, 2006 : * now takes advantage of autoloading. +v20 Dec 23, 2005 : * Eric Haarbauer found&fixed a bug with unzip use; + unzip needs the -o flag to overwrite. +v19 Nov 28, 2005 : * v18's GetLatestVimScript line accessed the wrong + script! Fixed. +v18 Mar 21, 2005 : * bugfix to automatic database construction + * bugfix - nowrapscan caused an error + (tnx to David Green for the fix) + Apr 01, 2005 * if shell is bash, "mv" instead of "ren" used in + :AutoInstall:s, even though its o/s is windows + Apr 01, 2005 * when downloading errors occurred, GLVS was + terminating early. It now just goes on to trying + the next script (after trying three times to + download a script description page) + Apr 20, 2005 * bugfix - when a failure to download occurred, + GetLatestVimScripts would stop early and claim that + everything was current. Fixed. +v17 Aug 25, 2004 : * g:GetLatestVimScripts_allowautoinstall, which + defaults to 1, can be used to prevent all + :AutoInstall: +v16 Aug 25, 2004 : * made execution of bunzip2/gunzip/tar/zip silent + * fixed bug with :AutoInstall: use of helptags +v15 Aug 24, 2004 : * bugfix: the "0 0 comment" download prevention wasn't + always preventing downloads (just usually). Fixed. +v14 Aug 24, 2004 : * bugfix -- helptags was using dotvim, rather than + s:dotvim. Fixed. +v13 Aug 23, 2004 : * will skip downloading a file if its scriptid or srcid + is zero. Useful for script authors; that way their + own GetLatestVimScripts activity won't overwrite + their scripts. +v12 Aug 23, 2004 : * bugfix - a "return" got left in the distribution that + was intended only for testing. Removed, now works. + * :AutoInstall: implemented +v11 Aug 20, 2004 : * GetLatestVimScripts is now a plugin: + * :GetLatestVimScripts command + * (runtimepath)/GetLatest/GetLatestVimScripts.dat + now holds scripts that need updating +v10 Apr 19, 2004 : * moved history from script to doc +v9 Jan 23, 2004 : windows (win32/win16/win95) will use + double quotes ("") whereas other systems will use + single quotes ('') around the urls in calls via wget +v8 Dec 01, 2003 : makes three tries at downloading +v7 Sep 02, 2003 : added error messages if "Click on..." or "src_id=" + not found in downloaded webpage + Uses t_ti, t_te, and rs to make progress visible +v6 Aug 06, 2003 : final status messages now display summary of work + ( "Downloaded someqty scripts" or + "Everything was current") + Now GetLatestVimScripts is careful about downloading + GetLatestVimScripts.vim itself! + (goes to ) +v5 Aug 04, 2003 : missing an endif near bottom +v4 Jun 17, 2003 : redraw! just before each "considering" message +v3 May 27, 2003 : Protects downloaded files from errant shell + expansions with single quotes: '...' +v2 May 14, 2003 : extracts name of item to be obtained from the + script file. Uses it instead of comment field + for output filename; comment is used in the + "considering..." line and is now just a comment! + * Fixed a bug: a string-of-numbers is not the + same as a number, so I added zero to them + and they became numbers. Fixes comparison. + +============================================================================== +vim:tw=78:ts=8:ft=help:fdm=marker diff --git a/vimfiles/doc/pi_netrw.txt b/vimfiles/doc/pi_netrw.txt index ea50a8d..0e6ad1f 100644 --- a/vimfiles/doc/pi_netrw.txt +++ b/vimfiles/doc/pi_netrw.txt @@ -1,4 +1,4 @@ -*pi_netrw.txt* For Vim version 7.1. Last change: 2007 Dec 12 +*pi_netrw.txt* For Vim version 7.1. Last change: 2008 Feb 26 ----------------------------------------------------- NETRW REFERENCE MANUAL by Charles E. Campbell, Jr. @@ -45,12 +45,14 @@ Customizing Browsing With A User Function..........|netrw-x| Deleting Files Or Directories......................|netrw-D| Directory Exploring Commands.......................|netrw-explore| + Exploring With Stars and Patterns..................|netrw-star| + Displaying Information About File..................|netrw-qf| Edit File Or Directory Hiding List.................|netrw-ctrl-h| Editing The Sorting Sequence.......................|netrw-S| Going Up...........................................|netrw--| Hiding Files Or Directories........................|netrw-a| Improving Browsing.................................|netrw-ssh-hack| - Listing Bookmarks And History......................|netrw-q| + Listing Bookmarks And History......................|netrw-qb| Making A New Directory.............................|netrw-d| Making The Browsing Directory The Current Directory|netrw-c| Marked Files: Compression And Decompression........|netrw-mz| @@ -807,11 +809,13 @@ There are several things you can do to affect the browser's display of files: * To change the listing style, press the "i" key (|netrw-i|). Currently there are four styles: thin, long, wide, and tree. + * To hide files (don't want to see those xyz~ files anymore?) see |netrw-ctrl-h|. + * Press s to sort files by name, time, or size. -See |netrw-browse-cmds| for all the things you can do! +See |netrw-browse-cmds| for all the things you can do with netrw! QUICK REFERENCE: MAPS *netrw-browse-maps* {{{2 @@ -830,6 +834,7 @@ QUICK REFERENCE: MAPS *netrw-browse-maps* {{{2 d Make a directory |netrw-d| D Attempt to remove the file(s)/directory(ies) |netrw-D| gb Go to previous bookmarked directory |netrw-gb| + gi Display information on file |netrw-qf| Edit file hiding list |netrw-ctrl-h| i Cycle between thin, long, wide, and tree listings |netrw-i| Causes Netrw to refresh the directory listing |netrw-ctrl-l| @@ -838,6 +843,7 @@ QUICK REFERENCE: MAPS *netrw-browse-maps* {{{2 md Apply diff to marked files (up to 3) |netrw-md| me Place marked files on arg list and edit them |netrw-me| mf Mark a file |netrw-mf| + mh Toggle marked file suffices' presence on hiding list |netrw-mh| mm Move marked files to marked-file target directory |netrw-mm| mp Print marked files |netrw-mp| mr Mark files satisfying a |regexp| |netrw-mr| @@ -851,7 +857,7 @@ QUICK REFERENCE: MAPS *netrw-browse-maps* {{{2 O Obtain a file specified by cursor |netrw-O| p Preview the file |netrw-p| P Browse in the previously used window |netrw-P| - q List bookmarked directories and history |netrw-q| + q List bookmarked directories and history |netrw-qb| r Reverse sorting order |netrw-r| R Rename the designed file(s)/directory(ies) |netrw-R| s Select sorting style: by name, time, or file size |netrw-s| @@ -869,11 +875,13 @@ QUICK REFERENCE: MAPS *netrw-browse-maps* {{{2 see |netrw-P| (gvim only) delete file/directory using word under mouse - <2-leftmouse> (gvim only) when in a netrw-selected file, a double - clicked leftmouse button will return to the netrw - browser window. This mapping is available only if - the user doesn't already have a <2-leftmouse> mapping. - See |g:netrw_noretmap| if you don't want this mapping. + <2-leftmouse> (gvim only) when: + * in a netrw-selected file, AND + * |g:netrw_retmap| == 1 AND + * the user doesn't already have a <2-leftmouse> mapping + defined before netrw is autoloaded, + then a double clicked leftmouse button will return + to the netrw browser window. (gvim only) like mf, will mark files QUICK REFERENCE: COMMANDS *netrw-explore-cmds* *netrw-browse-cmds* {{{2 @@ -895,7 +903,7 @@ One may easily "bookmark" a directory by using > < Any count may be used. One may use viminfo's "!" option to retain bookmarks between vim sessions. See |netrw-gb| for how to return to a bookmark and -|netrw-q| for how to list them. +|netrw-qb| for how to list them. BROWSING *netrw-cr* {{{2 @@ -917,10 +925,17 @@ default. When the option is one or two, the splitting will be taken horizontally or vertically, respectively. When the option is set to three, a will cause the file to appear in a new tab. -When using the gui (gvim), one may also click on a file using the leftmouse -button. A doubly-clicked leftmouse button will return to the netrw browser -window (unless |g:netrw_noretmap| is used, or the double-click leftmouse map -is already defined before netrw is loaded). + +When using the gui (gvim) one may select a file by pressing the +button. In addtion, if + + *|g:netrw_retmap| == 1 AND (its default value is 0) + * in a netrw-selected file, AND + * the user doesn't already have a <2-leftmouse> mapping defined before + netrw is loaded + +then a doubly-clicked leftmouse button will return to the netrw browser +window. Netrw attempts to speed up browsing, especially for remote browsing where one may have to enter passwords, by keeping and re-using previously obtained @@ -1022,7 +1037,7 @@ To change directory back to a bookmarked directory, use {cnt}gb Any count may be used to reference any of the bookmarks. See |netrw-mb| on -how to bookmark a directory and |netrw-q| on how to list bookmarks. +how to bookmark a directory and |netrw-qb| on how to list bookmarks. CHANGING TO A PREDECESSOR DIRECTORY *netrw-u* *netrw-updir* {{{2 @@ -1038,7 +1053,7 @@ CHANGING TO A SUCCESSOR DIRECTORY *netrw-U* *netrw-downdir* {{{2 With the "U" map, one can change to a later directory (successor). This map is the opposite of the "u" map. (see |netrw-u|) Use the -q map to list both the bookmarks and history. (see |netrw-q|) +q map to list both the bookmarks and history. (see |netrw-qb|) NETRW CLEAN *netrw-clean* *:NetrwClean* @@ -1198,6 +1213,9 @@ DIRECTORY EXPLORATION COMMANDS {{{2 By default, these commands use the current file's directory. However, one may explicitly provide a directory (path) to use. +The |g:netrw_winsize| variable also is used, if specified by the user, to +size Hexplore and Vexplore windows. + :Rexplore This command is a little different from the others. When one edits a file, for example by pressing when atop a file in a netrw browser window, :Rexplore will return the display to @@ -1205,32 +1223,41 @@ may explicitly provide a directory (path) to use. of <2-leftmouse> (which is only available under gvim and cooperative terms). - *netrw-starstar* -When Explore, Sexplore, Hexplore, or Vexplore are used with a **/filepat, -such as: -> - :Explore **/filename_pattern + +*netrw-star* *netrw-starpat* *netrw-starstar* *netrw-starstarpat* +EXPLORING WITH STARS AND PATTERNS + +When Explore, Sexplore, Hexplore, or Vexplore are used with one of the +following four styles, Explore generates a list of files which satisfy +the request. > + + */filepat files in current directory which satisfy filepat + **/filepat files in current directory or below which satisfy the + file pattern + *//pattern files in the current directory which contain the + pattern (vimgrep is used) + **//pattern files in the current directory or below which contain + the pattern (vimgrep is used) < -netrw will attempt to find a file in the current directory or any subdirectory -which matches the filename pattern. Internally, it produces a list of files -which match the pattern and their paths; to that extent it resembles the Unix -operation: -> - find $(pwd) -name "$1" -exec "echo" "{}" ";" 2> /dev/null -< -The directory display is updated to show the subdirectory containing a -matching file. One may then proceed to the next (or previous) matching files' -directories by using Nexplore or Pexplore, respectively. If your console or -gui produces recognizable shift-up or shift-down sequences, then you'll likely -find using shift-downarrow and shift-uparrow convenient. They're mapped by -netrw: +The cursor will be placed on the first file in the list. One may then +continue to go to subsequent files on that list via |:Nexplore| or to +preceding files on that list with |:Pexplore|. Explore will update the +directory and place the cursor appropriately. + +A plain > + :Explore +will clear the explore list. + +If your console or gui produces recognizable shift-up or shift-down sequences, +then you'll likely find using shift-downarrow and shift-uparrow convenient. +They're mapped by netrw: == Nexplore, and == Pexplore. As an example, consider > - :Explore **/*.c + :Explore */*.c :Nexplore :Nexplore :Pexplore @@ -1238,29 +1265,6 @@ As an example, consider The status line will show, on the right hand side of the status line, a message like "Match 3 of 20". - *netrw-starpat* -When Explore, Sexplore, Hexplore, or Vexplore are used with a */pattern, -such as: -> - :Explore */pattern -< -netrw will use |:vimgrep| to find files which contain the given pattern. -Like what happens with |netrw-starstar|, a list of files which contain -matches to the given pattern is generated. The cursor will then jump -to the first file with the given pattern; |:Nexplore|, |:Pexplore|, and -the shifted-down and -up arrows work with the list to move to the next -or previous files in that list. - - *netrw-starstarpat* -When Explore, Sexplore, Hexplore, or Vexplore are used with a **//pattern, -such as: -> - :Explore **//pattern -< -then Explore will use |:vimgrep| to find files like |netrw-starpat|; -however, Explore will also search subdirectories as well as the current -directory. - Associated setting variables: |g:netrw_keepdir| |g:netrw_browse_split| |g:netrw_fastbrowse| |g:netrw_ftp_browse_reject| |g:netrw_ftp_list_cmd| |g:netrw_ftp_sizelist_cmd| @@ -1268,6 +1272,13 @@ Associated setting variables: |g:netrw_keepdir| |g:netrw_browse_split| |g:netrw_liststyle| +DISPLAYING INFORMATION ABOUT FILE *netrw-qf* {{{2 + +With the cursor atop a filename, pressing "qf" will reveal the file's size +and last modification timestamp. Currently this capability is only available +for local files. + + EDIT FILE OR DIRECTORY HIDING LIST *netrw-ctrl-h* *netrw-edithide* {{{2 The "" map brings up a requestor allowing the user to change the @@ -1279,14 +1290,15 @@ either be hidden (ie. not shown) or be the only ones displayed (see Associated setting variable: |g:netrw_hide| -EDITING THE SORTING SEQUENCE *netrw-S* *netrw-sortsequence* {{{2 +EDITING THE SORTING SEQUENCE *netrw-S* *netrw-sortsequence* {{{2 When "Sorted by" is name, one may specify priority via the sorting sequence (g:netrw_sort_sequence). The sorting sequence typically prioritizes the name-listing by suffix, although any pattern will do. Patterns are delimited -by commas. The default sorting sequence is: +by commas. The default sorting sequence is (all one line): > - [\/]$,*,\.bak$,\.o$,\.h$,\.info$,\.swp$,\.obj$ + '[\/]$,\.[a-np-z]$,\.h$,\.c$,\.cpp$,*,\.o$,\.obj$,\.info$, + \.swp$,\.bak$,\~$' < The lone * is where all filenames not covered by one of the other patterns will end up. One may change the sorting sequence by modifying the @@ -1297,7 +1309,7 @@ Related topics: |g:netrw-s| |g:netrw-S| Associated setting variable: |g:netrw_sort_sequence| -GOING UP *netrw--* {{{2 +GOING UP *netrw--* {{{2 To go up a directory, press "-" or press the when atop the ../ directory entry in the listing. @@ -1314,7 +1326,7 @@ preferred. The NetList function which implements remote browsing expects that directories will be flagged by a trailing slash. -HIDING FILES OR DIRECTORIES *netrw-a* *netrw-hiding* {{{2 +HIDING FILES OR DIRECTORIES *netrw-a* *netrw-hiding* {{{2 Netrw's browsing facility allows one to use the hiding list in one of three ways: ignore it, hide files which match, and show only those files which @@ -1353,6 +1365,11 @@ If files have been marked using |netrw-mf|, then this command will: and showing only non-hidden files. endif + *netrw-gh* +As a quick shortcut, one may press > + gh +to toggle between hiding files which begin with a period (dot) or not. + Associated setting variable: |g:netrw_list_hide| *netrw-ctrl_h* @@ -1400,10 +1417,12 @@ passwords: http://sial.org/howto/openssh/publickey-auth/ -LISTING BOOKMARKS AND HISTORY *netrw-q* *netrw-listbookmark* {{{2 +LISTING BOOKMARKS AND HISTORY *netrw-qb* *netrw-listbookmark* {{{2 -Pressing "q" will list the bookmarked directories and directory traversal -history (query). (see |netrw-mb|, |netrw-gb|, |netrw-u|, and |netrw-U|) +Pressing "qb" (query bookmarks) will list the bookmarked directories and +directory traversal history (query). + +(see |netrw-mb|, |netrw-gb|, |netrw-u|, and |netrw-U|) MAKING A NEW DIRECTORY *netrw-d* {{{2 @@ -1457,7 +1476,7 @@ associated decompressing utilities; see |g:netrw_decompress|. Associated setting variables: |g:netrw_compress| |g:netrw_decompress| -MARKED FILES: COPYING *netrw-mc* {{{2 +MARKED FILES: COPYING *netrw-mc* {{{2 (See |netrw-mf| and |netrw-mr| for how to mark files) Select a target directory with mt (|netrw-mt|). Then change directory, @@ -1465,18 +1484,29 @@ select file(s) (see |netrw-mf|), and press "mc". Associated setting variable: |g:netrw_localcopycmd| |g:netrw_ssh_cmd| -MARKED FILES: DIFF *netrw-md* {{{2 +MARKED FILES: DIFF *netrw-md* {{{2 (See |netrw-mf| and |netrw-mr| for how to mark files) Use |vimdiff| to visualize difference between selected files (two or three may be selected for this). -MARKED FILES: EDITING *netrw-me* {{{2 +MARKED FILES: EDITING *netrw-me* {{{2 (See |netrw-mf| and |netrw-mr| for how to mark files) This command will place the marked files on the |arglist| and commence editing them. One may return the to explorer window with |:Rexplore|. +MARKED FILES: HIDING AND UNHIDING BY SUFFIX *netrw-mh* {{{2 + (See |netrw-mf| and |netrw-mr| for how to mark files) + +This command extracts the suffices of the marked files and toggles their +presence on the hiding list. Please note that marking the same suffix +this way multiple times will result in the suffix's presence being toggled +for each file (so an even quantity of marked files having the same suffix +is the same as not having bothered to select them at all). + +Related topics: |netrw-a| |g:netrw_list_hide| + MARKED FILES: MOVING *netrw-mm* {{{2 (See |netrw-mf| and |netrw-mr| for how to mark files) @@ -1485,7 +1515,7 @@ select file(s) (see |netrw-mf|), and press "mm". Associated setting variable: |g:netrw_localmovecmd| |g:netrw_ssh_cmd| -MARKED FILES: PRINTING *netrw-mp* {{{2 +MARKED FILES: PRINTING *netrw-mp* {{{2 (See |netrw-mf| and |netrw-mr| for how to mark files) Netrw will apply the |:hardcopy| command to marked files. What it does @@ -1493,7 +1523,13 @@ is open each file in a one-line window, execute hardcopy, then close the one-line window. -MARKED FILES: TAGGING *netrw-mT* {{{2 +MARKED FILES: SOURCING *netrw-ms* {{{2 + (See |netrw-mf| and |netrw-mr| for how to mark files) + +Netrw will source the marked files (using vim's |:source| command) + + +MARKED FILES: TAGGING *netrw-mT* {{{2 (See |netrw-mf| and |netrw-mr| for how to mark files) The "mt" mapping will apply the command in |g:netrw_ctags| (by default, its @@ -1518,19 +1554,31 @@ edit the desired file and go to the tag. Associated setting variables: |g:netrw_ctags| |g:netrw_ssh_cmd| -MARKED FILES: SETTING TARGET DIRECTORY *netrw-mt* {{{2 +MARKED FILES: SETTING THE TARGET DIRECTORY *netrw-mt* {{{2 (See |netrw-mf| and |netrw-mr| for how to mark files) -Set the marked file move/copy target (see |netrw-mc| and |netrw-mm|). +Set the marked file copy/move-to target (see |netrw-mc| and |netrw-mm|): + * if the cursor is atop a file name, then the netrw window's currently + displayed directory is used for the copy/move-to target. -MARKED FILES: UNMARKING *netrw-mu* {{{2 + * also, if the cursor is in the banner, then the netrw window's currently + displayed directory is used for the copy/move-to target. + + * however, if the cursor is atop a directory name, then that directory is + used for the copy/move-to target + +There is only one copy/move-to target per vim session; ie. the target is a +script variable (see |s:var|) and is shared between all netrw windows (in an +instance of vim). + +MARKED FILES: UNMARKING *netrw-mu* {{{2 (See |netrw-mf| and |netrw-mr| for how to mark files) The "mu" mapping will unmark all currently marked files. -MARKING FILES *netrw-mf* {{{2 +MARKING FILES *netrw-mf* {{{2 (also see |netrw-mr|) One may mark files with the cursor atop a filename and then pressing "mf". @@ -1549,7 +1597,7 @@ Two commands, |netrw-mc| and |netrw-mm|, copy/move marked files to a target directory (which can be set with |netrw-mt|). -MARKING FILES BY REGULAR EXPRESSION *netrw-mr* {{{2 +MARKING FILES BY REGULAR EXPRESSION *netrw-mr* {{{2 (also see |netrw-mf|) One may also mark files by pressing "mr"; netrw will then issue a prompt, @@ -1676,6 +1724,7 @@ your browsing preferences. (see also: |netrw-settings|) = 3: tree style listing *g:netrw_list_hide* comma separated pattern list for hiding files Patterns are regular expressions (see |regexp|) + Example: let g:netrw_list_hide= '.*\.swp$' default: "" *g:netrw_localcopycmd* ="cp" Linux/Unix/MacOS/Cygwin @@ -1704,9 +1753,11 @@ your browsing preferences. (see also: |netrw-settings|) *g:netrw_mkdir_cmd* command for making a remote directory default: "ssh USEPORT HOSTNAME mkdir" - *g:netrw_noretmap* if it exists and is set to one, then - <2-leftmouse> will not be mapped for easy + *g:netrw_retmap* if it exists and is set to one, then + <2-leftmouse> will be mapped for easy return to the netrw browser window. + (example: click once to select and open + a file, double-click to return) default: =0 *g:netrw_rm_cmd* command for removing files @@ -1729,6 +1780,28 @@ your browsing preferences. (see also: |netrw-settings|) default: '[\/]$,*,\.bak$,\.o$,\.h$, \.info$,\.swp$,\.obj$' + *g:netrw_special_syntax* If true, then certain files will be shown + in special syntax in the browser: + + netrwBak : *.bak + netrwCompress: *.gz *.bz2 *.Z *.zip + netrwData : *.dat + netrwHdr : *.h + netrwLib : *.a *.so *.lib *.dll + netrwMakefile: [mM]akefile *.mak + netrwObj : *.o *.obj + netrwTags : tags ANmenu ANtags + netrwTilde : *~ + netrwTmp : tmp* *tmp + + These syntax highlighting groups are linked + to Folded or DiffChange by default + (see |hl-Folded| and |hl-DiffChange|), but + one may put lines like > + hi link netrwCompress Visual +< into one's <.vimrc> to use one's own + preferences. + *g:netrw_ssh_cmd* One may specify an executable command to use instead of ssh for remote actions such as listing, file removal, etc. @@ -1759,7 +1832,9 @@ your browsing preferences. (see also: |netrw-settings|) " %a %Y-%m-%d %I-%M-%S %p" default: "%c" - *g:netrw_winsize* specify initial size of new o/v windows + *g:netrw_winsize* specify initial size of new windows made with + "o" (see |netrw-o|), "v" (see |netrw-v|), + |:Hexplore| or |:Vexplore|. default: "" *g:NetrwTopLvlMenu* This variable specifies the top level @@ -2162,6 +2237,61 @@ which is loaded automatically at startup (assuming :set nocp). ============================================================================== 12. History *netrw-history* {{{1 + v122: Feb 12, 2008 * bugfix - first sorting sequence match now has + priority + Feb 14, 2008 * bugfix - sorting sequence was effectively ignoring + sequencing priority of anything following '*' + * toggling a marked file was showing incorrect list + (list was correct, but displayed matches weren't) + * |g:netrw_special_syntax| implemented + v121: Feb 11, 2008 * Bram M reported that :e file ... :e . would not + retain the alternate file. Fixed -- I hope! + * bugfix -- apparently v120 broke an explicit + :Explore dirname + v120: Jan 21, 2008 * |netrw-mt| changed to allow for target selection + based on whether or not word under cursor is a + directory or file, or if cursor is in banner + area. + * |netrw-mh| included (hiding by marked-file suffix) + * functions moved about a bit (improved + categorization) + * executable files now displayed with trailing (*) + * symbolically linked files now displayed with + trailing (@) + * Somewhen, s:NetrwMarkFileMove() got damaged. Its + now restored (missing an endif, for example). + * |netrw-mu| implemented (unmarking marked files) + * many bugs have been removed from the marked file + system (tnx to Mark S. for feedback) + * |netrw-ms| implemented (sourcing marked files) + * fixed use of P with tree listing style + * multiple tree listing now supported + * ./ suppressed + * changed q -> qb (query bookmarks) + * implemented |netrw-qf| + * Explore now has four special list-generation + modes: */filepat **/filepat + *//pattern **//pattern + * gh (|netrw-gh|) is a shortcut for toggling the + hiding of files and directories beginning with a + dot + v119: Jan 10, 2008 * When g:netrw_keepdir is false, + NetrwOptionsRestore() had a problem + (Bill McCarthy) + Jan 11, 2008 * Netrw now shows symbolic links with a trailing + "@" and special highlighting. + Jan 15, 2008 * Changed g:netrw_noretmap -> |g:netrw_retmap|. + Changed: disabled by default at Bram's + preference. + v118: Jan 02, 2008 * Fixed a problem with Windows; + :Explore c:/path/ would not work, + but :Explore c:/path would. + * Fixed a bug in s:NetrwOptionRestore() - lcd's + argument wasn't being properly escaped so it + wouldn't handle spaces in directory names. + (Gary Johnson) + v117: Jan 02, 2008 * Fixed a problem with P; had to include + a b:netrw_curdir bypass (Bram Moolenaar) v116: Nov 27, 2007 * netrw#LocalBrowseCheck() has &ft=="netrw" check to prevent doing a directory listing (was getting unexpected directory refreshes diff --git a/vimfiles/doc/tags b/vimfiles/doc/tags index 6900b17..5e0b1b7 100644 --- a/vimfiles/doc/tags +++ b/vimfiles/doc/tags @@ -1,7 +1,20 @@ +'go' Align.txt /*'go'* :Explore pi_netrw.txt /*:Explore* :GLVS pi_getscript.txt /*:GLVS* :GetLatestVimScripts_dat pi_getscript.txt /*:GetLatestVimScripts_dat* :Hexplore pi_netrw.txt /*:Hexplore* +:I visincr.txt /*:I* +:IA visincr.txt /*:IA* +:ID visincr.txt /*:ID* +:II visincr.txt /*:II* +:IIO visincr.txt /*:IIO* +:IIR visincr.txt /*:IIR* +:IIX visincr.txt /*:IIX* +:IM visincr.txt /*:IM* +:IO visincr.txt /*:IO* +:IPOW visincr.txt /*:IPOW* +:IR visincr.txt /*:IR* +:IX visincr.txt /*:IX* :LP LogiPat.txt /*:LP* :LPF LogiPat.txt /*:LPF* :LogiPat LogiPat.txt /*:LogiPat* @@ -10,6 +23,11 @@ :NetrwClean pi_netrw.txt /*:NetrwClean* :Nexplore pi_netrw.txt /*:Nexplore* :Pexplore pi_netrw.txt /*:Pexplore* +:RI visincr.txt /*:RI* +:RID visincr.txt /*:RID* +:RIDMY visincr.txt /*:RIDMY* +:RIPOW visincr.txt /*:RIPOW* +:RM visincr.txt /*:RM* :Rexplore pi_netrw.txt /*:Rexplore* :RmVimball pi_vimball.txt /*:RmVimball* :Sexplore pi_netrw.txt /*:Sexplore* @@ -22,23 +40,13 @@ :UseVimball pi_vimball.txt /*:UseVimball* :Vexplore pi_netrw.txt /*:Vexplore* :VimballList pi_vimball.txt /*:VimballList* +Align-copyright Align.txt /*Align-copyright* C-Reference crefvim.txt /*C-Reference* GetLatestVimScripts pi_getscript.txt /*GetLatestVimScripts* GetLatestVimScripts-copyright pi_getscript.txt /*GetLatestVimScripts-copyright* GetLatestVimScripts_dat pi_getscript.txt /*GetLatestVimScripts_dat* -I visincr.txt /*I* -IA visincr.txt /*IA* -ID visincr.txt /*ID* IDMY visincr.txt /*IDMY* -II visincr.txt /*II* -IIO visincr.txt /*IIO* -IIR visincr.txt /*IIR* -IIX visincr.txt /*IIX* -IM visincr.txt /*IM* IMDY visincr.txt /*IMDY* -IO visincr.txt /*IO* -IR visincr.txt /*IR* -IX visincr.txt /*IX* IYMD visincr.txt /*IYMD* LogiPat() LogiPat.txt /*LogiPat()* LogiPat-flags LogiPat.txt /*LogiPat-flags* @@ -46,10 +54,93 @@ MatchError matchit.txt /*MatchError* Nread pi_netrw.txt /*Nread* Nsource pi_netrw.txt /*Nsource* Nwrite pi_netrw.txt /*Nwrite* +SR SrchRplcHiGrp.txt /*SR* +SRChooseHiGrp SrchRplcHiGrp.txt /*SRChooseHiGrp* +SRDispHiGrp SrchRplcHiGrp.txt /*SRDispHiGrp* +SRHiGrp SrchRplcHiGrp.txt /*SRHiGrp* +SRSearch SrchRplcHiGrp.txt /*SRSearch* +SrchRplcHiGrp.txt SrchRplcHiGrp.txt /*SrchRplcHiGrp.txt* TCommentDefineType() tComment.txt /*TCommentDefineType()* Vimball-copyright pi_vimball.txt /*Vimball-copyright* [% matchit.txt /*[%* ]% matchit.txt /*]%* +align Align.txt /*align* +align-align Align.txt /*align-align* +align-codepoint Align.txt /*align-codepoint* +align-command Align.txt /*align-command* +align-commands Align.txt /*align-commands* +align-concept Align.txt /*align-concept* +align-concepts Align.txt /*align-concepts* +align-contents Align.txt /*align-contents* +align-control Align.txt /*align-control* +align-history Align.txt /*align-history* +align-manual Align.txt /*align-manual* +align-maps Align.txt /*align-maps* +align-option Align.txt /*align-option* +align-options Align.txt /*align-options* +align-strlen Align.txt /*align-strlen* +align-usage Align.txt /*align-usage* +align-utf Align.txt /*align-utf* +align-utf8 Align.txt /*align-utf8* +align.txt Align.txt /*align.txt* +alignctrl Align.txt /*alignctrl* +alignctrl- Align.txt /*alignctrl-* +alignctrl-+ Align.txt /*alignctrl-+* +alignctrl-- Align.txt /*alignctrl--* +alignctrl-: Align.txt /*alignctrl-:* +alignctrl-< Align.txt /*alignctrl-<* +alignctrl-= Align.txt /*alignctrl-=* +alignctrl-> Align.txt /*alignctrl->* +alignctrl-C Align.txt /*alignctrl-C* +alignctrl-I Align.txt /*alignctrl-I* +alignctrl-P Align.txt /*alignctrl-P* +alignctrl-W Align.txt /*alignctrl-W* +alignctrl-c Align.txt /*alignctrl-c* +alignctrl-g Align.txt /*alignctrl-g* +alignctrl-l Align.txt /*alignctrl-l* +alignctrl-m Align.txt /*alignctrl-m* +alignctrl-no-option Align.txt /*alignctrl-no-option* +alignctrl-p Align.txt /*alignctrl-p* +alignctrl-r Align.txt /*alignctrl-r* +alignctrl-separators Align.txt /*alignctrl-separators* +alignctrl-settings Align.txt /*alignctrl-settings* +alignctrl-v Align.txt /*alignctrl-v* +alignctrl-w Align.txt /*alignctrl-w* +alignman Align.txt /*alignman* +alignmanual Align.txt /*alignmanual* +alignmap-Htd Align.txt /*alignmap-Htd* +alignmap-T= Align.txt /*alignmap-T=* +alignmap-a, Align.txt /*alignmap-a,* +alignmap-a< Align.txt /*alignmap-a<* +alignmap-a= Align.txt /*alignmap-a=* +alignmap-a? Align.txt /*alignmap-a?* +alignmap-abox Align.txt /*alignmap-abox* +alignmap-acom Align.txt /*alignmap-acom* +alignmap-adcom Align.txt /*alignmap-adcom* +alignmap-adec Align.txt /*alignmap-adec* +alignmap-adef Align.txt /*alignmap-adef* +alignmap-afnc Align.txt /*alignmap-afnc* +alignmap-anum Align.txt /*alignmap-anum* +alignmap-aocom Align.txt /*alignmap-aocom* +alignmap-ascom Align.txt /*alignmap-ascom* +alignmap-history Align.txt /*alignmap-history* +alignmap-m= Align.txt /*alignmap-m=* +alignmap-t# Align.txt /*alignmap-t#* +alignmap-t, Align.txt /*alignmap-t,* +alignmap-t: Align.txt /*alignmap-t:* +alignmap-t; Align.txt /*alignmap-t;* +alignmap-t< Align.txt /*alignmap-t<* +alignmap-t= Align.txt /*alignmap-t=* +alignmap-t? Align.txt /*alignmap-t?* +alignmap-tab Align.txt /*alignmap-tab* +alignmap-tml Align.txt /*alignmap-tml* +alignmap-ts, Align.txt /*alignmap-ts,* +alignmap-tsp Align.txt /*alignmap-tsp* +alignmap-tsq Align.txt /*alignmap-tsq* +alignmap-tt Align.txt /*alignmap-tt* +alignmap-t~ Align.txt /*alignmap-t~* +alignmaps Align.txt /*alignmaps* +alignusage Align.txt /*alignusage* b:match_col matchit.txt /*b:match_col* b:match_debug matchit.txt /*b:match_debug* b:match_ignorecase matchit.txt /*b:match_ignorecase* @@ -1332,9 +1423,9 @@ g:netrw_maxfilenamelen pi_netrw.txt /*g:netrw_maxfilenamelen* g:netrw_menu pi_netrw.txt /*g:netrw_menu* g:netrw_mkdir_cmd pi_netrw.txt /*g:netrw_mkdir_cmd* g:netrw_nogx pi_netrw.txt /*g:netrw_nogx* -g:netrw_noretmap pi_netrw.txt /*g:netrw_noretmap* g:netrw_preview pi_netrw.txt /*g:netrw_preview* g:netrw_rcp_cmd pi_netrw.txt /*g:netrw_rcp_cmd* +g:netrw_retmap pi_netrw.txt /*g:netrw_retmap* g:netrw_rm_cmd pi_netrw.txt /*g:netrw_rm_cmd* g:netrw_rmdir_cmd pi_netrw.txt /*g:netrw_rmdir_cmd* g:netrw_rmf_cmd pi_netrw.txt /*g:netrw_rmf_cmd* @@ -1347,6 +1438,7 @@ g:netrw_silent pi_netrw.txt /*g:netrw_silent* g:netrw_sort_by pi_netrw.txt /*g:netrw_sort_by* g:netrw_sort_direction pi_netrw.txt /*g:netrw_sort_direction* g:netrw_sort_sequence pi_netrw.txt /*g:netrw_sort_sequence* +g:netrw_special_syntax pi_netrw.txt /*g:netrw_special_syntax* g:netrw_ssh_browse_reject pi_netrw.txt /*g:netrw_ssh_browse_reject* g:netrw_ssh_cmd pi_netrw.txt /*g:netrw_ssh_cmd* g:netrw_sshport pi_netrw.txt /*g:netrw_sshport* @@ -1471,6 +1563,7 @@ netrw-file pi_netrw.txt /*netrw-file* netrw-fixup pi_netrw.txt /*netrw-fixup* netrw-ftp pi_netrw.txt /*netrw-ftp* netrw-gb pi_netrw.txt /*netrw-gb* +netrw-gh pi_netrw.txt /*netrw-gh* netrw-gx pi_netrw.txt /*netrw-gx* netrw-handler pi_netrw.txt /*netrw-handler* netrw-help pi_netrw.txt /*netrw-help* @@ -1490,11 +1583,13 @@ netrw-mc pi_netrw.txt /*netrw-mc* netrw-md pi_netrw.txt /*netrw-md* netrw-me pi_netrw.txt /*netrw-me* netrw-mf pi_netrw.txt /*netrw-mf* +netrw-mh pi_netrw.txt /*netrw-mh* netrw-ml_get pi_netrw.txt /*netrw-ml_get* netrw-mm pi_netrw.txt /*netrw-mm* netrw-move pi_netrw.txt /*netrw-move* netrw-mp pi_netrw.txt /*netrw-mp* netrw-mr pi_netrw.txt /*netrw-mr* +netrw-ms pi_netrw.txt /*netrw-ms* netrw-mt pi_netrw.txt /*netrw-mt* netrw-mu pi_netrw.txt /*netrw-mu* netrw-mx pi_netrw.txt /*netrw-mx* @@ -1528,7 +1623,8 @@ netrw-prvwin pi_netrw.txt /*netrw-prvwin* netrw-pscp pi_netrw.txt /*netrw-pscp* netrw-psftp pi_netrw.txt /*netrw-psftp* netrw-putty pi_netrw.txt /*netrw-putty* -netrw-q pi_netrw.txt /*netrw-q* +netrw-qb pi_netrw.txt /*netrw-qb* +netrw-qf pi_netrw.txt /*netrw-qf* netrw-r pi_netrw.txt /*netrw-r* netrw-read pi_netrw.txt /*netrw-read* netrw-ref pi_netrw.txt /*netrw-ref* @@ -1542,6 +1638,7 @@ netrw-sort pi_netrw.txt /*netrw-sort* netrw-sortsequence pi_netrw.txt /*netrw-sortsequence* netrw-source pi_netrw.txt /*netrw-source* netrw-ssh-hack pi_netrw.txt /*netrw-ssh-hack* +netrw-star pi_netrw.txt /*netrw-star* netrw-starpat pi_netrw.txt /*netrw-starpat* netrw-starstar pi_netrw.txt /*netrw-starstar* netrw-starstarpat pi_netrw.txt /*netrw-starstarpat* @@ -1579,6 +1676,10 @@ rsync pi_netrw.txt /*rsync* s:netrw_passwd pi_netrw.txt /*s:netrw_passwd* scp pi_netrw.txt /*scp* sftp pi_netrw.txt /*sftp* +srchrplchigrp SrchRplcHiGrp.txt /*srchrplchigrp* +srchrplchigrp-commands SrchRplcHiGrp.txt /*srchrplchigrp-commands* +srchrplchigrp-contents SrchRplcHiGrp.txt /*srchrplchigrp-contents* +srchrplchigrp-examples SrchRplcHiGrp.txt /*srchrplchigrp-examples* tComment-Installation tComment.txt /*tComment-Installation* tComment-Key-Bindings tComment.txt /*tComment-Key-Bindings* tComment-Usage tComment.txt /*tComment-Usage* @@ -1602,11 +1703,13 @@ visincr-ID visincr.txt /*visincr-ID* visincr-IDMY visincr.txt /*visincr-IDMY* visincr-II visincr.txt /*visincr-II* visincr-IIO visincr.txt /*visincr-IIO* +visincr-IIPOW visincr.txt /*visincr-IIPOW* visincr-IIR visincr.txt /*visincr-IIR* visincr-IIX visincr.txt /*visincr-IIX* visincr-IM visincr.txt /*visincr-IM* visincr-IMDY visincr.txt /*visincr-IMDY* visincr-IO visincr.txt /*visincr-IO* +visincr-IPOW visincr.txt /*visincr-IPOW* visincr-IR visincr.txt /*visincr-IR* visincr-IX visincr.txt /*visincr-IX* visincr-IYMD visincr.txt /*visincr-IYMD* @@ -1614,8 +1717,10 @@ visincr-RI visincr.txt /*visincr-RI* visincr-RID visincr.txt /*visincr-RID* visincr-RIDMY visincr.txt /*visincr-RIDMY* visincr-RII visincr.txt /*visincr-RII* +visincr-RIIPOW visincr.txt /*visincr-RIIPOW* visincr-RIM visincr.txt /*visincr-RIM* visincr-RIMDY visincr.txt /*visincr-RIMDY* +visincr-RIPOW visincr.txt /*visincr-RIPOW* visincr-RIYMD visincr.txt /*visincr-RIYMD* visincr-calutil visincr.txt /*visincr-calutil* visincr-copyright visincr.txt /*visincr-copyright* @@ -1628,5 +1733,6 @@ visincr-increment visincr.txt /*visincr-increment* visincr-leaddate visincr.txt /*visincr-leaddate* visincr-options visincr.txt /*visincr-options* visincr-raggedright visincr.txt /*visincr-raggedright* +visincr-restrict visincr.txt /*visincr-restrict* visincr-usage visincr.txt /*visincr-usage* visincr.txt visincr.txt /*visincr.txt* diff --git a/vimfiles/doc/visincr.txt b/vimfiles/doc/visincr.txt index a97a8c9..84f373b 100644 --- a/vimfiles/doc/visincr.txt +++ b/vimfiles/doc/visincr.txt @@ -1,8 +1,8 @@ -*visincr.txt* The Visual Incrementing Tool Sep 19, 2006 +*visincr.txt* The Visual Incrementing Tool Oct 17, 2007 Author: Charles E. Campbell, Jr. (remove NOSPAM from Campbell's email before using) -Copyright: (c) 2004-2005 by Charles E. Campbell, Jr. *visincr-copyright* +Copyright: (c) 2004-2007 by Charles E. Campbell, Jr. *visincr-copyright* The VIM LICENSE applies to visincr.vim and visincr.txt (see |copyright|) except use "visincr" instead of "Vim" No warranty, express or implied. Use At-Your-Own-Risk. @@ -25,6 +25,8 @@ Copyright: (c) 2004-2005 by Charles E. Campbell, Jr. *visincr-copyright* :IA [#] ...................: |visincr-IA| :ID [#] ...................: |visincr-ID| :IM [#] ...................: |visincr-IM| + :IPOW [#] ...................: |visincr-IPOW| + :IIPOW [#] ..................: |visincr-IIPOW| 4. Examples.....................: |visincr-examples| :I ..........................: |ex-viscinr-I| :II .........................: |ex-viscinr-II| @@ -112,14 +114,21 @@ Copyright: (c) 2004-2005 by Charles E. Campbell, Jr. *visincr-copyright* then only three-letter abbreviations will be used. For more: see |visincr-IM| + *:RI* :*RII* :*RIMDY* *:RIDMY* *:RID* *:RM* *visincr-restrict* :RI RII RIYMD RIMDY RIDMY RID RM Restricted variants of the above commands - requires that the visual block on the current line start with an appropriate pattern (ie. a number for :I, a dayname for :ID, a monthname for :IM, etc). - For more, see |visincr-RI|, |visincr-RII|, |visincr-RIYMD|, - |visincr-RIMDY|, |visincr-RIDMY|, |visincr-RID|, and - |visincr-M|. + For more, see + + Restricted left-justified incrementing......|visincr-RI| + Restricted right-justified incrementing.....|visincr-RII| + Restricted year/month/day incrementing......|visincr-RIYMD| + Restricted month/day/year incrementing......|visincr-RIMDY| + Restricted day/month/year incrementing......|visincr-RIDMY| + Restricted dayname incrementing.............|visincr-RID| + Restricted monthname incrementing...........|visincr-M| ============================================================================== @@ -129,7 +138,7 @@ Copyright: (c) 2004-2005 by Charles E. Campbell, Jr. *visincr-copyright* The visincr plugin facilitates making a column of increasing or decreasing numbers, dates, or daynames. - LEFT JUSTIFIED INCREMENTING *I* *viscinr-I* + LEFT JUSTIFIED INCREMENTING *:I* *viscinr-I* :I [#] Will use the first line's number as a starting point to build a column of increasing numbers (or decreasing numbers if the increment is negative). @@ -139,21 +148,21 @@ numbers, dates, or daynames. The IX variant supports hexadecimal incrementing. - *visincr-RI* + *visincr-RI* The restricted version (:RI) applies number incrementing only to those lines in the visual block that begin with a number. See |visincr-raggedright| for a discussion on ragged-right handling. - *IX* *visincr-IX* *IO* *visincr-IO* + *:IX* *visincr-IX* *:IO* *visincr-IO* The following two commands are variants of :I : > :IO [#] left justified octal incrementing :IX [#] left justified hexadecimal incrementing < The increments are in octal or hexadecimal for their respective commands. - *IR* *visincr-IR* *IIR* *visincr-IIR* + *:IR* *visincr-IR* *:IIR* *visincr-IIR* These commands do left (IR) and right (IIR) justified Roman numeral enumeration. The increment for these commands is in the usual arabic numerals (ie. decimal) @@ -162,7 +171,7 @@ numbers, dates, or daynames. - RIGHT JUSTIFIED INCREMENTING *II* *visincr-II* + RIGHT JUSTIFIED INCREMENTING *:II* *visincr-II* :II [# [zfill]] Will use the first line's number as a starting point to build a column of increasing numbers (or decreasing numbers if the increment is negative). @@ -172,14 +181,14 @@ numbers, dates, or daynames. Zfill : left padding will be done with the given character, typically a zero. - *IIX* *visincr-IIX* *IIO* *visincr-IIO* + *:IIX* *visincr-IIX* *:IIO* *visincr-IIO* The following two commands are variants of :II : :IIO [# [zfill]] right justified octal incrementing :IIX [# [zfill]] right justified hexadecimal incrementing - *visincr-RII* - The restricted version (:RII) applies number incrementing only to - those lines in the visual block that begin with zero or more + *visincr-RII* + The restricted version (:RII) applies number incrementing only + to those lines in the visual block that begin with zero or more spaces and end with a number. RAGGED RIGHT HANDLING FOR I AND II *visincr-raggedright* @@ -227,10 +236,13 @@ numbers, dates, or daynames. words. *g:visincr_datedivset* By default, the date dividers are: given by: > - let g:visincr_datedivset= '[-./]' + let g:visincr_datedivset= '[-./_:~,+*^]\=' < You may change the set in your <.vimrc>. The separator actually - used is the first one found in your date column. - + used is the first one found in your date column. A date + divider is no longer strictly required (note that \= in the + date divider set). For :IMDY and :IDMY and no date dividers, + the year may be 2 or 4 digits. For :IYMD, the year must be + four digits if there are no date dividers. SINGLE DIGIT DAYS OR MONTHS *visincr-leaddate* @@ -253,11 +265,11 @@ numbers, dates, or daynames. http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs - ALPHABETIC INCREMENTING *IA* *visincr-IA* + ALPHABETIC INCREMENTING *:IA* *visincr-IA* :IA Will produce an increasing/decreasing list of alphabetic characters. - DAYNAME INCREMENTING *ID* *visincr-ID* *visincr-RID* + DAYNAME INCREMENTING *:ID* *visincr-ID* *visincr-RID* :ID [#] Will produce an increasing/decreasing list of daynames. Three-letter daynames will be used if the first day on the first line is a three letter dayname; otherwise, full names @@ -267,7 +279,7 @@ numbers, dates, or daynames. to those lines in the visual block that begin with a dayname (mon tue wed thu fri sat). - MONTHNAME INCREMENTING *IM* *visincr-IM* *visincr-RIM* + MONTHNAME INCREMENTING *:IM* *visincr-IM* *visincr-RIM* :IM [#] will produce an increasing/decreasing list of monthnames. Monthnames may be three-letter versions (jan feb etc) or fully-spelled out monthnames. @@ -276,6 +288,16 @@ numbers, dates, or daynames. to those lines in the visual block that begin with a monthname (jan feb mar etc). + POWER INCREMENTING *:IPOW* *visincr-IPOW* *visincr-IIPOW* + *:RIPOW* *visincr-RIPOW* *visincr-RIIPOW* + :IPOW [#] will produce an increasing/decreasing list of powers times + the starting point. The multiplier(divisor)'s default value + is 2. + + Restricted versions (:RIPOW and :RIIPOW) applies only + to those lines in the visual block that begin with + a number. + ============================================================================== 4. Examples: *visincr-examples* @@ -414,6 +436,10 @@ numbers, dates, or daynames. ============================================================================== 6. History: *visincr-history* {{{1 + v18: 02/13/07 : included IPOW and variants + 02/15/07 * date dividers are no longer required + 10/17/07 * calutil.vim and calutil.txt included, and they + use vim 7's autoload feature v17: 07/26/06 : -complete=expression added to all visincr commands 07/27/06 * g:visincr_datedivset support included diff --git a/vimfiles/plugin/AlignMaps.vim b/vimfiles/plugin/AlignMaps.vim new file mode 100644 index 0000000..565a1b0 --- /dev/null +++ b/vimfiles/plugin/AlignMaps.vim @@ -0,0 +1,506 @@ +" AlignMaps: Alignment maps based upon +" Maintainer: Dr. Charles E. Campbell, Jr. +" Date: Mar 06, 2008 +" Version: 39 +" +" NOTE: the code herein needs vim 6.0 or later +" needs v6 or later +" needs v5 or later +" Copyright: Copyright (C) 1999-2007 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, +" AlignMaps.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 +" of this software. +" +" Usage: {{{1 +" Use 'a to mark beginning of to-be-aligned region, Alternative: use v +" move cursor to end of region, and execute map. (visual mode) to mark +" The maps also set up marks 'y and 'z, and retain region, execute same map. +" 'a at the beginning of region. Uses 'a, 'y, and 'z. +" +" Although the comments indicate the maps use a leading backslash, +" actually they use (:he mapleader), so the user can +" specify that the maps start how he or she prefers. +" +" Note: these maps all use . +" +" Romans 1:20 For the invisible things of Him since the creation of the {{{1 +" world are clearly seen, being perceived through the things that are +" made, even His everlasting power and divinity; that they may be +" without excuse. +" --------------------------------------------------------------------- + +" Load Once: {{{1 +if exists("g:loaded_alignmaps") || &cp + finish +endif +let g:loaded_alignmaps = "v39" +let s:keepcpo = &cpo +set cpo&vim + +" --------------------------------------------------------------------- +" WS: wrapper start map (internal) {{{1 +" Produces a blank line above and below, marks with 'y and 'z +if !hasmapto('WrapperStart') + nmap WS AlignMapsWrapperStart +endif +nmap