From 522f5b30ccd23b8e0d0025397840bcb994cea650 Mon Sep 17 00:00:00 2001 From: stefan Date: Mon, 5 Nov 2007 10:58:58 +0000 Subject: [PATCH] + blockdiff.vim, vgrepsup.vim git-svn-id: https://vimsuite.svn.sourceforge.net/svnroot/vimsuite/trunk@147 eb2d0018-73a3-4aeb-bfe9-1def61c9ec69 --- vimfiles.damos/ftplugin/kgs.vim | 2 +- vimfiles.damos/syntax/damos.vim | 11 +- vimfiles.damos/syntax/kgs.vim | 1 + vimfiles.stefan/ftplugin/vim.vim | 2 +- vimfiles.stefan/plugin/changelog.vim | 4 + vimfiles.stefan/spell/bmsk.add | 64 + vimfiles.stefan/spell/bmsk.add.spl | Bin 4217 -> 4819 bytes vimfiles/GetLatest/GetLatestVimScripts.dat | 15 +- vimfiles/autoload/netrw.vim | 4242 +++++++++++++------- vimfiles/autoload/netrwSettings.vim | 24 +- vimfiles/doc/pi_netrw.txt | 2373 ++++++----- vimfiles/doc/tComment.txt | 69 +- vimfiles/doc/tags | 36 +- vimfiles/plugin/blockdiff.vim | 86 + vimfiles/plugin/netrwPlugin.vim | 12 +- vimfiles/plugin/svndiff.vim | 108 +- vimfiles/plugin/tComment.vim | 281 +- vimfiles/plugin/vgrepsup.vim | 76 + vimfiles/syntax/netrw.vim | 144 +- 19 files changed, 4799 insertions(+), 2751 deletions(-) create mode 100644 vimfiles/plugin/blockdiff.vim create mode 100644 vimfiles/plugin/vgrepsup.vim diff --git a/vimfiles.damos/ftplugin/kgs.vim b/vimfiles.damos/ftplugin/kgs.vim index 8b71d5d..4b4138b 100644 --- a/vimfiles.damos/ftplugin/kgs.vim +++ b/vimfiles.damos/ftplugin/kgs.vim @@ -29,7 +29,7 @@ setlocal expandtab "set cindent setlocal cinoptions=*200,)100,(s,w1 let &l:shiftwidth = tabwidth -setlocal formatoptions=croq +setlocal formatoptions=wan2croql setlocal formatexpr=KgsFormat() " commenting diff --git a/vimfiles.damos/syntax/damos.vim b/vimfiles.damos/syntax/damos.vim index 4e8c1a6..e141e15 100644 --- a/vimfiles.damos/syntax/damos.vim +++ b/vimfiles.damos/syntax/damos.vim @@ -25,13 +25,20 @@ syn keyword damosFunction einstelleSprache oeffneOSp liesBezeichner oeffnePV syn keyword damosFunction liesAdressDatei anlegeDatenstand syn keyword damosFunction liesKonservierung speichere schreibeHexDatei syn keyword damosFunction schreibeASAP_AgIAsw -syn keyword damosFunction kdoOTypCheck ausfuehreTrans pruefeAutoRam +syn keyword damosFunction kdoOTypCheck ausfuehre ausfuehreTrans pruefeAutoRam syn keyword damosFunction pruefeFktKonsistenz schreibeFhlListAusFktKonsPruef syn keyword damosFunction oeffneQuellDatenstand fuelleAusTestwerte syn keyword damosFunction definiereSGGrAuswahl anlegeAsw entferneAsw schneideAsw syn keyword damosFunction schliesseAsw setzeUmfang schreibeDatenquelle syn keyword damosFunction schreibeFktIncludeAbh anlegeOSp importiereObjekte -syn keyword damosFunction schliesseOSp +syn keyword damosFunction anlegeProjekt anlegePV liesDefBase +syn keyword damosFunction schliesseOSp schliesseQuellDatenstand +syn keyword damosFunction anzeigeVarKod liefereName +syn keyword damosFunction pruefeAblKonsistenz pruefeBezeichnerListe +syn keyword damosFunction pruefeRefInfo pruefeSpeicherbereiche +syn keyword damosFunction pruefeMinPMaxP pruefeVarKod vater +syn keyword damosFunction schreibeFhlListAusBezKonsPruef schreibeFktIncludeAsw + syn keyword damosCommand exit Dam DAMOS quellDst syn match damosSeperator "[<>,:]" diff --git a/vimfiles.damos/syntax/kgs.vim b/vimfiles.damos/syntax/kgs.vim index 5d23dcf..438223e 100644 --- a/vimfiles.damos/syntax/kgs.vim +++ b/vimfiles.damos/syntax/kgs.vim @@ -13,6 +13,7 @@ syntax keyword kgsDefinitions fkt_bezeichner kgs_bezeichner ram_bezeichner syntax keyword kgsDefinitions ram_groesse lok_ram_groesse kennwert kennlinie syntax keyword kgsDefinitions gruppenkennlinie gruppenkennfeld gruppenstuetzstellen syntax keyword kgsDefinitions kennfeld kennwerteblock systemkonstante festkennlinie +syntax keyword kgsDefinitions kenngroessen_gruppe ramgroessen_gruppe syntax keyword kgsRefgroessen ref_ram_groesse ref_kenngroesse syntax keyword kgsKomponents umrechnung codesyntax datentyp adressierschema syntax keyword kgsKomponents bitanzahl element_anzahl bitbasis_typ bitposition diff --git a/vimfiles.stefan/ftplugin/vim.vim b/vimfiles.stefan/ftplugin/vim.vim index 03fc8e0..b12c43f 100644 --- a/vimfiles.stefan/ftplugin/vim.vim +++ b/vimfiles.stefan/ftplugin/vim.vim @@ -10,7 +10,7 @@ setlocal softtabstop=4 setlocal formatoptions=croq " vimfiles sollen immer im unix-Format gespeichert werden -if filewritable(expand('%')) +if &modifiable setlocal fileformat=unix endif diff --git a/vimfiles.stefan/plugin/changelog.vim b/vimfiles.stefan/plugin/changelog.vim index a452956..b43e475 100644 --- a/vimfiles.stefan/plugin/changelog.vim +++ b/vimfiles.stefan/plugin/changelog.vim @@ -14,6 +14,10 @@ if exists('nochangelog') endif function s:ReportRev(Rev) + if a:Rev >= '145' + echo 'Neu seit Rev: 145' + echo 'BlockDiff: Markieren -> BlockDiff -> Markieren -> BlockDiff -> neuer Tab' + echo 'Gsub: global substitute' if a:Rev >= '139' echo 'Neu seit Rev: 129' echo 'Projekt laden über project.vim' diff --git a/vimfiles.stefan/spell/bmsk.add b/vimfiles.stefan/spell/bmsk.add index c1663c6..aa87d12 100644 --- a/vimfiles.stefan/spell/bmsk.add +++ b/vimfiles.stefan/spell/bmsk.add @@ -323,3 +323,67 @@ disk false true copy_FCMTabEntryType +brief +author +date +Ramgrößen +lint +Ramwert +Adaptionswertes +restore +Adaptionswert +Adaptionsgrößen +Adaptionswerten +ref +ram +bezeichner +groesse +RaMNonVolatileRamU16 +umrechnung +dez +Initialisierungswert +kennwert +KgMKwWU16 +uint16 +Doxygen +doku +page +Fahrsoftware +section +Adaptionsvorgänge +create +li +Ramgröße +code +wertp +endcode +include +b +Init +Objektspeicher +Desc +Preprozessor +Description +Hint +BMSX +Mainpage +Developersguide +Entwicklerdoku +mainpage +image +html +jpg +Developers +Guide +Library +BDL +Coding +Guidelines +Applikationsdaten +subsection +check +subsubsection +Applikationslabel +Codesyntaxen +shade +Headers diff --git a/vimfiles.stefan/spell/bmsk.add.spl b/vimfiles.stefan/spell/bmsk.add.spl index c22d5a6b5594a88cd9e2006f5a1b57a556a64e02..1dbc64f7f5a43a08465bfb10bd01eb00226ce3b1 100644 GIT binary patch literal 4819 zcmZWsONd-q89wK~Rh_QR;9`*Yz*!WHt};U=nAp}rkeGp)OeAC`ozYoTZqq>~7#&#kS zdLoVnge{g^d{W(R?c64KD)fkNa|v5;=c}+my+rr^!y;g#vZsh;SB^) zz+Y5}Kxuoh!P-^~wR14bVCa$hLy;iKTP%TOo6996hWN*O#P!*dwG-1V-wIt^8*}-~a_wh@ElBHHD-a?5Q-K46qg3{rTGMNO_aSYhN;YDY@ z3nR^-tsYXRHiE1Imbq}Etqs;Yd~y1>H2@6NS>zQ8tzjgqpws1=@#kS$DaKI&^yE>; zb6b@r2c8aGycKJ+sBU-2WFG|5^-v2Y3t&gSi6InBiqe@r0R+fO`rKtS$lj^2p97Mb zPyq-K#PFp{h`_e$hO7ezW+aTh=X+tc%O{iDUW^N;4#3Ndz68_2$9Y#phyXJ}(V0Y0 zh4?!}Dn}hL)o^M%e!=)boU&FmEu)NSrU^dYv8nj9ib!}ro2jElQiY?&^2HC1K;PAqM$KtS13b1_;%Z%|G;Dh5gco@rPd@tw#?4Ns?WBDnKqC1f2 z3jo6Ur8xaQz`qtP345RzC~8l9<{Onp+KSHt830`_u+%}N~G<4&P`X<0iaG8iqN&Iy}|E!)!@Y<KORP|MQ>2%xZ2$C6;Y zQgmvW853YEjH80(jkYqs&)Zk+IeUh(54OZt5FW*9%`!uw2GeQP4kElIB!7^v%_9^x z<9)sARH~1}CgUe;8I6X^am=|?V<*~2d@}X8$3E_Th?)ogq)UWXy?!N;jh6Ok=sZT% z4FRgYyw8}E+x1Bqoc-pvVBKgM#RyIC{AfYzC+GOXs&n)!CF}c==bZ*mOip{Fkpfg> zI%$DV4_xqma31xCnek5<^K~)(_GQ4J~JS&_q^sm$oNfc3ol2zQf|UiV3Ptqh?TA zyV(TE9^tgtrc$;Vj#PX#cQE8!)D-Hv(bN~z$bM-R(~_a%`RFB#9cMIa>rv!MR4YQO zgd}n_*`*-Nc|Y?I8n9;vV)wz(b%EgrnK#4sk8773!A(REK$6pQvT9*0;Z!RgB-F~a zf2u&?B!aAm+KL{OC*WI554}gEBCvTBb7}?P_G1F*I+z;?ymp48qiJA$DamEPcU+RJ%~8=OgUUmAkqhVIQXqJQr5|GpNgx+@GU>V|uD!vYV8tY_-N< zJ&59)HBp9|cU%wm;le^v*CO56XJ3S=;)B;qt7g+;;Prv!+MiTy^MrGT^9d^47un^8 zclJBlbhg+(RP#*~fd#9Z`Mk0+7|MY5 zd2Llo0z_1s|7{Sfe00MnqX8Ox>JLm@0-9}ip~2Gl6X?R!q(-jKx@!nsw)WFv&Bqvk zV99SWF-WRo!gx=g>1U2kFyrcSnEL?{agoq^RqMthd6xn(Cjdce%1ML*hNpO!VjyDr z)s@k-{DOIvfj66LLf|ULx4f#me$ReeP!l-Jaui|3lG~|GJiny+>=xvrzWIy|?Eh+z zXxU?z#?i-wj&;ZNRw^?5VT1V!URrx69KiDR3s3@6A6=-~;TbJYoMz}fGvV9PuXRL8M5|OlCh}Nudv@iP>fXqomM!o+M|rY?3j5 zUqSa8O>1IGHxk!bR5U|dmvS6@l_i%**VseepkQttv zlxP)THr&qX0|Euke}Kc*jSt0c%z!#ZQe&PXA#ngt|AN6AziL%GSMoOAOCXoyiq4#4 z))aZvYpU2M&?3cHjf))aZ|Y+0h2!(!z)^-pQ%)y%c6UbN!9bvOuH?JSYV9ph4!_f@ z@z4qCFa;6wKgZZ7dBXx~q8|D2-{S^r#;UYIiX~+i5PQLjO>3mAtcZ+Zm~@ndX=9@(8I7%pk_Zzy_3m<2SCy-( z=Ou(@(Gm*~NG!mLlqf40A$I%#7Lica*|70)WQhflSg^AM=X|$&W&n+*>v8Y>Ugvy| zdjIX+u1U)B*1wI}c$}cIc8a^1t_8M~q=Tg19%4ge z3tQ?oIn_(fU5msE;uH(Vkdo-R7SbvE?=YjavF@Ei4BqWzu%v{r0=8dR2*12g$5%=XMS=X;Z0Yclt!YhQKhd%tv*9uO$T zyjNotOTo@@#h(^%QY1u}aSy|$FrWD7^M;}7;UtWvWz8EB3YSAH4=1D=gGI6&Nr^^%ud9A$7E*K_9;ajW1L-t5dF@R3d7?+kW3@aRd4 z_dWix=a-GpI`WF5?el8Q1W}UL9z~}!4bD!jEXA9Jqr=P()8@cw8B;&Z7K8P1Cx)CM zGbv!CDos15|UXl{vcqB$D!{#ffx6H59ljmqg1*>#DGN97k`X# z)mk9Q+_n-EeY=ZHkl-BZV-e*X3kM>+e4>%^Y9$f9^IoYXsa4DrQNqgSj2<|rb%AbN z)CMgH*-}bk8y+OV3Ed2y;_!E4eM9&depZqKYYNDs@Po3R!#5@AD8cK_PQ{SX8kL}L80poatbHfSS5DhjXhL6{D#dm~-E^TXx&N&K-+4mPLbQk^ykNXjMd0yq$92 z({d1{W!*#7a1t;Dp>u;ZwpFw*DdTd3mHPzrVy@!wrT=!;*O0Sr^uI1Vq@gjCi2{tLl z&^15eT|s`J@$*kxFNAlfp3p+*7(NEVo`uWAVVG!sF$e(E=NZgHH0FL@pt2KEF4kH^ zHIrC$R;bZVdJw`wt@2}JS&9?#buLwh6$iwsosta>*O}S^Oa+yPsk+JoA}r5ZF@)H8 z=z8Ij8xKVf^E*nj&WQre?2nmHdz;H(Bo%p3I0FP93?^=9Pn86gRGp} zP^M7#*V0lL=`CO8s8%@6QRv)NkUcgIZBct{al?l`zZuy;rXhz;tvFK9MPy7kj+tb#je#v zyDBs;X$U%ez8?&NsC+`&5>#!CBhEVPuPmBqeTa&I4_ef|N!J{Lozyf4TCX$nxiP{L z2Shg|_@@*|P=}N1WwXU=7%5LPkO{@JZuNW4!wBd>b z9i-ArJ}NY?B^Pi|4@VU0^-nX&W@3P`lq^%M!_0B^Pc5E%Ofuv+9p@R!Bwx(9;CS~M znlt84MiGwwhLJqM4uWv`4FUe%sk{Kjum9ZHj+3JZ(g?}=ZBn9vI&vSvb8ovS1Py66ClLK(ioiVajhY2;wVcaHI6W7kTEgg^@bMhRZKa^hb&3FzCv} zrV#r(EQ=(p|Hyr6xK>D~)UZ)+jQQf)ogdzP`<;&+7Sg~q52Lm??d)MB%I`(Y7Vc*3N#Ixw{Xut`3VDs7(fpyr8fILL2?Mx(C&}_B}=MuAbx9)qC#i>eB`;8}lCk CeI#@M diff --git a/vimfiles/GetLatest/GetLatestVimScripts.dat b/vimfiles/GetLatest/GetLatestVimScripts.dat index 401af0f..a494d77 100644 --- a/vimfiles/GetLatest/GetLatestVimScripts.dat +++ b/vimfiles/GetLatest/GetLatestVimScripts.dat @@ -1,7 +1,6 @@ ScriptID SourceID Filename -------------------------- -642 7080 GetLatestVimScripts.vim -1075 7079 netrw.vim +1075 7738 netrw.vim 1502 7078 vimball.vim 1008 3118 srec.vim (ftplugin) 1009 3119 srec.vim (syntax file) @@ -12,12 +11,18 @@ ScriptID SourceID Filename 51 171 cscope_macros.vim 102 5306 DirDiff.vim 1189 6533 matrix.vim -1173 7046 tcomment +1173 7588 tcomment 948 2878 Scons Compiler plugin 1709 6421 Scons Syntax file 1772 7248 DAMOS.zip DAMOS tools (von Stefan) 987 6978 DoxygenToolkit.vim 1397 6887 xml.vim -1290 5190 LogiPat -1881 7244 svndiff +1290 5190 LogiPat.vim +1881 7505 svndiff 1462 5612 dtd2xml +1046 4249 Lusty Explorer +2043 7805 VimPdb (debugging python) +1776 7810 Vimgrep Replace +2048 7815 BlockDiff +642 7080 getscript.vim +642 7080 :AutoInstall: GetLatestVimScripts.vim diff --git a/vimfiles/autoload/netrw.vim b/vimfiles/autoload/netrw.vim index b4753c2..6d8a5cb 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: May 05, 2007 -" Version: 109 +" Date: Oct 02, 2007 +" Version: 114 " Maintainer: Charles E Campbell, Jr " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 1999-2007 Charles E. Campbell, Jr. {{{1 @@ -30,7 +30,7 @@ if !exists("s:NOTE") let s:WARNING = 1 let s:ERROR = 2 endif -let g:loaded_netrw = "v109" +let g:loaded_netrw = "v114" 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 @@ -115,6 +115,18 @@ endif " --------------------------------------------------------------------- " Default values for netrw's global variables {{{2 +" Cygwin Detection ------- {{{3 +if !exists("g:netrw_cygwin") + if has("win32") || has("win95") || has("win64") || has("win16") + if &shell =~ '\%(\\|\\)\%(\.exe\)\=$' + let g:netrw_cygwin= 1 + else + let g:netrw_cygwin= 0 + endif + else + let g:netrw_cygwin= 0 + endif +endif " Default values - a-c ---------- {{{3 if !exists("g:netrw_alto") let g:netrw_alto= &sb @@ -128,23 +140,16 @@ endif if !exists("g:netrw_chgwin") let g:netrw_chgwin = -1 endif -if !exists("g:netrw_cygwin") - if has("win32") || has("win95") || has("win64") || has("win16") - if &shell =~ '\%(\\|\\)\%(\.exe\)\=$' - let g:netrw_cygwin= 1 - else - let g:netrw_cygwin= 0 - endif - else - let g:netrw_cygwin= 0 - endif -else - let g:netrw_cygwin= 0 +if !exists("g:netrw_compress") + let g:netrw_compress= "gzip" endif " Default values - d-f ---------- {{{3 if !exists("g:NETRW_DIRHIST_CNT") let g:NETRW_DIRHIST_CNT= 0 endif +if !exists("g:netrw_decompress") + let g:netrw_decompress= { ".gz" : "gunzip" , ".bz2" : "bunzip2" , ".zip" : "unzip" , ".tar" : "tar -xf"} +endif if !exists("g:netrw_dirhistmax") let g:netrw_dirhistmax= 10 endif @@ -198,9 +203,35 @@ if !exists("g:netrw_list_hide") let g:netrw_list_hide= "" endif " Default values - lh-lz ---------- {{{3 +if !exists("g:netrw_localcopycmd") + if has("win32") || has("win95") || has("win64") || has("win16") + if g:netrw_cygwin + let g:netrw_localcopycmd= "cp" + else + let g:netrw_localcopycmd= "copy" + endif + elseif has("unix") || has("macunix") + let g:netrw_localcopycmd= "cp" + else + let g:netrw_localcopycmd= "" + endif +endif if !exists("g:netrw_local_mkdir") let g:netrw_local_mkdir= "mkdir" endif +if !exists("g:netrw_localmovecmd") + if has("win32") || has("win95") || has("win64") || has("win16") + if g:netrw_cygwin + let g:netrw_localcopycmd= "mv" + else + let g:netrw_localcopycmd= "move" + endif + elseif has("unix") || has("macunix") + let g:netrw_localcopycmd= "mv" + else + let g:netrw_localcopycmd= "" + endif +endif if !exists("g:netrw_local_rmdir") let g:netrw_local_rmdir= "rmdir" endif @@ -224,6 +255,19 @@ endif if !exists("g:netrw_mkdir_cmd") let g:netrw_mkdir_cmd= g:netrw_ssh_cmd." USEPORT HOSTNAME mkdir" endif +if !exists("g:netrw_mousemaps") + if exists("&mouse") && &mouse =~ '[anh]' + let g:netrw_mousemaps= 1 + else + let g:netrw_mousemaps= 0 + endif +endif +if !exists("g:netrw_noretmap") + let g:netrw_noretmap= 0 +endif +if !exists("g:netrw_preview") + let g:netrw_preview= 0 +endif if !exists("g:netrw_scpport") let g:netrw_scpport= "-P" endif @@ -287,6 +331,9 @@ else let g:netrw_use_noswf= 0 endif " Default values - t-w ---------- {{{3 +if !exists("g:netrw_ctags") + let g:netrw_ctags= "ctags" +endif if !exists("g:netrw_timefmt") let g:netrw_timefmt= "%c" endif @@ -304,8 +351,8 @@ if !exists("g:netrw_winsize") endif " --------------------------------------------------------------------- " Default values for netrw's script variables: {{{2 -if !exists("s:netrw_cd_escape") - let s:netrw_cd_escape="[]#*$%'\" ?`!&();<>\\" +if !exists("g:netrw_cd_escape") + let g:netrw_cd_escape="[]#*$%'\" ?`!&();<>\\" endif if !exists("g:netrw_fname_escape") let g:netrw_fname_escape= ' ?&;' @@ -327,9 +374,9 @@ endif " ============================== " ------------------------------------------------------------------------ -" NetSavePosn: saves position of cursor on screen {{{2 -fun! netrw#NetSavePosn() -" call Dfunc("netrw#NetSavePosn()") +" 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(".") @@ -339,20 +386,28 @@ fun! netrw#NetSavePosn() norm! H0 let w:netrw_hline= line(".") - call netrw#NetRestorePosn() -" call Dret("netrw#NetSavePosn : winnr=".w:netrw_winnr." line=".w:netrw_line." col=".w:netrw_col." hline=".w:netrw_hline) + " 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 " ------------------------------------------------------------------------ -" NetRestorePosn: restores the cursor and file position as saved by NetSavePosn() {{{2 -fun! netrw#NetRestorePosn() -" call Dfunc("netrw#NetRestorePosn() 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)) +" 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") @@ -377,108 +432,112 @@ fun! netrw#NetRestorePosn() endif let &ei= eikeep -" call Dret("netrw#NetRestorePosn") +" call Dret("netrw#NetrwRestorePosn") endfun -" =============================== -" NetOptionSave: save options and set to "standard" form {{{2 -"DechoTabOn -fun! s:NetOptionSave() -" call Dfunc("s:NetOptionSave() win#".winnr()." buf#".bufnr(".")) - if !exists("w:netrw_optionsave") - let w:netrw_optionsave= 1 +" --------------------------------------------------------------------- +" 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 +" and NetWrite, or after the s:NetrwEnew() call in +" 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(".")) + if !exists("{a:vt}netrw_optionsave") + let {a:vt}netrw_optionsave= 1 +" call Decho(a:vt."netrw_optionsave=".{a:vt}netrw_optionsave) else -" call Dret("s:NetOptionSave : netoptionsave=".w:netrw_optionsave) +" call Dret("s:NetrwOptionSave : netoptionsave=".{a:vt}netrw_optionsave." (options already saved)") return endif " Save current settings and current directory let s:yykeep = @@ if exists("&l:acd") - let w:netrw_acdkeep = &l:acd + let {a:vt}netrw_acdkeep = &l:acd endif - let w:netrw_aikeep = &l:ai - let w:netrw_awkeep = &l:aw - let w:netrw_cikeep = &l:ci - let w:netrw_cinkeep = &l:cin - let w:netrw_cinokeep = &l:cino - let w:netrw_comkeep = &l:com - let w:netrw_cpokeep = &l:cpo + let {a:vt}netrw_aikeep = &l:ai + let {a:vt}netrw_awkeep = &l:aw + let {a:vt}netrw_cikeep = &l:ci + let {a:vt}netrw_cinkeep = &l:cin + let {a:vt}netrw_cinokeep = &l:cino + let {a:vt}netrw_comkeep = &l:com + let {a:vt}netrw_cpokeep = &l:cpo if g:netrw_keepdir - let w:netrw_dirkeep = getcwd() + let {a:vt}netrw_dirkeep = getcwd() endif - let w:netrw_fokeep = &l:fo " formatoptions - let w:netrw_gdkeep = &l:gd " gdefault - let w:netrw_hidkeep = &l:hidden - let w:netrw_magickeep = &l:magic - let w:netrw_repkeep = &l:report - let w:netrw_spellkeep = &l:spell - let w:netrw_twkeep = &l:tw " textwidth - let w:netrw_wigkeep = &l:wig " wildignore + let {a:vt}netrw_fokeep = &l:fo " formatoptions + let {a:vt}netrw_gdkeep = &l:gd " gdefault + let {a:vt}netrw_hidkeep = &l:hidden + let {a:vt}netrw_magickeep = &l:magic + let {a:vt}netrw_repkeep = &l:report + let {a:vt}netrw_spellkeep = &l:spell + let {a:vt}netrw_twkeep = &l:tw " textwidth + let {a:vt}netrw_wigkeep = &l:wig " wildignore if has("win32") && !has("win95") - let w:netrw_swfkeep= &l:swf " swapfile + let {a:vt}netrw_swfkeep= &l:swf " swapfile endif - call s:NetrwSafeOptions() - if &go =~ 'a' | silent! let w:netrw_regstar = @* | endif - silent! let w:netrw_regslash= @/ + if &go =~ 'a' | silent! let {a:vt}netrw_regstar = @* | endif + silent! let {a:vt}netrw_regslash= @/ +" call s:NetrwSafeOptions() -" call Dret("s:NetOptionSave") -" call Dret("s:NetOptionSave : win#".winnr()." buf#".bufnr(".")) +" call Dret("s:NetrwOptionSave : win#".winnr()." buf#".bufnr(".")) endfun " ------------------------------------------------------------------------ -" NetOptionRestore: restore options {{{2 -fun! s:NetOptionRestore() -" call Dfunc("s:NetOptionRestore() win#".winnr()." buf#".bufnr(".")) - if !exists("w:netrw_optionsave") -" call Dret("s:NetOptionRestore : w:netrw_optionsave doesn't exist") +" s:NetrwOptionRestore: restore options {{{2 +fun! s:NetrwOptionRestore(vt) +" call Dfunc("s:NetrwOptionRestore(vt<".a:vt.">) win#".winnr()." buf#".bufnr(".")) + if !exists("{a:vt}netrw_optionsave") +" call Dret("s:NetrwOptionRestore : {a:vt}netrw_optionsave doesn't exist") return endif - unlet w:netrw_optionsave + unlet {a:vt}netrw_optionsave if exists("&acd") - if exists("w:netrw_acdkeep") |let &l:acd = w:netrw_acdkeep |unlet w:netrw_acdkeep |endif + if exists("{a:vt}netrw_acdkeep") |let &l:acd = {a:vt}netrw_acdkeep |unlet {a:vt}netrw_acdkeep |endif endif - if exists("w:netrw_aikeep") |let &l:ai = w:netrw_aikeep |unlet w:netrw_aikeep |endif - if exists("w:netrw_awkeep") |let &l:aw = w:netrw_awkeep |unlet w:netrw_awkeep |endif - if exists("w:netrw_cikeep") |let &l:ci = w:netrw_cikeep |unlet w:netrw_cikeep |endif - if exists("w:netrw_cinkeep") |let &l:cin = w:netrw_cinkeep |unlet w:netrw_cinkeep |endif - if exists("w:netrw_cinokeep") |let &l:cino = w:netrw_cinokeep |unlet w:netrw_cinokeep |endif - if exists("w:netrw_comkeep") |let &l:com = w:netrw_comkeep |unlet w:netrw_comkeep |endif - if exists("w:netrw_cpokeep") |let &l:cpo = w:netrw_cpokeep |unlet w:netrw_cpokeep |endif - if exists("w:netrw_dirkeep") |exe "lcd ".w:netrw_dirkeep |unlet w:netrw_dirkeep |endif - if exists("w:netrw_fokeep") |let &l:fo = w:netrw_fokeep |unlet w:netrw_fokeep |endif - if exists("w:netrw_gdkeep") |let &l:gd = w:netrw_gdkeep |unlet w:netrw_gdkeep |endif - if exists("w:netrw_hidkeep") |let &l:hidden = w:netrw_hidkeep |unlet w:netrw_hidkeep |endif - if exists("w:netrw_magic") |let &l:magic = w:netrw_magic |unlet w:netrw_magic |endif - if exists("w:netrw_repkeep") |let &l:report = w:netrw_repkeep |unlet w:netrw_repkeep |endif - if exists("w:netrw_spellkeep")|let &l:spell = w:netrw_spellkeep |unlet w:netrw_spellkeep|endif - if exists("w:netrw_twkeep") |let &l:tw = w:netrw_twkeep |unlet w:netrw_twkeep |endif - if exists("w:netrw_wigkeep") |let &l:wig = w:netrw_wigkeep |unlet w:netrw_wigkeep |endif - if exists("s:yykeep") |let @@ = s:yykeep |unlet s:yykeep |endif - if exists("w:netrw_swfkeep") + if exists("{a:vt}netrw_aikeep") |let &l:ai = {a:vt}netrw_aikeep |unlet {a:vt}netrw_aikeep |endif + if exists("{a:vt}netrw_awkeep") |let &l:aw = {a:vt}netrw_awkeep |unlet {a:vt}netrw_awkeep |endif + if exists("{a:vt}netrw_cikeep") |let &l:ci = {a:vt}netrw_cikeep |unlet {a:vt}netrw_cikeep |endif + if exists("{a:vt}netrw_cinkeep") |let &l:cin = {a:vt}netrw_cinkeep |unlet {a:vt}netrw_cinkeep |endif + 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_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 + if exists("{a:vt}netrw_magic") |let &l:magic = {a:vt}netrw_magic |unlet {a:vt}netrw_magic |endif + if exists("{a:vt}netrw_repkeep") |let &l:report = {a:vt}netrw_repkeep |unlet {a:vt}netrw_repkeep |endif + if exists("{a:vt}netrw_spellkeep")|let &l:spell = {a:vt}netrw_spellkeep |unlet {a:vt}netrw_spellkeep|endif + if exists("{a:vt}netrw_twkeep") |let &l:tw = {a:vt}netrw_twkeep |unlet {a:vt}netrw_twkeep |endif + if exists("{a:vt}netrw_wigkeep") |let &l:wig = {a:vt}netrw_wigkeep |unlet {a:vt}netrw_wigkeep |endif + if exists("s:yykeep") |let @@ = s:yykeep |unlet s:yykeep |endif + if exists("{a:vt}netrw_swfkeep") if &directory == "" " user hasn't specified a swapfile directory; " netrw will temporarily set the swapfile directory " to the current directory as returned by getcwd(). let &l:directory = getcwd() - silent! let &l:swf = w:netrw_swfkeep + silent! let &l:swf = {a:vt}netrw_swfkeep setlocal directory= - unlet w:netrw_swfkeep - elseif &l:swf != w:netrw_swfkeep + unlet {a:vt}netrw_swfkeep + elseif &l:swf != {a:vt}netrw_swfkeep " following line causes a Press ENTER in windows -- can't seem to work around it!!! (COMBAK) - silent! let &l:swf= w:netrw_swfkeep - unlet w:netrw_swfkeep + silent! let &l:swf= {a:vt}netrw_swfkeep + unlet {a:vt}netrw_swfkeep endif endif - if exists("w:netrw_regstar") |silent! let @*= w:netrw_regstar |unlet w:netrw_regstar |endif - if exists("w:netrw_regslash")|silent! let @/= w:netrw_regslash|unlet w:netrw_regslash|endif + if exists("{a:vt}netrw_regstar") |silent! let @*= {a:vt}netrw_regstar |unlet {a:vt}netrw_regstar |endif + if exists("{a:vt}netrw_regslash")|silent! let @/= {a:vt}netrw_regslash|unlet {a:vt}netrw_regslash|endif -" call Dret("s:NetOptionRestore : win#".winnr()." buf#".bufnr(".")) +" call Dret("s:NetrwOptionRestore : win#".winnr()." buf#".bufnr(".")) endfun " --------------------------------------------------------------------- -" NetrwSafeOptions: sets options to help netrw do its job {{{2 +" s:NetrwSafeOptions: sets options to help netrw do its job {{{2 fun! s:NetrwSafeOptions() " call Dfunc("s:NetrwSafeOptions()") setlocal cino= @@ -499,12 +558,58 @@ fun! s:NetrwSafeOptions() " call Dret("s:NetrwSafeOptions") endfun +" --------------------------------------------------------------------- +" netrw#NetrwClean: remove netrw {{{2 +" supports :NetrwClean -- remove netrw from first directory on runtimepath +" :NetrwClean! -- remove netrw from all directories on runtimepath +fun! netrw#NetrwClean(sys) +" call Dfunc("netrw#NetrwClean(sys=".a:sys.")") + + if a:sys + let choice= confirm("Remove personal and system copies of netrw?","&Yes\n&No") + else + let choice= confirm("Remove personal copy of netrw?","&Yes\n&No") + endif +" call Decho("choice=".choice) + let diddel= 0 + let diddir= "" + + if choice == 1 + for dir in split(&rtp,',') + if filereadable(dir."/plugin/netrwPlugin.vim") +" call Decho("removing netrw-related files from ".dir) + if s:System("delete",dir."/plugin/netrwPlugin.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/plugin/netrwPlugin.vim",55) |endif + if s:System("delete",dir."/autoload/netrwFileHandlers.vim")|call netrw#ErrorMsg(1,"unable to remove ".dir."/autoload/netrwFileHandlers.vim",55)|endif + if s:System("delete",dir."/autoload/netrwSettings.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/autoload/netrwSettings.vim",55) |endif + if s:System("delete",dir."/autoload/netrw.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/autoload/netrw.vim",55) |endif + if s:System("delete",dir."/syntax/netrw.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/syntax/netrw.vim",55) |endif + if s:System("delete",dir."/syntax/netrwlist.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/syntax/netrwlist.vim",55) |endif + let diddir= dir + let diddel= diddel + 1 + if !a:sys|break|endif + endif + endfor + endif + + echohl WarningMsg + if diddel == 0 + echomsg "netrw is either not installed or not removable" + elseif diddel == 1 + echomsg "removed one copy of netrw from <".diddir.">" + else + echomsg "removed ".diddel." copies of netrw" + endif + echohl None + +" call Dret("netrw#NetrwClean") +endfun + " ------------------------------------------------------------------------ " Netrw Transfer Functions: {{{1 " =============================== " ------------------------------------------------------------------------ -" NetRead: responsible for reading a file over the net {{{2 +" netrw#NetRead: responsible for reading a file over the net {{{2 " mode: =0 read remote file and insert before current line " =1 read remote file and insert after current line " =2 replace with remote file @@ -513,7 +618,8 @@ fun! netrw#NetRead(mode,...) " call Dfunc("netrw#NetRead(mode=".a:mode.",...) a:0=".a:0." ".g:loaded_netrw) " save options {{{3 - call s:NetOptionSave() + call s:NetrwOptionSave("w:") + call s:NetrwSafeOptions() " interpret mode into a readcmd {{{3 if a:mode == 0 " read remote file before current line @@ -572,10 +678,10 @@ fun! netrw#NetRead(mode,...) " call Decho("reconstructing choice") if match(choice,'"$') != -1 " case "..." - let choice=strpart(choice,1,strlen(choice)-2) + let choice=strpart(choice,1,s:Strlen(choice)-2) else " case "... ... ..." - let choice = strpart(choice,1,strlen(choice)-1) + let choice = strpart(choice,1,s:Strlen(choice)-1) let wholechoice = "" while match(choice,'"$') == -1 @@ -590,7 +696,7 @@ fun! netrw#NetRead(mode,...) endif let choice= a:{ichoice} endwhile - let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1) + let choice= strpart(wholechoice,1,s:Strlen(wholechoice)-1) . " " . strpart(choice,0,s:Strlen(choice)-1) endif endif endif @@ -599,14 +705,14 @@ fun! netrw#NetRead(mode,...) let ichoice= ichoice + 1 " Determine method of read (ftp, rcp, etc) {{{3 - call s:NetMethod(choice) + call s:NetrwMethod(choice) let tmpfile= s:GetTempfile(b:netrw_fname) " apply correct suffix - " Check if NetBrowse() should be handling this request -" call Decho("checking if NetBrowse() should handle choice<".choice."> with netrw_list_cmd<".g:netrw_list_cmd.">") + " Check if NetrwBrowse() should be handling this request +" call Decho("checking if NetrwBrowse() should handle choice<".choice."> with netrw_list_cmd<".g:netrw_list_cmd.">") if choice =~ "^.*[\/]$" && b:netrw_method != 5 && choice !~ '^http://' " call Decho("yes, choice matches '^.*[\/]$'") - keepjumps call s:NetBrowse(0,choice) + keepjumps call s:NetrwBrowse(0,choice) " call Dret("netrw#NetRead :3 getcwd<".getcwd().">") return endif @@ -642,7 +748,7 @@ fun! netrw#NetRead(mode,...) endif " call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".uid_machine.":".escape(b:netrw_fname,' ?&;')." ".tmpfile) exe g:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".uid_machine.":".escape(b:netrw_fname,' ?&;')." ".tmpfile - let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) + let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) let b:netrw_lastfile = choice "......................................... @@ -675,7 +781,7 @@ fun! netrw#NetRead(mode,...) let &debug= debugkeep endif bd! - let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) + let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) let b:netrw_lastfile = choice "......................................... @@ -730,7 +836,7 @@ fun! netrw#NetRead(mode,...) endif endif bd! - let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) + let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) let b:netrw_lastfile = choice "......................................... @@ -744,7 +850,7 @@ fun! netrw#NetRead(mode,...) endif " call Decho("executing: !".g:netrw_scp_cmd.useport." '".g:netrw_machine.":".escape(b:netrw_fname,g:netrw_fname_escape)."' ".tmpfile) exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_shq.g:netrw_machine.":".escape(b:netrw_fname,g:netrw_fname_escape).g:netrw_shq." ".tmpfile - let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) + let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) let b:netrw_lastfile = choice "......................................... @@ -764,7 +870,7 @@ fun! netrw#NetRead(mode,...) let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape) " call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_fname) exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_fname - let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) + let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) else " wget plus a jump to an in-page marker (ie. http://abc/def.html#aMarker) @@ -774,7 +880,7 @@ fun! netrw#NetRead(mode,...) " call Decho("netrw_tag <".netrw_tag.">") " call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html) exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html - let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) + let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) " call Decho('<\s*a\s*name=\s*"'.netrw_tag.'"/') exe 'norm! 1G/<\s*a\s*name=\s*"'.netrw_tag.'"/'."\" endif @@ -804,7 +910,7 @@ fun! netrw#NetRead(mode,...) " call Decho("executing: %!".g:netrw_dav_cmd) exe g:netrw_silentxfer."%!".g:netrw_dav_cmd bd! - let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) + let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) let b:netrw_lastfile = choice "......................................... @@ -814,7 +920,7 @@ fun! netrw#NetRead(mode,...) let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape) " call Decho("executing: !".g:netrw_rsync_cmd." ".g:netrw_machine.":".netrw_fname." ".tmpfile) exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".g:netrw_machine.":".netrw_fname." ".tmpfile - let result = s:NetGetFile(readcmd,tmpfile, b:netrw_method) + let result = s:NetrwGetFile(readcmd,tmpfile, b:netrw_method) let b:netrw_lastfile = choice "......................................... @@ -844,7 +950,7 @@ fun! netrw#NetRead(mode,...) exe g:netrw_silentxfer."!".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_machine."/".netrw_fname endif - let result = s:NetGetFile(readcmd,tmpfile, b:netrw_method) + let result = s:NetrwGetFile(readcmd,tmpfile, b:netrw_method) let b:netrw_lastfile = choice setlocal ro @@ -855,7 +961,7 @@ fun! netrw#NetRead(mode,...) let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape) " call Decho("executing: !".g:netrw_sftp_cmd." ".g:netrw_machine.":".netrw_fname." ".tmpfile) exe g:netrw_silentxfer."!".g:netrw_sftp_cmd." ".g:netrw_machine.":".netrw_fname." ".tmpfile - let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) + let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) let b:netrw_lastfile = choice "......................................... @@ -875,19 +981,20 @@ fun! netrw#NetRead(mode,...) " call Decho("cleanup by deleting tmpfile<".tmpfile.">") call s:System("delete",tmpfile) endif - call s:NetOptionRestore() + call s:NetrwOptionRestore("w:") " call Dret("netrw#NetRead :5 getcwd<".getcwd().">") endfun " ------------------------------------------------------------------------ -" NetWrite: responsible for writing a file over the net {{{2 +" netrw#NetWrite: responsible for writing a file over the net {{{2 fun! netrw#NetWrite(...) range " call Dfunc("netrw#NetWrite(a:0=".a:0.") ".g:loaded_netrw) " option handling let mod= 0 - call s:NetOptionSave() + call s:NetrwOptionSave("w:") + call s:NetrwSafeOptions() " Get Temporary Filename {{{3 let tmpfile= s:GetTempfile("") @@ -959,10 +1066,10 @@ fun! netrw#NetWrite(...) range elseif match(choice,"^\"") != -1 if match(choice,"\"$") != -1 " case "..." - let choice=strpart(choice,1,strlen(choice)-2) + let choice=strpart(choice,1,s:Strlen(choice)-2) else " case "... ... ..." - let choice = strpart(choice,1,strlen(choice)-1) + let choice = strpart(choice,1,s:Strlen(choice)-1) let wholechoice = "" while match(choice,"\"$") == -1 @@ -977,7 +1084,7 @@ fun! netrw#NetWrite(...) range endif let choice= a:{ichoice} endwhile - let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1) + let choice= strpart(wholechoice,1,s:Strlen(wholechoice)-1) . " " . strpart(choice,0,s:Strlen(choice)-1) endif endif endif @@ -985,7 +1092,7 @@ fun! netrw#NetWrite(...) range " call Decho("choice<" . choice . "> ichoice=".ichoice) " Determine method of write (ftp, rcp, etc) {{{4 - call s:NetMethod(choice) + call s:NetrwMethod(choice) " ============= " Perform Protocol-Based Write {{{4 @@ -1181,7 +1288,7 @@ fun! netrw#NetWrite(...) range " call Decho("tmpfile<".tmpfile."> readable, will now delete it") call s:System("delete",tmpfile) endif - call s:NetOptionRestore() + call s:NetrwOptionRestore("w:") if a:firstline == 1 && a:lastline == line("$") " restore modifiability; usually equivalent to set nomod @@ -1192,7 +1299,7 @@ fun! netrw#NetWrite(...) range endfun " --------------------------------------------------------------------- -" NetSource: source a remotely hosted vim script {{{2 +" netrw#NetSource: source a remotely hosted vim script {{{2 " uses NetRead to get a copy of the file into a temporarily file, " then sources that file, " then removes that file. @@ -1230,17 +1337,17 @@ fun! netrw#NetSource(...) endfun " =========================================== -" NetGetFile: Function to read temporary file "tfile" with command "readcmd". {{{2 +" s:NetrwGetFile: Function to read temporary file "tfile" with command "readcmd". {{{2 " readcmd == %r : replace buffer with newly read file " == 0r : read file at top of buffer " == r : read file after current line " == t : leave file in temporary form (ie. don't read into buffer) -fun! s:NetGetFile(readcmd, tfile, method) -" call Dfunc("NetGetFile(readcmd<".a:readcmd.">,tfile<".a:tfile."> method<".a:method.">)") +fun! s:NetrwGetFile(readcmd, tfile, method) +" call Dfunc("NetrwGetFile(readcmd<".a:readcmd.">,tfile<".a:tfile."> method<".a:method.">)") " readcmd=='t': simply do nothing if a:readcmd == 't' -" call Dret("NetGetFile : skip read of <".a:tfile.">") +" call Dret("NetrwGetFile : skip read of <".a:tfile.">") return endif @@ -1305,7 +1412,7 @@ fun! s:NetGetFile(readcmd, tfile, method) " not readable " call Decho("tfile<".a:tfile."> not readable") call netrw#ErrorMsg(s:WARNING,"file <".a:tfile."> not readable",9) -" call Dret("NetGetFile : tfile<".a:tfile."> not readable") +" call Dret("NetrwGetFile : tfile<".a:tfile."> not readable") return endif @@ -1326,11 +1433,11 @@ fun! s:NetGetFile(readcmd, tfile, method) " make sure file is being displayed redraw! -" call Dret("NetGetFile") +" call Dret("NetrwGetFile") endfun " ------------------------------------------------------------------------ -" NetMethod: determine method of transfer {{{2 +" s:NetrwMethod: determine method of transfer {{{2 " method == 1: rcp " 2: ftp + <.netrc> " 3: ftp + machine, id, password, and [path]filename @@ -1340,8 +1447,8 @@ endfun " 7: rsync " 8: fetch " 9: sftp -fun! s:NetMethod(choice) " globals: method machine id passwd fname -" call Dfunc("NetMethod(a:choice<".a:choice.">)") +fun! s:NetrwMethod(choice) " globals: method machine id passwd fname +" call Dfunc("NetrwMethod(a:choice<".a:choice.">)") " initialization let b:netrw_method = 0 @@ -1522,7 +1629,7 @@ fun! s:NetMethod(choice) " globals: method machine id passwd fname " call Decho("g:netrw_passwd <".g:netrw_passwd.">") " endif "Decho " call Decho("b:netrw_fname <".b:netrw_fname.">") -" call Dret("NetMethod : b:netrw_method=".b:netrw_method) +" call Dret("NetrwMethod : b:netrw_method=".b:netrw_method) endfun " ------------------------------------------------------------------------ @@ -1583,110 +1690,173 @@ endfun fun! s:BrowserMaps(islocal) " call Dfunc("s:BrowserMaps(islocal=".a:islocal.") b:netrw_curdir<".b:netrw_curdir.">") if a:islocal - nnoremap :call netrw#LocalBrowseCheck(NetBrowseChgDir(1,NetGetWord())) - nnoremap :call netrw#LocalBrowseCheck(NetBrowseChgDir(1,NetGetWord())) - nnoremap :call NetRefresh(1,NetBrowseChgDir(1,'./')) - nnoremap - :exe "norm! 0"call netrw#LocalBrowseCheck(NetBrowseChgDir(1,'../')) - nnoremap a :call NetHide(1) - nnoremap mb :call NetBookmarkDir(0,b:netrw_curdir) - nnoremap gb :call NetBookmarkDir(1,b:netrw_curdir) - nnoremap c :exe "cd ".b:netrw_curdir + nnoremap :call netrw#LocalBrowseCheck(NetrwBrowseChgDir(1,NetrwGetWord())) + nnoremap - :exe "norm! 0"call netrw#LocalBrowseCheck(NetrwBrowseChgDir(1,'../')) + nnoremap a :call NetrwHide(1) + nnoremap mb :call NetrwBookmarkDir(0,b:netrw_curdir) + nnoremap mc :call NetrwMarkFileCopy(1) + nnoremap md :call NetrwMarkFileDiff(1) + nnoremap me :call NetrwMarkFileEdit(1) + nnoremap mf :call NetrwMarkFile(1,NetrwGetWord()) + nnoremap mm :call NetrwMarkFileMove(1) + nnoremap mp :call NetrwMarkFilePrint(1) + nnoremap mr :call NetrwMarkFileRegexp(1) + nnoremap mT :call NetrwMarkFileTag(1) + nnoremap mt :call NetrwMarkFileTgt(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 C :let g:netrw_chgwin= winnr() - nnoremap d :call NetMakeDir("") - nnoremap :call NetHideEdit(1) - nnoremap i :call NetListStyle(1) - nnoremap o :call NetSplit(3) - nnoremap O :call LocalObtain() - nnoremap p :call NetPreview(NetBrowseChgDir(1,NetGetWord(),1)) - nnoremap P :call NetPrevWinOpen(1) - nnoremap q :call NetBookmarkDir(2,b:netrw_curdir) - nnoremap r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'exe "norm! 0"call NetRefresh(1,NetBrowseChgDir(1,'./')) - nnoremap s :call NetSortStyle(1) + nnoremap d :call NetrwMakeDir("") + nnoremap i :call NetrwListStyle(1) + nnoremap o :call NetrwSplit(3) + 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 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) - nnoremap t :call NetSplit(4) - nnoremap u :call NetBookmarkDir(4,expand("%")) - nnoremap U :call NetBookmarkDir(5,expand("%")) - nnoremap v :call NetSplit(5) - nnoremap x :call netrw#NetBrowseX(NetBrowseChgDir(1,NetGetWord(),0),0)" + nnoremap t :call NetrwSplit(4) + nnoremap u :call NetrwBookmarkDir(4,expand("%")) + nnoremap U :call NetrwBookmarkDir(5,expand("%")) + nnoremap v :call NetrwSplit(5) + nnoremap x :call netrw#NetrwBrowseX(NetrwBrowseChgDir(1,NetrwGetWord(),0),0)" + if !hasmapto('NetrwHideEdit') + nmap NetrwHideEdit + endif + nnoremap NetrwHideEdit :call NetrwHideEdit(1) + if !hasmapto('NetrwRefresh') + nmap NetrwRefresh + endif + nnoremap NetrwRefresh :call NetrwRefresh(1,NetrwBrowseChgDir(1,'./')) if s:didstarstar || !mapcheck("","n") nnoremap :Nexplore endif if s:didstarstar || !mapcheck("","n") nnoremap :Pexplore endif - exe 'nnoremap :call LocalBrowseRm("'.b:netrw_curdir.'")' - exe 'vnoremap :call LocalBrowseRm("'.b:netrw_curdir.'")' - exe 'nnoremap :call LocalBrowseRm("'.b:netrw_curdir.'")' - exe 'vnoremap :call LocalBrowseRm("'.b:netrw_curdir.'")' - exe 'nnoremap D :call LocalBrowseRm("'.b:netrw_curdir.'")' - exe 'vnoremap D :call LocalBrowseRm("'.b:netrw_curdir.'")' - exe 'nnoremap R :call LocalBrowseRename("'.b:netrw_curdir.'")' - exe 'vnoremap R :call LocalBrowseRename("'.b:netrw_curdir.'")' - exe 'nnoremap m :call NetMakeDir("")' + if g:netrw_mousemaps == 1 + nnoremap :call NetrwLeftmouse(1) + nnoremap :call NetrwPrevWinOpen(1) + nnoremap :call NetrwMarkFile(1,NetrwGetWord()) + exe 'nnoremap :call NetrwLocalRm("'.b:netrw_curdir.'")' + exe 'vnoremap :call NetrwLocalRm("'.b:netrw_curdir.'")' + if !g:netrw_noretmap + if !hasmapto("NetrwReturn") + nmap <2-leftmouse> NetrwReturn + endif + exe 'nnoremap NetrwReturn :call netrw#LocalBrowseCheck("'.b:netrw_curdir.'")' + endif + endif + exe 'com! Rexplore call netrw#LocalBrowseCheck("'.escape(b:netrw_curdir,g:netrw_cd_escape).'")' + exe 'nnoremap :call NetrwLocalRm("'.b:netrw_curdir.'")' + exe 'vnoremap :call NetrwLocalRm("'.b:netrw_curdir.'")' + exe 'nnoremap D :call NetrwLocalRm("'.b:netrw_curdir.'")' + exe 'vnoremap D :call NetrwLocalRm("'.b:netrw_curdir.'")' + exe 'nnoremap R :call NetrwLocalRename("'.b:netrw_curdir.'")' + exe 'vnoremap R :call NetrwLocalRename("'.b:netrw_curdir.'")' + exe 'nnoremap m :call NetrwMakeDir("")' nnoremap :he netrw-dir else " remote call s:RemotePathAnalysis(b:netrw_curdir) - nnoremap :call NetBrowse(0,NetBrowseChgDir(0,NetGetWord())) - nnoremap :call NetBrowse(0,NetBrowseChgDir(0,NetGetWord())) - nnoremap :call NetRefresh(0,NetBrowseChgDir(0,'./')) - nnoremap - :exe "norm! 0"call NetBrowse(0,NetBrowseChgDir(0,'../')) - nnoremap a :call NetHide(0) - nnoremap mb :call NetBookmarkDir(0,b:netrw_curdir) - nnoremap gb :call NetBookmarkDir(1,b:netrw_cur) + nnoremap :call NetrwBrowse(0,NetrwBrowseChgDir(0,NetrwGetWord())) + nnoremap :call NetrwRefresh(0,NetrwBrowseChgDir(0,'./')) + nnoremap - :exe "norm! 0"call NetrwBrowse(0,NetrwBrowseChgDir(0,'../')) + nnoremap a :call NetrwHide(0) + nnoremap mb :call NetrwBookmarkDir(0,b:netrw_curdir) + nnoremap mc :call NetrwMarkFileCopy(0) + nnoremap md :call NetrwMarkFileDiff(0) + nnoremap me :call NetrwMarkFileEdit(0) + nnoremap mf :call NetrwMarkFile(0,NetrwGetWord()) + nnoremap mm :call NetrwMarkFileMove(0) + nnoremap mp :call NetrwMarkFilePrint(0) + nnoremap mr :call NetrwMarkFileRegexp(0) + nnoremap mT :call NetrwMarkFileTag(0) + nnoremap mt :call NetrwMarkFileTgt(0) + nnoremap mx :call NetrwMarkFileExe(0) + nnoremap mz :call NetrwMarkFileCompress(0) + nnoremap gb :call NetrwBookmarkDir(1,b:netrw_cur) nnoremap C :let g:netrw_chgwin= winnr() - nnoremap :call NetHideEdit(0) - nnoremap i :call NetListStyle(0) - nnoremap o :call NetSplit(0) - nnoremap O :call netrw#NetObtain(0) - vnoremap O :call netrw#NetObtain(1) - nnoremap p :call NetPreview(NetBrowseChgDir(1,NetGetWord(),1)) - nnoremap P :call NetPrevWinOpen(0) - nnoremap q :call NetBookmarkDir(2,b:netrw_curdir) - nnoremap r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'exe "norm! 0"call NetBrowse(0,NetBrowseChgDir(0,'./')) - nnoremap s :call NetSortStyle(0) + 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 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) - nnoremap t :call NetSplit(1) - nnoremap u :call NetBookmarkDir(4,b:netrw_curdir) - nnoremap U :call NetBookmarkDir(5,b:netrw_curdir) - nnoremap v :call NetSplit(2) - nnoremap x :call netrw#NetBrowseX(NetBrowseChgDir(0,NetGetWord()),1) - exe 'nnoremap :call NetBrowseRm("'.s:user.s:machine.'","'.s:path.'")' - exe 'vnoremap :call NetBrowseRm("'.s:user.s:machine.'","'.s:path.'")' - exe 'nnoremap :call NetBrowseRm("'.s:user.s:machine.'","'.s:path.'")' - exe 'vnoremap :call NetBrowseRm("'.s:user.s:machine.'","'.s:path.'")' - exe 'nnoremap d :call NetMakeDir("'.s:user.s:machine.'")' - exe 'nnoremap D :call NetBrowseRm("'.s:user.s:machine.'","'.s:path.'")' - exe 'vnoremap D :call NetBrowseRm("'.s:user.s:machine.'","'.s:path.'")' - exe 'nnoremap R :call NetBrowseRename("'.s:user.s:machine.'","'.s:path.'")' - exe 'vnoremap R :call NetBrowseRename("'.s:user.s:machine.'","'.s:path.'")' + nnoremap t :call NetrwSplit(1) + nnoremap u :call NetrwBookmarkDir(4,b:netrw_curdir) + nnoremap U :call NetrwBookmarkDir(5,b:netrw_curdir) + nnoremap v :call NetrwSplit(2) + nnoremap x :call netrw#NetrwBrowseX(NetrwBrowseChgDir(0,NetrwGetWord()),1) + if !hasmapto('NetrwHideEdit') + nmap NetrwHideEdit + endif + nnoremap NetrwHideEdit :call NetrwHideEdit(0) + if !hasmapto('NetrwRefresh') + nmap NetrwRefresh + endif + nnoremap NetrwRefresh :call NetrwRefresh(0,NetrwBrowseChgDir(0,'./')) + if g:netrw_mousemaps == 1 + nnoremap :call NetrwLeftmouse(0) + nnoremap :call NetrwPrevWinOpen(0) + nnoremap :call NetrwMarkFile(0,NetrwGetWord()) + exe 'nnoremap :call NetrwRemoteRm("'.s:user.s:machine.'","'.s:path.'")' + exe 'vnoremap :call NetrwRemoteRm("'.s:user.s:machine.'","'.s:path.'")' + if !g:netrw_noretmap + if !hasmapto("NetrwReturn") + nmap <2-leftmouse> NetrwReturn + endif + exe 'nnoremap NetrwReturn :call NetrwBrowse(0,"'.b:netrw_curdir.'")' + endif + endif + exe 'com! Rexplore call s:NetrwBrowse(0,"'.escape(b:netrw_curdir,g:netrw_cd_escape).'")' + exe 'nnoremap :call NetrwRemoteRm("'.s:user.s:machine.'","'.s:path.'")' + exe 'vnoremap :call NetrwRemoteRm("'.s:user.s:machine.'","'.s:path.'")' + exe 'nnoremap d :call NetrwMakeDir("'.s:user.s:machine.'")' + exe 'nnoremap D :call NetrwRemoteRm("'.s:user.s:machine.'","'.s:path.'")' + exe 'vnoremap D :call NetrwRemoteRm("'.s:user.s:machine.'","'.s:path.'")' + exe 'nnoremap R :call NetrwRemoteRename("'.s:user.s:machine.'","'.s:path.'")' + exe 'vnoremap R :call NetrwRemoteRename("'.s:user.s:machine.'","'.s:path.'")' nnoremap :he netrw-browse-cmds endif " call Dret("s:BrowserMaps") endfun " --------------------------------------------------------------------- -" s:NetBrowse: This function uses the command in g:netrw_list_cmd to get a list {{{2 +" s:NetrwBrowse: This function uses the command in g:netrw_list_cmd to get a list {{{2 " of the contents of a remote directory. It is assumed that the " g:netrw_list_cmd has a string, USEPORT HOSTNAME, that needs to be substituted " with the requested remote hostname first. -fun! s:NetBrowse(islocal,dirname) +fun! s:NetrwBrowse(islocal,dirname) if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif -" call Dfunc("NetBrowse(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".w:netrw_liststyle." ".g:loaded_netrw." buf#".bufnr("%")."<".bufname("%").">") +" call Dfunc("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("NetBrowse : s:netrw_skipbrowse=".s:netrw_skipbrowse) +" call Dret("NetrwBrowse : s:netrw_skipbrowse=".s:netrw_skipbrowse) return endif - call s:NetOptionSave() + call s:NetrwOptionSave("w:") + + " clear any marked files + if exists("s:netrwmarkfilelist") + unlet s:netrwmarkfilelist + unlet s:netrwmarkfilemtch + 2match none + endif if a:islocal && exists("w:netrw_acdkeep") && w:netrw_acdkeep " call Decho("handle w:netrw_acdkeep:") -" call Decho("cd ".escape(a:dirname,s:netrw_cd_escape)." (due to 'acd')") - exe 'cd '.escape(a:dirname,s:netrw_cd_escape) +" call Decho("cd ".escape(a:dirname,g:netrw_cd_escape)." (due to 'acd')") + exe 'cd '.escape(a:dirname,g:netrw_cd_escape) " call Decho("getcwd<".getcwd().">") elseif !a:islocal && a:dirname !~ '[\/]$' && a:dirname !~ '^"' @@ -1706,18 +1876,18 @@ fun! s:NetBrowse(islocal,dirname) let b:netrw_curdir= a:dirname call s:NetrwSafeOptions() setlocal ma noro -" call Decho("exe silent! keepalt file ".s:method."://".s:user.s:machine."/".escape(s:path,s:netrw_cd_escape)." (bt=".&bt.")") - exe "silent! keepalt file ".s:method."://".s:user.s:machine."/".escape(s:path,s:netrw_cd_escape) +" 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) exe "silent keepalt doau BufReadPre ".s:fname silent call netrw#NetRead(2,s:method."://".s:user.s:machine."/".s:path) exe "silent keepalt doau BufReadPost ".s:fname " save certain window-oriented variables into buffer-oriented variables {{{3 call s:SetBufWinVars() - call s:NetOptionRestore() + call s:NetrwOptionRestore("w:") setlocal nomod nowrap -" call Dret("NetBrowse : file<".s:fname.">") +" call Dret("NetrwBrowse : file<".s:fname.">") return endif @@ -1729,9 +1899,9 @@ fun! s:NetBrowse(islocal,dirname) let dirname = a:dirname let s:last_sort_by = g:netrw_sort_by - call s:NetMenu(1) " set up menu {{{3 - if s:NetGetBuffer(a:islocal,dirname) " set up buffer {{{3 -" call Dret("NetBrowse : re-using buffer") + call s:NetrwMenu(1) " set up menu {{{3 + if s:NetrwGetBuffer(a:islocal,dirname) " set up buffer {{{3 +" call Dret("NetrwBrowse : re-using buffer") return endif @@ -1768,17 +1938,17 @@ fun! s:NetBrowse(islocal,dirname) " handle g:netrw_keepdir: set vim's current directory to netrw's notion of the current directory {{{3 if !g:netrw_keepdir " call Decho("handle keepdir: (g:netrw_keepdir=".g:netrw_keepdir.")") -" call Decho('exe cd '.escape(b:netrw_curdir,s:netrw_cd_escape)) +" call Decho('exe cd '.escape(b:netrw_curdir,g:netrw_cd_escape)) try - exe 'cd '.escape(b:netrw_curdir,s:netrw_cd_escape) + exe 'cd '.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") let b:netrw_curdir= w:netrw_prvdir else - call s:NetOptionRestore() + call s:NetrwOptionRestore("w:") let b:netrw_curdir= dirname -" call Dret("NetBrowse : reusing buffer#".(exists("bufnum")? bufnum : 'N/A')."<".dirname."> getcwd<".getcwd().">") +" call Dret("NetrwBrowse : reusing buffer#".(exists("bufnum")? bufnum : 'N/A')."<".dirname."> getcwd<".getcwd().">") return endif endtry @@ -1812,8 +1982,8 @@ fun! s:NetBrowse(islocal,dirname) if !exists("g:netrw_quiet") call netrw#ErrorMsg(s:ERROR,"netrw doesn't understand your dirname<".dirname.">",20) endif - call s:NetOptionRestore() -" call Dret("NetBrowse : badly formatted dirname<".dirname.">") + call s:NetrwOptionRestore("w:") +" call Dret("NetrwBrowse : badly formatted dirname<".dirname.">") return endif let b:netrw_curdir= dirname @@ -1827,43 +1997,65 @@ fun! s:NetBrowse(islocal,dirname) call s:BrowserMaps(a:islocal) call s:PerformListing(a:islocal) -" call Dret("NetBrowse") +" call Dret("NetrwBrowse") return endfun " --------------------------------------------------------------------- -" s:NetGetBuffer: {{{2 +" s:NetrwGetBuffer: {{{2 " returns 0=cleared buffer " 1=re-used buffer -fun! s:NetGetBuffer(islocal,dirname) -" call Dfunc("s:NetGetBuffer(islocal=".a:islocal." dirname<".a:dirname.">)") +fun! s:NetrwGetBuffer(islocal,dirname) +" call Dfunc("s:NetrwGetBuffer(islocal=".a:islocal." 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 -" call Dret("s:NetGetBuffer : bufnum#".bufnum."") +" call Dret("s:NetrwGetBuffer : bufnum#".bufnum."") return endif 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("findbuf1: bufnum=bufnr('".escape(dirname,'\')."')=".bufnum." (initial)") +" call Decho("bufnr(dirname<".escape(dirname,'\').">)=".bufnum) + if bufnum < 0 && dirname !~ '/$' + " trying appending a trailing / +" 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.">") + 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 + " 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 let buflast = bufnr("$") " call Decho("findbuf2: buflast=".buflast) while ibuf <= buflast - let bname= bufname(ibuf) + 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 bname =~ '^'.dirname.'/\=$' | break | endif + if dirname =~ '^'.bname.'/$' | break | endif let ibuf= ibuf + 1 endwhile if ibuf > buflast @@ -1876,6 +2068,7 @@ fun! s:NetGetBuffer(islocal,dirname) endif " get enew buffer and name it -or- re-use buffer {{{3 +" call Decho("--get enewbuffer and name it -or- re-use buffer--") mark ' if bufnum < 0 || !bufexists(bufnum) " call Decho("get enew buffer") @@ -1885,10 +2078,14 @@ fun! s:NetGetBuffer(islocal,dirname) if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST " call Decho('silent! keepalt file NetrwTreeListing') silent! keepalt file NetrwTreeListing + nnoremap [ :silent call TreeListMove('[') + nnoremap ] :silent call TreeListMove(']') + nnoremap [[ :silent call TreeListMove('[') + nnoremap ]] :silent call TreeListMove(']') else -" call Decho('exe silent! keepalt file '.escape(dirname,s:netrw_cd_escape)) +" call Decho('exe silent! keepalt file '.escape(dirname,g:netrw_cd_escape)) " let v:errmsg= "" " Decho - let escdirname= escape(dirname,s:netrw_cd_escape) + 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)).">") endif @@ -1896,7 +2093,7 @@ fun! s:NetGetBuffer(islocal,dirname) else " Re-use the buffer -" call Decho("re-use buffer:") +" call Decho("re-use buffer#".bufnum.":") let eikeep= &ei set ei=all if getline(2) =~ '^" Netrw Directory Listing' @@ -1909,16 +2106,16 @@ fun! s:NetGetBuffer(islocal,dirname) let &ei= eikeep if line("$") <= 1 call s:NetrwListSettings(a:islocal) -" call Dret("s:NetGetBuffer 0 : re-using buffer#".bufnr("%").", but its empty, so refresh it") +" 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") silent %d call s:NetrwListSettings(a:islocal) -" call Dret("s:NetGetBuffer 0 : re-using buffer#".bufnr("%").", but treelist mode always needs a refresh") +" call Dret("s:NetrwGetBuffer 0 : re-using buffer#".bufnr("%").", but treelist mode always needs a refresh") return 0 else -" call Dret("s:NetGetBuffer 1 : buf#".bufnr("%")) +" call Dret("s:NetrwGetBuffer 1 : buf#".bufnr("%")) return 1 endif endif @@ -1928,611 +2125,24 @@ fun! s:NetGetBuffer(islocal,dirname) " slow 0 D D Deleting a buffer implies it will not be re-used (slow) " med 1 D H " fast 2 H H +" 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,' ') " delete all lines from buffer {{{3 +" call Decho("--delete all lines from buffer--") " call Decho("clear buffer<".expand("%")."> with :%d") keepalt silent! %d -" call Dret("s:NetGetBuffer 0 : buf#".bufnr("%")) +" call Dret("s:NetrwGetBuffer 0 : buf#".bufnr("%")) return 0 endfun " --------------------------------------------------------------------- -" s:NetrwListSettings: {{{2 -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,' ') - if g:netrw_use_noswf - setlocal noswf - endif -" call Dredir("ls!") -" call Decho("exe setlocal ts=".g:netrw_maxfilenamelen) - exe "setlocal ts=".g:netrw_maxfilenamelen - if g:netrw_fastbrowse > a:islocal - setlocal bh=hide - else - setlocal bh=delete - endif -" call Dret("s:NetrwListSettings") -endfun - -" --------------------------------------------------------------------- -" s:PerformListing: {{{2 -fun! s:PerformListing(islocal) -" call Dfunc("s:PerformListing(islocal=".a:islocal.") buf(%)=".bufnr("%")."<".bufname("%").">") - -" 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") - setlocal ma noro - keepjumps %d - endif - - " save current directory on directory history list - call s:NetBookmarkDir(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 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 - endif - exe 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 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 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 - if a:islocal - call s:LocalListing() - else " remote - call s:RemoteListing() - 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:NetListHide() - 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' - 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:NetWideListing() - call s:NetTreeListing(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 '.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:NetOptionRestore() - - " 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(".")).">") -endfun - -" --------------------------------------------------------------------- -" s:NetBrowseChgDir: constructs a new directory based on the current {{{2 -" directory and a new directory name -fun! s:NetBrowseChgDir(islocal,newdir,...) -" call Dfunc("s:NetBrowseChgDir(islocal=".a:islocal."> newdir<".a:newdir.">) a:0=".a:0." curpos<".string(getpos("."))."> b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "").">") - - if !exists("b:netrw_curdir") -" call Decho("(NetBrowseChgDir) b:netrw_curdir doesn't exist!") - echoerr "(NetBrowseChgDir) b:netrw_curdir doesn't exist!" -" call Dret("s:NetBrowseChgDir") - return - endif - - call netrw#NetSavePosn() - let nbcd_curpos = getpos('.') - let dirname = substitute(b:netrw_curdir,'\\','/','ge') - let newdir = a:newdir - - " set up o/s-dependent directory recognition pattern - if has("amiga") - let dirpat= '[\/:]$' - else - let dirpat= '[\/]$' - endif -" call Decho("dirname<".dirname."> dirpat<".dirpat.">") - - if dirname !~ dirpat - " apparently vim is "recognizing" that it is in a directory and - " is removing the trailing "/". Bad idea, so I have to put it back. - let dirname= dirname.'/' -" call Decho("adjusting dirname<".dirname.">") - endif - - if newdir !~ dirpat - " handling a file -" 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:NetTreeDir().newdir -" call Decho("tree listing") - elseif newdir =~ '^\(/\|\a:\)' - let dirname= newdir - else - let dirname= s:ComposePath(dirname,newdir) - endif -" call Decho("handling a file: dirname<".dirname."> (a:0=".a:0.")") - " this lets NetBrowseX avoid the edit - if a:0 < 1 -" call Decho("dirname<".dirname."> netrw_cd_escape<".s:netrw_cd_escape."> browse_split=".g:netrw_browse_split) -" call Decho("about to edit<".escape(dirname,s:netrw_cd_escape)."> didsplit=".(exists("s:didsplit")? s:didsplit : "doesn't exist")) - if !exists("s:didsplit") - if g:netrw_browse_split == 1 - new - wincmd _ - elseif g:netrw_browse_split == 2 - rightb vert new - wincmd | - elseif g:netrw_browse_split == 3 - tabnew - else - " handling a file, didn't split, so remove menu -" call Decho("handling a file+didn't split, so remove menu") - call s:NetMenu(0) - " optional change to window - if g:netrw_chgwin >= 1 - exe g:netrw_chgwin."wincmd w" - endif - endif - endif - " edit the file - " its local only: LocalBrowseCheck() doesn't edit a file, but NetBrowse() will - if a:islocal -" call Decho("edit file: exe e! ".escape(dirname,s:netrw_cd_escape)) - exe "e! ".escape(dirname,s:netrw_cd_escape) - endif - setlocal ma nomod noro - endif - - elseif newdir =~ '^/' - " just go to the new directory spec -" call Decho('case "just go to new directory spec": newdir<'.newdir.'>') - let dirname= newdir - - elseif newdir == './' - " refresh the directory list -" call Decho('case "refresh directory listing": newdir == "./"') - - elseif newdir == '../' - " go up one directory -" call Decho('case "go up one directory": newdir == "../"') - - if w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") - " force a refresh -" call Decho("clear buffer<".expand("%")."> with :%d") - setlocal noro ma - keepjumps %d - endif - - if has("amiga") - " amiga -" call Decho('case "go up one directory": newdir == "../" and amiga') - if a:islocal - let dirname= substitute(dirname,'^\(.*[/:]\)\([^/]\+$\)','\1','') - let dirname= substitute(dirname,'/$','','') - else - let dirname= substitute(dirname,'^\(.*[/:]\)\([^/]\+/$\)','\1','') - endif -" call Decho("amiga: dirname<".dirname."> (go up one dir)") - - else - " unix or cygwin -" call Decho('case "go up one directory": newdir == "../" and unix or cygwin') - if a:islocal - let dirname= substitute(dirname,'^\(.*\)/\([^/]\+\)/$','\1','') - if dirname == "" - let dirname= '/' - endif - else - let dirname= substitute(dirname,'^\(\a\+://.\{-}/\{1,2}\)\(.\{-}\)\([^/]\+\)/$','\1\2','') - endif -" call Decho("unix: dirname<".dirname."> (go up one dir)") - endif - - elseif w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") -" call Decho('case liststyle is TREELIST and w:netrw_treedict exists') - " force a refresh (for TREELIST, wait for NetTreeDir() to force the refresh) - 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 - endif - let treedir = s:NetTreeDir() - let s:treecurpos = nbcd_curpos - let haskey= 0 -" call Decho("w:netrw_treedict<".string(w:netrw_treedict).">") - - " search treedict for tree dir as-is - if has_key(w:netrw_treedict,treedir) -" call Decho('....searched for treedir<'.treedir.'> : found it!') - let haskey= 1 - else -" call Decho('....searched for treedir<'.treedir.'> : not found') - endif - - " search treedict for treedir with a / appended - if !haskey && treedir !~ '/$' - if has_key(w:netrw_treedict,treedir."/") - let treedir= treedir."/" -" call Decho('....searched.for treedir<'.treedir.'> found it!') - let haskey = 1 - else -" call Decho('....searched for treedir<'.treedir.'/> : not found') - endif - endif - - " search treedict for treedir with any trailing / elided - if !haskey && treedir =~ '/$' - let treedir= substitute(treedir,'/$','','') - if has_key(w:netrw_treedict,treedir) -" call Decho('....searched.for treedir<'.treedir.'> found it!') - let haskey = 1 - else -" call Decho('....searched for treedir<'.treedir.'> : not found') - endif - endif - - if haskey - " close tree listing for selected subdirectory -" call Decho("closing selected subdirectory<".dirname.">") - call remove(w:netrw_treedict,treedir) -" call Decho("removed entry<".dirname."> from treedict") -" call Decho("yielding treedict<".string(w:netrw_treedict).">") - let dirname= w:netrw_treetop - else - " go down one directory - let dirname= substitute(treedir,'/*$','/','') -" call Decho("go down one dir: treedir<".treedir.">") - endif - - else - " go down one directory - let dirname= s:ComposePath(dirname,newdir) -" call Decho("go down one dir: dirname<".dirname."> newdir<".newdir.">") - endif - -" call Dret("s:NetBrowseChgDir <".dirname."> : curpos<".string(getpos(".")).">") - return dirname -endfun - -" --------------------------------------------------------------------- -" s:NetHide: this function is invoked by the "a" map for browsing {{{2 -" and switches the hiding mode -fun! s:NetHide(islocal) -" call Dfunc("NetHide(islocal=".a:islocal.")") - let g:netrw_hide=(g:netrw_hide+1)%3 - exe "norm! 0" - if g:netrw_hide && g:netrw_list_hide == "" - call netrw#ErrorMsg(s:WARNING,"your hiding list is empty!",49) -" call Dret("NetHide") - return - endif - call netrw#NetSavePosn() - call s:NetRefresh(a:islocal,s:NetBrowseChgDir(a:islocal,'./')) -" call Dret("NetHide") -endfun - -" --------------------------------------------------------------------- - -" =========================================== -" s:NetPreview: {{{2 -fun! s:NetPreview(path) range -" call Dfunc("NetPreview(path<".a:path.">)") - if has("quickfix") - if !isdirectory(a:path) - exe "pedit ".escape(a:path,g:netrw_fname_escape) - elseif !exists("g:netrw_quiet") - call netrw#ErrorMsg(s:WARNING,"sorry, cannot preview a directory such as <".a:path.">",38) - endif - elseif !exists("g:netrw_quiet") - call netrw#ErrorMsg(s:WARNING,"sorry, to preview your vim needs the quickfix feature compiled in",39) - endif -" call Dret("NetPreview") -endfun - -" --------------------------------------------------------------------- -" s:NetSortStyle: change sorting style (name - time - size) and refresh display {{{2 -fun! s:NetSortStyle(islocal) -" call Dfunc("s:NetSortStyle(islocal=".a:islocal.") netrw_sort_by<".g:netrw_sort_by.">") - call s:NetSaveWordPosn() - - let g:netrw_sort_by= (g:netrw_sort_by =~ 'n')? 'time' : (g:netrw_sort_by =~ 't')? 'size' : 'name' - norm! 0 - call netrw#NetSavePosn() - call s:NetRefresh(a:islocal,s:NetBrowseChgDir(a:islocal,'./')) - -" call Dret("s:NetSortStyle : netrw_sort_by<".g:netrw_sort_by.">") -endfun - -" --------------------------------------------------------------------- -" Remote Directory Browsing Support: {{{1 -" =========================================== - -" --------------------------------------------------------------------- -" s:RemoteListing: {{{2 -fun! s:RemoteListing() -" call Dfunc("s:RemoteListing() b:netrw_curdir<".b:netrw_curdir.">)") - - call s:RemotePathAnalysis(b:netrw_curdir) - - " sanity check: - if exists("b:netrw_method") && b:netrw_method =~ '[235]' -" call Decho("b:netrw_method=".b:netrw_method) - if !executable("ftp") - if !exists("g:netrw_quiet") - call netrw#ErrorMsg(s:ERROR,"this system doesn't support remote directory listing via ftp",18) - endif - call s:NetOptionRestore() -" call Dret("s:RemoteListing") - return - endif - - elseif !exists("g:netrw_list_cmd") || g:netrw_list_cmd == '' - if !exists("g:netrw_quiet") - if g:netrw_list_cmd == "" - call netrw#ErrorMsg(s:ERROR,g:netrw_ssh_cmd." is not executable on your system",47) - else - call netrw#ErrorMsg(s:ERROR,"this system doesn't support remote directory listing via ".g:netrw_list_cmd,19) - endif - endif - - call s:NetOptionRestore() -" call Dret("s:RemoteListing") - return - endif " (remote handling sanity check) - - if exists("b:netrw_method") -" call Decho("setting w:netrw_method<".b:netrw_method.">") - let w:netrw_method= b:netrw_method - endif - - if s:method == "ftp" - " use ftp to get remote file listing -" call Decho("use ftp to get remote file listing") - let s:method = "ftp" - let listcmd = g:netrw_ftp_list_cmd - if g:netrw_sort_by =~ '^t' - let listcmd= g:netrw_ftp_timelist_cmd - elseif g:netrw_sort_by =~ '^s' - let listcmd= g:netrw_ftp_sizelist_cmd - endif -" call Decho("listcmd<".listcmd."> (using g:netrw_ftp_list_cmd)") - call s:NetBrowseFtpCmd(s:path,listcmd) -" exe "keepjumps ".w:netrw_bannercnt.',$g/^./call Decho("raw listing: ".getline("."))' - - if w:netrw_liststyle == s:THINLIST || w:netrw_liststyle == s:WIDELIST || w:netrw_liststyle == s:TREELIST - " shorten the listing -" call Decho("generate short listing") - exe "keepjumps ".w:netrw_bannercnt - - " cleanup - if g:netrw_ftp_browse_reject != "" - exe "silent! g/".g:netrw_ftp_browse_reject."/keepjumps d" - endif - silent! keepjumps %s/\r$//e - - " if there's no ../ listed, then put ./ and ../ in - let line1= line(".") - exe "keepjumps ".w:netrw_bannercnt - let line2= search('^\.\.\/\%(\s\|$\)','cnW') - if line2 == 0 -" call Decho("netrw is putting ./ and ../ into listing") - keepjumps put='../' - keepjumps put='./' - endif - exe "keepjumps ".line1 - keepjumps norm! 0 - -" call Decho("line1=".line1." line2=".line2." line(.)=".line(".")) - if search('^\d\{2}-\d\{2}-\d\{2}\s','n') " M$ ftp site cleanup -" call Decho("M$ ftp cleanup") - exe 'silent! keepjumps '.w:netrw_bannercnt.',$s/^\d\{2}-\d\{2}-\d\{2}\s\+\d\+:\d\+[AaPp][Mm]\s\+\%(\|\d\+\)\s\+//' - else " normal ftp cleanup -" call Decho("normal ftp cleanup") - exe 'silent! keepjumps '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2/e' - exe "silent! keepjumps ".w:netrw_bannercnt.',$g/ -> /s# -> .*/$#/#e' - exe "silent! keepjumps ".w:netrw_bannercnt.',$g/ -> /s# -> .*$#/#e' - endif - endif - - else - " use ssh to get remote file listing {{{3 -" call Decho("use ssh to get remote file listing: s:netrw_shq<".g:netrw_shq."> s:path<".s:path."> s:netrw_cd_escape<".s:netrw_cd_escape.">") - let listcmd= s:MakeSshCmd(g:netrw_list_cmd) -" call Decho("listcmd<".listcmd."> (using g:netrw_list_cmd)") - if g:netrw_scp_cmd =~ '^pscp' -" call Decho("1: exe silent r! ".listcmd.g:netrw_shq.s:path.g:netrw_shq) - exe "silent r! ".listcmd.g:netrw_shq.s:path.g:netrw_shq - " remove rubbish and adjust listing format of 'pscp' to 'ssh ls -FLa' like - g/^Listing directory/d - g/^d[-rwx][-rwx][-rwx]/s+$+/+e - silent g/^l[-rwx][-rwx][-rwx]/s+$+@+e - if g:netrw_liststyle != s:LONGLIST - g/^[dlsp-][-rwx][-rwx][-rwx]/s/^.*\s\(\S\+\)$/\1/e - endif - else - if s:path == "" -" call Decho("2: exe silent r! ".listcmd) - exe "silent r! ".listcmd - else -" call Decho("3: exe silent r! ".listcmd." ".g:netrw_shq.s:path.g:netrw_shq) - exe "silent r! ".listcmd." ".g:netrw_shq.s:path.g:netrw_shq - endif - endif - - " cleanup - if g:netrw_ftp_browse_reject != "" -" call Decho("(cleanup) exe silent! g/".g:netrw_ssh_browse_reject."/keepjumps d") - exe "silent! g/".g:netrw_ssh_browse_reject."/keepjumps d" - endif - endif - - if w:netrw_liststyle == s:LONGLIST - " do a long listing; these substitutions need to be done prior to sorting {{{3 -" call Decho("fix long listing:") - - if s:method == "ftp" - " cleanup - exe "keepjumps ".w:netrw_bannercnt - while getline(".") =~ g:netrw_ftp_browse_reject - keepjumps d - endwhile - " if there's no ../ listed, then put ./ and ../ in - let line1= line(".") - keepjumps 1 - silent keepjumps call search('^\.\.\/\%(\s\|$\)','W') - let line2= line(".") - if line2 == 0 - exe 'keepjumps '.w:netrw_bannercnt."put='./'" - if b:netrw_curdir != '/' - exe 'keepjumps '.w:netrw_bannercnt."put='../'" - endif - endif - exe "keepjumps ".line1 - keepjumps norm! 0 - endif - - if search('^\d\{2}-\d\{2}-\d\{2}\s','n') " M$ ftp site cleanup -" call Decho("M$ ftp site listing cleanup") - exe 'silent! keepjumps '.w:netrw_bannercnt.',$s/^\(\d\{2}-\d\{2}-\d\{2}\s\+\d\+:\d\+[AaPp][Mm]\s\+\%(\|\d\+\)\s\+\)\(\w.*\)$/\2\t\1/' - elseif exists("w:netrw_bannercnt") && w:netrw_bannercnt <= line("$") -" call Decho("normal ftp site listing cleanup: bannercnt=".w:netrw_bannercnt." line($)=".line("$")) - exe 'silent keepjumps '.w:netrw_bannercnt.',$s/ -> .*$//e' - exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2\t\1/e' - exe 'silent keepjumps '.w:netrw_bannercnt - endif - endif - -" if exists("w:netrw_bannercnt") && w:netrw_bannercnt <= line("$") " Decho -" exe "keepjumps ".w:netrw_bannercnt.',$g/^./call Decho("listing: ".getline("."))' -" endif " Decho -" call Dret("s:RemoteListing") -endfun - -" --------------------------------------------------------------------- -" NetGetWord: it gets the directory named under the cursor {{{2 -fun! s:NetGetWord() -" call Dfunc("NetGetWord() line#".line(".")." liststyle=".g:netrw_liststyle." virtcol=".virtcol(".")) +" 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 s:UseBufWinVars() " insure that w:netrw_liststyle is set up @@ -2611,184 +2221,1359 @@ fun! s:NetGetWord() " call Decho("4: dirname<".dirname.">") endif -" call Dret("NetGetWord <".dirname.">") +" call Dret("NetrwGetWord <".dirname.">") return dirname endfun " --------------------------------------------------------------------- -" NetBrowseRm: remove/delete a remote file or directory {{{2 -fun! s:NetBrowseRm(usrhost,path) range -" call Dfunc("NetBrowseRm(usrhost<".a:usrhost."> path<".a:path.">) virtcol=".virtcol(".")) -" call Decho("firstline=".a:firstline." lastline=".a:lastline) +" s:NetrwListSettings: {{{2 +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,' ') + if g:netrw_use_noswf + setlocal noswf + endif +" call Dredir("ls!") +" call Decho("exe setlocal ts=".g:netrw_maxfilenamelen) + exe "setlocal ts=".g:netrw_maxfilenamelen + setlocal isk+=.,~,- + if g:netrw_fastbrowse > a:islocal + setlocal bh=hide + else + setlocal bh=delete + endif +" call Dret("s:NetrwListSettings") +endfun - " preparation for removing multiple files/directories - let ctr= a:firstline - let all= 0 +" --------------------------------------------------------------------- +" s:PerformListing: {{{2 +fun! s:PerformListing(islocal) +" call Dfunc("s:PerformListing(islocal=".a:islocal.") buf(%)=".bufnr("%")."<".bufname("%").">") - " remove multiple files and directories - while ctr <= a:lastline - exe ctr +" if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1 " Decho +" call Decho("(netrw) Processing your browsing request...") +" endif " Decho - let rmfile= s:NetGetWord() -" call Decho("rmfile<".rmfile.">") +" 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") + setlocal ma noro + keepjumps %d + endif - if rmfile !~ '^"' && (rmfile =~ '@$' || rmfile !~ '[\/]$') - " attempt to remove file -" call Decho("attempt to remove file") - if !all - echohl Statement - call inputsave() - let ok= input("Confirm deletion of file<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") - call inputrestore() - echohl NONE - if ok == "" - let ok="no" - endif - let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e') - if ok =~ 'a\%[ll]' - let all= 1 - endif - endif + " save current directory on directory history list + call s:NetrwBookmarkDir(3,b:netrw_curdir) - if all || ok =~ 'y\%[es]' || ok == "" - if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3) - silent! keepjumps .,$d - call s:NetBrowseFtpCmd(a:path,"delete ".rmfile) - else - let netrw_rm_cmd= s:MakeSshCmd(g:netrw_rm_cmd) -" call Decho("attempt to remove file: system(".netrw_rm_cmd.")") - let ret= s:System("system",netrw_rm_cmd) -" call Decho("returned=".ret." errcode=".v:shell_error) - endif - elseif ok =~ 'q\%[uit]' - break - endif + " 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 + endif + exe "keepjumps ".w:netrw_bannercnt + + " 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 - " attempt to remove directory -" call Decho("attempt to remove directory") - if !all - call inputsave() - let ok= input("Confirm deletion of directory<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") - call inputrestore() - if ok == "" - let ok="no" - endif - let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e') - if ok =~ 'a\%[ll]' - let all= 1 - endif - endif + keepjumps put ='\" Copy/Move Tgt: '.s:netrwmftgt.' (remote)' + endif + let w:netrw_bannercnt= w:netrw_bannercnt + 1 + endif + exe "keepjumps ".w:netrw_bannercnt - if all || ok =~ 'y\%[es]' || ok == "" - if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3) - call s:NetBrowseFtpCmd(a:path,"rmdir ".rmfile) - else - let rmfile = substitute(a:path.rmfile,'/$','','') - let netrw_rmdir_cmd = s:MakeSshCmd(g:netrw_rmdir_cmd).' '.rmfile -" call Decho("attempt to remove dir: system(".netrw_rmdir_cmd.")") - let ret= s:System("system",netrw_rmdir_cmd) -" call Decho("returned=".ret." errcode=".v:shell_error) + " 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 - if v:shell_error != 0 -" call Decho("v:shell_error not 0") - let netrw_rmf_cmd= s:MakeSshCmd(g:netrw_rmf_cmd).' '.substitute(rmfile,'[\/]$','','e') -" call Decho("2nd attempt to remove dir: system(".netrw_rmf_cmd.")") - let ret= s:System("system",netrw_rmf_cmd) -" call Decho("returned=".ret." errcode=".v:shell_error) + " 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("$")) - if v:shell_error != 0 && !exists("g:netrw_quiet") - call netrw#ErrorMsg(s:ERROR,"unable to remove directory<".rmfile."> -- is it empty?",22) - endif + " 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 ok =~ 'q\%[uit]' - break + 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 setpos('.',s:treecurpos) + unlet s:treecurpos + endif + +" call Dret("s:PerformListing : curpos<".string(getpos(".")).">") +endfun + +" --------------------------------------------------------------------- +" s:NetrwBrowseChgDir: constructs a new directory based on the current {{{2 +" directory and a new directory name. Also, if the +" "new directory name" is actually a file, +" NetrwBrowseChgDir() edits the file. +fun! s:NetrwBrowseChgDir(islocal,newdir,...) +" call Dfunc("s:NetrwBrowseChgDir(islocal=".a:islocal."> newdir<".a:newdir.">) a:0=".a:0." curpos<".string(getpos("."))."> b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "").">") + + if !exists("b:netrw_curdir") +" call Decho("(NetrwBrowseChgDir) b:netrw_curdir doesn't exist!") + echoerr "(NetrwBrowseChgDir) b:netrw_curdir doesn't exist!" +" call Dret("s:NetrwBrowseChgDir") + return + endif + + call s:NetrwOptionSave("s:") + call netrw#NetrwSavePosn() + let nbcd_curpos = getpos('.') + let dirname = substitute(b:netrw_curdir,'\\','/','ge') + let newdir = a:newdir + + " set up o/s-dependent directory recognition pattern + if has("amiga") + let dirpat= '[\/:]$' + else + let dirpat= '[\/]$' + endif +" call Decho("dirname<".dirname."> dirpat<".dirpat.">") + + if dirname !~ dirpat + " apparently vim is "recognizing" that it is in a directory and + " is removing the trailing "/". Bad idea, so I put it back. + let dirname= dirname.'/' +" call Decho("adjusting dirname<".dirname.">") + endif + + if newdir !~ dirpat + " ------------ + " edit a file: + " ------------ +" 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 +" call Decho("tree listing") + elseif newdir =~ '^\(/\|\a:\)' + let dirname= newdir + else + let dirname= s:ComposePath(dirname,newdir) + endif +" call Decho("handling a file: dirname<".dirname."> (a:0=".a:0.")") + " this lets NetrwBrowseX avoid the edit + if a:0 < 1 +" call Decho("dirname<".dirname."> netrw_cd_escape<".g:netrw_cd_escape."> browse_split=".g:netrw_browse_split) +" call Decho("about to edit<".escape(dirname,g:netrw_cd_escape)."> didsplit=".(exists("s:didsplit")? s:didsplit : "doesn't exist")) + if !exists("s:didsplit") + if g:netrw_browse_split == 1 + new + wincmd _ + elseif g:netrw_browse_split == 2 + rightb vert new + wincmd | + elseif g:netrw_browse_split == 3 + tabnew + else + " handling a file, didn't split, so remove menu +" call Decho("handling a file+didn't split, so remove menu") + call s:NetrwMenu(0) + " optional change to window + if g:netrw_chgwin >= 1 + exe g:netrw_chgwin."wincmd w" + endif + endif + endif + " the point where netrw actually edits the (local) file + " if its local only: LocalBrowseCheck() doesn't edit a file, but NetrwBrowse() will + if a:islocal +" call Decho("edit local file: exe e! ".escape(dirname,g:netrw_cd_escape)) + call s:NetrwOptionRestore("s:") + setlocal ma nomod noro + exe "e! ".escape(dirname,g:netrw_cd_escape) + else + setlocal ma nomod noro + call s:NetrwOptionRestore("s:") endif endif - let ctr= ctr + 1 - endwhile + elseif newdir =~ '^/' + " --------------------------------- + " just go to the new directory spec + " --------------------------------- +" call Decho('case "just go to new directory spec": newdir<'.newdir.'>') + let dirname= newdir + call s:NetrwOptionRestore("s:") - " refresh the (remote) directory listing -" call Decho("refresh remote directory listing") - call netrw#NetSavePosn() - call s:NetRefresh(0,s:NetBrowseChgDir(0,'./')) + elseif newdir == './' + " -------------------------- + " refresh the directory list + " -------------------------- +" call Decho('case "refresh directory listing": newdir == "./"') + call s:NetrwOptionRestore("s:") -" call Dret("NetBrowseRm") -endfun + elseif newdir == '../' + " ------------------- + " go up one directory + " ------------------- +" call Decho('case "go up one directory": newdir == "../"') -" --------------------------------------------------------------------- -" NetBrowseRename: rename a remote file or directory {{{2 -fun! s:NetBrowseRename(usrhost,path) range -" call Dfunc("NetBrowseRename(usrhost<".a:usrhost."> path<".a:path.">)") - - " preparation for removing multiple files/directories - let ctr = a:firstline - let rename_cmd = s:MakeSshCmd(g:netrw_rename_cmd) - - " attempt to rename files/directories - while ctr <= a:lastline - exe "keepjumps ".ctr - - norm! 0 - let oldname= s:NetGetWord() -" call Decho("oldname<".oldname.">") - - call inputsave() - let newname= input("Moving ".oldname." to : ",oldname) - call inputrestore() - - if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3) - call s:NetBrowseFtpCmd(a:path,"rename ".oldname." ".newname) - else - let oldname= a:path.oldname - let newname= a:path.newname -" call Decho("system(rename_cmd".' "'.escape(oldname," ").'" "'.escape(newname,s:netrw_cd_escape).'"') - let ret= s:System("system",rename_cmd.' "'.escape(oldname,s:netrw_cd_escape).'" "'.escape(newname,s:netrw_cd_escape).'"') + if w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") + " force a refresh +" call Decho("clear buffer<".expand("%")."> with :%d") + setlocal noro ma + keepjumps %d endif - let ctr= ctr + 1 - endwhile + if has("amiga") + " amiga +" call Decho('case "go up one directory": newdir == "../" and amiga') + if a:islocal + let dirname= substitute(dirname,'^\(.*[/:]\)\([^/]\+$\)','\1','') + let dirname= substitute(dirname,'/$','','') + else + let dirname= substitute(dirname,'^\(.*[/:]\)\([^/]\+/$\)','\1','') + endif +" call Decho("amiga: dirname<".dirname."> (go up one dir)") - " refresh the directory - let curline= line(".") - call s:NetBrowse(0,s:NetBrowseChgDir(0,'./')) - exe "keepjumps ".curline -" call Dret("NetBrowseRename") + else + " unix or cygwin +" call Decho('case "go up one directory": newdir == "../" and unix or cygwin') + if a:islocal + let dirname= substitute(dirname,'^\(.*\)/\([^/]\+\)/$','\1','') + if dirname == "" + let dirname= '/' + endif + else + let dirname= substitute(dirname,'^\(\a\+://.\{-}/\{1,2}\)\(.\{-}\)\([^/]\+\)/$','\1\2','') + endif +" call Decho("unix: dirname<".dirname."> (go up one dir)") + endif + call s:NetrwOptionRestore("s:") + + elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") +" 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 + if !(exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir")) +" call Decho("clear buffer<".expand("%")."> with :%d") + keepjumps %d + endif + let treedir = s:NetrwTreeDir() + let s:treecurpos = nbcd_curpos + let haskey= 0 +" call Decho("w:netrw_treedict<".string(w:netrw_treedict).">") + + " search treedict for tree dir as-is + if has_key(w:netrw_treedict,treedir) +" call Decho('....searched for treedir<'.treedir.'> : found it!') + let haskey= 1 + else +" call Decho('....searched for treedir<'.treedir.'> : not found') + endif + + " search treedict for treedir with a / appended + if !haskey && treedir !~ '/$' + if has_key(w:netrw_treedict,treedir."/") + let treedir= treedir."/" +" call Decho('....searched.for treedir<'.treedir.'> found it!') + let haskey = 1 + else +" call Decho('....searched for treedir<'.treedir.'/> : not found') + endif + endif + + " search treedict for treedir with any trailing / elided + if !haskey && treedir =~ '/$' + let treedir= substitute(treedir,'/$','','') + if has_key(w:netrw_treedict,treedir) +" call Decho('....searched.for treedir<'.treedir.'> found it!') + let haskey = 1 + else +" call Decho('....searched for treedir<'.treedir.'> : not found') + endif + endif + + if haskey + " close tree listing for selected subdirectory +" call Decho("closing selected subdirectory<".dirname.">") + call remove(w:netrw_treedict,treedir) +" call Decho("removed entry<".dirname."> from treedict") +" call Decho("yielding treedict<".string(w:netrw_treedict).">") + let dirname= w:netrw_treetop + else + " go down one directory + let dirname= substitute(treedir,'/*$','/','') +" call Decho("go down one dir: treedir<".treedir.">") + endif + + else + " go down one directory + let dirname= s:ComposePath(dirname,newdir) +" call Decho("go down one dir: dirname<".dirname."> newdir<".newdir.">") + call s:NetrwOptionRestore("s:") + endif + +" call Dret("s:NetrwBrowseChgDir <".dirname."> : curpos<".string(getpos(".")).">") + return dirname endfun " --------------------------------------------------------------------- -" NetRefresh: {{{2 -fun! s:NetRefresh(islocal,dirname) -" call Dfunc("NetRefresh(islocal<".a:islocal.">,dirname=".a:dirname.") hide=".g:netrw_hide." sortdir=".g:netrw_sort_direction) - " at the current time (Mar 19, 2007) all calls to NetRefresh() call NetBrowseChgDir() first. - " NetBrowseChgDir() may clear the display; hence a NetSavePosn() may not work if its placed here. - " Also, NetBrowseChgDir() now does a NetSavePosn() itself. +" s:NetrwHide: this function is invoked by the "a" map for browsing {{{2 +" and switches the hiding mode. The actual hiding is done by +" s:NetrwListHide(). +" g:netrw_hide= 0: show all +" 1: show not-hidden files +" 2: show hidden files only +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).">") +" call Decho("g:netrw_list_hide<".g:netrw_list_hide.">") + + " hide the files in the markfile list + for fname in s:netrwmarkfilelist +" 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 + let g:netrw_list_hide= substitute(g:netrw_list_hide,'..\<'.escape(fname,g:netrw_fname_escape).'\>..','','') + let g:netrw_list_hide= substitute(g:netrw_list_hide,',,',',','g') + let g:netrw_list_hide= substitute(g:netrw_list_hide,'^,\|,$','','') +" call Decho("unhide: g:netrw_list_hide<".g:netrw_list_hide.">") + else + " append fname to hiding list + if exists("g:netrw_list_hide") && g:netrw_list_hide != "" + let g:netrw_list_hide= g:netrw_list_hide.',\<'.escape(fname,g:netrw_fname_escape).'\>' + else + let g:netrw_list_hide= '\<'.escape(fname,g:netrw_fname_escape).'\>' + endif +" call Decho("hide: g:netrw_list_hide<".g:netrw_list_hide.">") + endif + endfor + unlet s:netrwmarkfilelist + unlet s:netrwmarkfilemtch + 2match none + let g:netrw_hide= 1 + + else + + " switch between show-all/show-not-hidden/show-hidden + let g:netrw_hide=(g:netrw_hide+1)%3 + exe "norm! 0" + if g:netrw_hide && g:netrw_list_hide == "" + call netrw#ErrorMsg(s:WARNING,"your hiding list is empty!",49) +" call Dret("NetrwHide") + return + endif + endif + + call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) + call netrw#NetrwRestorePosn(svpos) +" call Dret("NetrwHide") +endfun + +" --------------------------------------------------------------------- +" s:NetrwLeftmouse: handles the when in a netrw browsing window {{{2 +fun! s:NetrwLeftmouse(islocal) +" call Dfunc("s:NetrwLeftmouse(islocal=".a:islocal.")") + if a:islocal + if exists("b:netrw_curdir") + call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,s:NetrwGetWord())) + endif + else + if exists("b:netrw_curdir") + call s:NetrwBrowse(0,s:NetrwBrowseChgDir(0,s:NetrwGetWord())) + endif + endif +" call Dret("s:NetrwLeftmouse") +endfun + +" --------------------------------------------------------------------- +" s:NetrwListHide: uses [range]g~...~d to delete files that match comma {{{2 +" separated patterns given in g:netrw_list_hide +fun! s:NetrwListHide() +" call Dfunc("NetrwListHide() hide=".g:netrw_hide." listhide<".g:netrw_list_hide.">") + + " find a character not in the "hide" string to use as a separator for :g and :v commands + " How-it-works: take the hiding command, convert it into a range. Duplicate + " characters don't matter. Remove all such characters from the '/~...90' + " string. Use the first character left as a separator character. + let listhide= g:netrw_list_hide + let sep = strpart(substitute('/~@#$%^&*{};:,<.>?|1234567890','['.escape(listhide,'-]^\').']','','ge'),1,1) +" call Decho("sep=".sep) + + while listhide != "" + if listhide =~ ',' + let hide = substitute(listhide,',.*$','','e') + let listhide = substitute(listhide,'^.\{-},\(.*\)$','\1','e') + else + let hide = listhide + let listhide = "" + endif + + " Prune the list by hiding any files which match + if g:netrw_hide == 1 +" call Decho("hiding<".hide."> listhide<".listhide.">") + exe 'silent keepjumps '.w:netrw_bannercnt.',$g'.sep.hide.sep.'d' + elseif g:netrw_hide == 2 +" call Decho("showing<".hide."> listhide<".listhide.">") + exe 'silent keepjumps '.w:netrw_bannercnt.',$g'.sep.hide.sep.'s@^@ /-KEEP-/ @' + endif + endwhile + if g:netrw_hide == 2 + exe 'silent keepjumps '.w:netrw_bannercnt.',$v@^ /-KEEP-/ @d' + exe 'silent keepjumps '.w:netrw_bannercnt.',$s@^\%( /-KEEP-/ \)\+@@e' + endif + +" call Dret("NetrwListHide") +endfun + +" --------------------------------------------------------------------- +" NetrwHideEdit: allows user to edit the file/directory hiding list +fun! s:NetrwHideEdit(islocal) +" call Dfunc("NetrwHideEdit(islocal=".a:islocal.")") + + " save current cursor position + let svpos= netrw#NetrwSavePosn() + + " get new hiding list from user + call inputsave() + let newhide= input("Edit Hiding List: ",g:netrw_list_hide) + call inputrestore() + let g:netrw_list_hide= newhide +" call Decho("new g:netrw_list_hide<".g:netrw_list_hide.">") + + " refresh the listing + silent call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,"./")) + + " restore cursor position + call netrw#NetrwRestorePosn(svpos) + +" call Dret("NetrwHideEdit") +endfun + +" --------------------------------------------------------------------- +" NetSortSequence: allows user to edit the sorting sequence +fun! s:NetSortSequence(islocal) +" call Dfunc("NetSortSequence(islocal=".a:islocal.")") + + let svpos= netrw#NetrwSavePosn() + call inputsave() + let newsortseq= input("Edit Sorting Sequence: ",g:netrw_sort_sequence) + call inputrestore() + + " refresh the listing + let g:netrw_sort_sequence= newsortseq + call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) + call netrw#NetrwRestorePosn(svpos) + +" call Dret("NetSortSequence") +endfun + +" --------------------------------------------------------------------- +" s:NetrwMarkFile: This function is invoked by mf, and 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 +" moment. When the mouse and gui are available, +" 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 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 + " 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.'\|\<'.a:fname.'\>' + 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 + 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.">") + 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).">") + + if a:fname =~ '/$' + let s:netrwmarkfilemtch= '\<'.escape(a:fname,'*./[\') + else + let s:netrwmarkfilemtch= '\<'.escape(a:fname,'*./[\').'\>' + endif +" call Decho("ending s:netrwmarkfilemtch<".s:netrwmarkfilemtch.">") + endif + + if exists("s:netrwmarkfilemtch") && s:netrwmarkfilemtch != "" +" call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch."/") + exe "2match netrwMarkFile /".s:netrwmarkfilemtch."/" + else +" call Decho("2match none") + 2match none + endif +" call Dret("s:NetrwMarkFile : netrwmarkfilelist".(exists("s:netrwmarkfilelist")? string(s:netrwmarkfilelist) : " doesn't exist")) +endfun + +" --------------------------------------------------------------------- +" s:NetrwMarkFileCompress: This function, invoked by mz, 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 +" do. By default: +" g:netrw_compress = "gzip" +" 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 exists("s:netrwmarkfilelist") && exists("g:netrw_compress") && exists("g:netrw_decompress") + for fname in s:netrwmarkfilelist + " 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 executable(exe) + if a:islocal + call system(exe." ".fname) + else + call s:RemoteSystem(exe." ".fname) + endif + else + call netrw#ErrorMsg(s:WARNING,"unable to apply<".exe."> to file<".fname.">",50) + endif + break + endif + endfor + if exists("exe") + unlet exe + elseif a:islocal + " fname not a compressed file, so compress it + call system(g:netrw_compress." ".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 + 2match none + call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) + call netrw#NetrwRestorePosn(svpos) + endif +" call Dret("s:NetrwMarkFileCompress") +endfun + +" --------------------------------------------------------------------- +" s:NetrwMarkFileCopy: copy marked files to target {{{2 +" If no marked files, then set up directory as the +" target. Currently does not support copying entire +" directories. +" Returns 1=success (used by NetrwMarkFileMove()) +" 0=failure +fun! s:NetrwMarkFileCopy(islocal) +" call Dfunc("s:NetrwMarkFileCopy(islocal=".a:islocal.") target<".(exists("s:netrwmftgt")? s:netrwmftgt : '---').">") + + if exists("s:netrwmarkfilelist") +" call Decho("s:netrwmarkfilelist<".string(s:netrwmarkfilelist).">") +" call Decho("s:netrwmarkfilemtch<".string(s:netrwmarkfilemtch).">") + let svpos= netrw#NetrwSavePosn() + + if exists("s:netrwmftgt") && exists("s:netrwmfloc") +" call Decho("s:netrwmftgt<".s:netrwmftgt.">") +" call Decho("s:netrwmfloc=".s:netrwmfloc) + + for fname in s:netrwmarkfilelist +" call Decho("s:NetrwMarkFileCopy: fname<".fname.">") + + " sanity check + if (a:islocal && isdirectory(fname)) || (!a:islocal && fname =~ '/$') + call netrw#ErrorMsg(s:ERROR,"currently netrw can't copy entire directories such as <".fname.">",58) +" call Dret("s:NetrwMarkFileCopy 0 : currently netrw can't copy entire directories") + return 0 + endif + + if a:islocal && s:netrwmfloc + " local to local copy +" call Decho("local to local copy") + 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) + if v:shell_error < 0 + call netrw#ErrorMsg(s:ERROR,"command<".g:netrw_localcopycmd."> failed, aborting",54) + break + endif + else + call netrw#ErrorMsg(s:ERROR,"command<".g:netrw_localcopycmd."> is not executable!",57) + break + endif + + elseif !a:islocal && s:netrwmfloc + " remote to local copy +" call Decho("remote to local copy") + call netrw#NetrwObtain(a:islocal,fname,s:netrwmftgt) + + elseif a:islocal && !s:netrwmfloc + " local to remote copy +" call Decho("local to remote copy") + call s:NetrwUpload(fname,s:netrwmftgt) + + else + " remote to remote copy +" call Decho("remote to remote copy") + call s:NetrwUpload(fname,s:netrwmftgt) + endif + endfor + + " 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 + 2match none + endif + else + call netrw#ErrorMsg(s:ERROR,"missing a markfile copy target!",56) + endif + + " 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:NetrwMarkFileCopy 1") + return 1 +endfun + +" --------------------------------------------------------------------- +" s:NetrwMarkFileDiff: This function, invoked by md, 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 exists("s:netrwmarkfilelist") + let curdir= b:netrw_curdir + let cnt= 0 + for fname in s:netrwmarkfilelist + let cnt= cnt + 1 + if !a:islocal + let fname= curdir.fname + endif + if cnt == 1 +" call Decho("diffthis: ".fname) + exe "e ".fname + diffthis + elseif cnt == 2 || cnt == 3 + vsplit + wincmd l +" call Decho("diffthis: ".fname) + exe "e ".fname + diffthis + else + break + endif + endfor + unlet s:netrwmarkfilelist + unlet s:netrwmarkfilemtch + 2match none + endif +" call Dret("s:NetrwMarkFileDiff") +endfun + +" --------------------------------------------------------------------- +" s:NetrwMarkFileEdit: put marked files on arg list and start editing them {{{2 +fun! s:NetrwMarkFileEdit(islocal) +" call Dfunc("s:NetrwMarkFileEdit(islocal=".a:islocal.")") + + if exists("s:netrwmarkfilelist") + if a:islocal + exe 'com! Rexplore call netrw#LocalBrowseCheck("'.escape(b:netrw_curdir,g:netrw_cd_escape).'")' + if g:netrw_mousemaps == 1 + silent! unmap <2-leftmouse> + exe 'nnoremap <2-leftmouse> :call netrw#LocalBrowseCheck("'.b:netrw_curdir.'")' + endif + else + exe 'com! Rexplore call s:NetrwBrowse(0,"'.escape(b:netrw_curdir,g:netrw_cd_escape).'")' + if g:netrw_mousemaps == 1 + silent! unmap <2-leftmouse> + exe 'silent! nnoremap <2-leftmouse> :call NetrwBrowse(0,"'.b:netrw_curdir.'")' + endif + endif + let flist= substitute(escape(join(s:netrwmarkfilelist,"\t"),' '),"\t",' ','g') + " unmark marked file list + unlet s:netrwmarkfilelist + unlet s:netrwmarkfilemtch + 2match none +" call Decho("exe silent args ".flist) + exe "silent args ".flist + endif + +" call Dret("s:NetrwMarkFileEdit") +endfun + +" --------------------------------------------------------------------- +" s:NetrwMarkFileExe: 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 exists("s:netrwmarkfilelist") + " get the command + call inputsave() + let cmd= input("Enter command: ","","file") + call inputrestore() +" call Decho("cmd<".cmd.">") + + " apply command to marked files. Substitute: filename -> % + " If no %, then append a space and the filename to the command + for fname in s:netrwmarkfilelist + if cmd =~ '%' + let xcmd= substitute(cmd,'%',fname,'g') + else + let xcmd= cmd.' '.fname + endif + if a:islocal +" call Decho("local: xcmd<".xcmd.">") + let ret= system(xcmd) + else +" call Decho("remote: xcmd<".xcmd.">") + let ret= s:RemoteSystem(xcmd) + endif + if v:shell_error < 0 + call netrw#ErrorMsg(s:ERROR,"command<".xcmd."> failed, aborting",54) + break + else + echo ret + endif + endfor + + " unmark marked file list + unlet s:netrwmarkfilelist + unlet s:netrwmarkfilemtch + 2match none + + " refresh the listing + call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) + call netrw#NetrwRestorePosn(svpos) + 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 exists("s:netrwmarkfilelist") + let svpos= netrw#NetrwSavePosn() + if exists("s:netrwmftgt") && exists("s:netrwmfloc") + + 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) + break + endif + else + call netrw#ErrorMsg(s:ERROR,"command<".g:netrw_localmovecmd."> is not executable!",57) + break + endif + else + " remote to local move + " local to remote move + " remote to remote move + let netrwmflist = s:netrwmflist + let netrwmfmtch = s:netrwmfmtch + if s:NetrwMarkFileCopy(islocal) + let s:netrwmflist= netrwmflist + let s:netrwmfmtch= netrwmfmtch + if a:islocal + call s:NetrwLocalRm("---") + else + call s:NetrwRemoteRm("---","---") + endif + endif + endif + + " First, do a copy, then (attempt to) do a delete + + call netrw#NetrwRestorePosn(svpos) + endif + +" call Dret("s:NetrwMarkFileMove") +endfun + +" --------------------------------------------------------------------- +" s:NetrwMarkFilePrint: This function, invoked by mp, prints marked files {{{2 +" using the hardcopy command +fun! s:NetrwMarkFilePrint(islocal) +" call Dfunc("s:NetrwMarkFilePrint(islocal=".a:islocal.")") + if exists("s:netrwmarkfilelist") + let netrwmarkfilelist= s:netrwmarkfilelist + unlet s:netrwmarkfilelist + unlet s:netrwmarkfilemtch + for fname in netrwmarkfilelist + 1split + exe "silent e ".fname +" call Decho("hardcopy ".fname) + hardcopy + q + endfor + 2match none + endif +" call Dret("s:NetrwMarkFilePrint") +endfun + +" --------------------------------------------------------------------- + +" =========================================== +" s:NetrwMarkFileRegexp: This function, invoked by mr, 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.")") + + " get the regular expression + call inputsave() + let regexp= input("Enter regexp: ","","file") + call inputrestore() + + 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)) + if filelist != "" + let filelist= filelist."\n" + endif + + " mark the list of files + while filelist != "" + if filelist =~ '\n' + let filename = substitute(filelist,'\n.*$','','e') + let filelist = substitute(filelist,'^.\{-}\n\(.*\)$','\1','e') + else + let filename = filelist + let filelist = "" + endif +" call Decho("filelist<".filelist.">") +" call Decho("filename<".filename.">") + call s:NetrwMarkFile(a:islocal,substitute(filename,'^.*/','','')) + endwhile + + else + + " convert displayed listing into a filelist + let eikeep = &ei + let areg = @a + silent %y a + set ei=all ma + 1split + enew + silent norm! "ap + 2 + let bannercnt= search('^" =====','W') + exe "silent 1,".bannercnt."d" + set bt=nofile + if g:netrw_liststyle == s:LONGLIST + silent %s/\s\{2,}\S.*$//e + elseif g:netrw_liststyle == s:WIDELIST + silent %s/\s\{2,}/\r/ge + elseif g:netrw_liststyle == s:TREELIST + silent %s/^| //e + silent! g/^ .*$/d + endif + exe "silent! v/".escape(regexp,'/')."/d" + let filelist= getline(1,line("$")) + q! + for filename in filelist + call s:NetrwMarkFile(a:islocal,substitute(filename,'^.*/','','')) + endfor + unlet filelist + let @a = areg + let &ei = eikeep + endif + +" call Dret("s:NetrwMarkFileRegexp") +endfun + +" --------------------------------------------------------------------- +" s:NetrwMarkFileTag: This function, invoked by mT, applies {{{2 +" g:netrw_ctags to marked files +fun! s:NetrwMarkFileTag(islocal) +" call Dfunc("s:NetrwMarkFileTag(islocal=".a:islocal.")") + let svpos= netrw#NetrwSavePosn() + + 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') +" call Decho("netrwmarkfilelist<".netrwmarkfilelist.">") + + if a:islocal + if executable(g:netrw_ctags) + if g:netrw_shq != "'" + let netrwmarkfilelist= substitute(netrwmarkfilelist,"'",g:netrw_shq,'g') + endif +" call Decho("call system(".g:netrw_ctags." ".netrwmarkfilelist.")") + call system(g:netrw_ctags." ".netrwmarkfilelist) + else + call netrw#ErrorMsg(s:ERROR,"g:netrw_ctags<".g:netrw_ctags."> is not executable!",51) + endif + else + let cmd= s:RemoteSystem(g:netrw_ctags." ".netrwmarkfilelist) + call netrw#NetrwObtain(a:islocal,"tags") + let curdir= b:netrw_curdir + 1split + e tags + let path= substitute(curdir,'^\(.*\)/[^/]*$','\1/','') +" call Decho("curdir<".curdir."> path<".path.">") + exe '%s/\t\(\S\+\)\t/\t'.escape(path,'/').'\1\t/e' + wq! + endif + 2match none + call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) + call netrw#NetrwRestorePosn(svpos) + endif + +" call Dret("s:NetrwMarkFileTag") +endfun + +" --------------------------------------------------------------------- + " s:NetrwMarkFileTgt: {{{2 +fun! s:NetrwMarkFileTgt(islocal) +" call Dfunc("s:NetrwMarkFileTgt(islocal=".a:islocal.")") + let svpos= netrw#NetrwSavePosn() + + 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 + endif + + call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) + call netrw#NetrwRestorePosn(svpos) +" call Dret("s:NetrwMarkFileTgt") +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 + call netrw#NetrwObtain(a:islocal,fname) + endfor + unlet s:netrwmarkfilelist + unlet s:netrwmarkfilemtch + 2match none + else + call netrw#NetrwObtain(a:islocal,expand("")) + endif + +" call Dret("NetrwObtain") +endfun + +" --------------------------------------------------------------------- +" netrw#NetrwObtain: {{{2 +fun! netrw#NetrwObtain(islocal,fname,...) +" call Dfunc("netrw#NetrwObtain(islocal=".a:islocal." fname<".a:fname.">) a:0=".a:0) + " NetrwStatusLine support - for obtaining support + + if a:islocal + + " obtain local file from getcwd() to b:netrw_curdir + if exists("b:netrw_curdir") && getcwd() != b:netrw_curdir + let fname= expand("") + let fcopy= readfile(b:netrw_curdir."/".fname,"b") + call writefile(fcopy,getcwd()."/".fname,"b") + elseif !exists("b:netrw_curdir") + call netrw#ErrorMsg(s:ERROR,"local browsing directory doesn't exist!",36) + else + call netrw#ErrorMsg(s:WARNING,"local browsing directory and current directory are identical",37) + endif + + else + + " obtain a remote file to local directory (see tgtdir below) + call s:SetupNetrwStatusLine('%f %h%m%r%=%9*Obtaining '.a:fname) + + " set up target directory (default is vim's idea of the current directory) + if a:0 > 0 + let tgtdir= a:1 + else + let tgtdir= '.' + endif +" call Decho("tgtdir<".tgtdir.">") + if exists("w:netrw_method") && w:netrw_method =~ '[235]' +" call Decho("method=".w:netrw_method) + if executable("ftp") +" call Decho("ftp is executable, method=".w:netrw_method) + let curdir = b:netrw_curdir + let path = substitute(curdir,'ftp://[^/]\+/','','e') + let curline= line(".") + let endline= line("$")+1 + setlocal ma noro + keepjumps $ +" call Decho("getcwd<".getcwd().">") +" call Decho("curdir<".curdir.">") +" call Decho("path<".path.">") +" call Decho("curline=".curline) +" call Decho("endline=".endline) + + "......................................... + if w:netrw_method == 2 + " ftp + <.netrc>: Method #2 + setlocal ff=unix + if path != "" + put ='cd '.path +" call Decho("ftp: cd ".path) + endif + if tgtdir != '.' + put ='lcd '.tgtdir + endif + put ='get '.a:fname +" call Decho("ftp: get ".a:fname) + put ='quit' +" call Decho("ftp: quit") + if exists("g:netrw_port") && g:netrw_port != "" +" call Decho("exe ".g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) + exe g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port + else +" call Decho("exe ".g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine) + exe g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine + endif + + "......................................... + elseif w:netrw_method == 3 + " ftp + machine,id,passwd,filename: Method #3 + setlocal ff=unix + if exists("g:netrw_port") && g:netrw_port != "" + put ='open '.g:netrw_machine.' '.g:netrw_port +" call Decho('ftp: open '.g:netrw_machine.' '.g:netrw_port) + else + put ='open '.g:netrw_machine +" call Decho('ftp: open '.g:netrw_machine) + endif + + if exists("g:netrw_ftp") && g:netrw_ftp == 1 + put =g:netrw_uid + put ='\"'.g:netrw_passwd.'\"' +" call Decho('ftp: g:netrw_uid') +" call Decho('ftp: g:netrw_passwd') + else + put ='user \"'.g:netrw_uid.'\" \"'.g:netrw_passwd.'\"' +" call Decho('user '.g:netrw_uid.' '.g:netrw_passwd) + endif + + if path != "" + put ='cd '.path +" call Decho('cd '.a:path) + endif + if tgtdir != '.' + put ='lcd '.tgtdir + endif + put ='get '.a:fname +" call Decho("ftp: get ".a:fname) + put ='quit' +" call Decho("ftp: quit") + + " perform ftp: + " -i : turns off interactive prompting from ftp + " -n unix : DON'T use <.netrc>, even though it exists + " -n win32: quit being obnoxious about password +" call Decho("exe ".g:netrw_silentxfer.curline.",$!".g:netrw_ftp_cmd." -i -n") + exe g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i -n" + + "......................................... + else + call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",28) + endif + " restore + exe "silent! ".endline.",$d" + exe "keepjumps ".curline + setlocal noma nomod ro + else +" call Decho("ftp not executable") + if !exists("g:netrw_quiet") + call netrw#ErrorMsg(s:ERROR,"this system doesn't support ftp",29) + endif + " restore status line + let &stl = s:netrw_users_stl + let &laststatus = s:netrw_users_ls + " restore NetrwMethod + if exists("keep_netrw_method") + call s:NetrwMethod(keep_netrw_choice) + let w:netrw_method = keep_netrw_wmethod + endif +" call Dret("NetrwObtain") + return + endif + + "......................................... + else + " scp: Method#4 +" call Decho("using scp") + let curdir = b:netrw_curdir + let path = substitute(curdir,'scp://[^/]\+/','','e') +" call Decho("path<".path.">") + if exists("g:netrw_port") && g:netrw_port != "" + let useport= " ".g:netrw_scpport." ".g:netrw_port + else + let useport= "" + endif +" call Decho("pwd<".getcwd().">") +" call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".path.escape(a:fname,' ?&')." ".tgtdir) + exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".path.escape(a:fname,' ?&')." ".tgtdir + endif + + " restore status line + let &stl = s:netrw_users_stl + let &laststatus = s:netrw_users_ls + redraw! + + " restore NetrwMethod + if exists("keep_netrw_method") + call s:NetrwMethod(keep_netrw_choice) + let w:netrw_method = keep_netrw_wmethod + endif + endif + +" call Dret("netrw#NetrwObtain") +endfun + +" --------------------------------------------------------------------- +" s:NetrwUpload: load fname to tgt (used by NetrwMarkFileCopy()) {{{2 +" fname may itself be a remote or local file +" tgt is assumed to be remote, so NetWrite will be used +" (indirectly an autocmd) +fun! s:NetrwUpload(fname,tgt) +" call Dfunc("s:NetrwUpload(fname<".a:fname."> tgt<".a:tgt.">)") + + 1split +" call Decho("exe e ".a:fname) + exe "e ".escape(a:fname,g:netrw_fname_escape) + if a:tgt =~ '/$' +" call Decho("exe w ".a:tgt.a:fname) + exe "w ".escape(a:tgt.a:fname,g:netrw_fname_escape) + else +" call Decho("exe w ".a:tgt) + exe "w ".escape(a:tgt,g:netrw_fname_escape) + endif + q! + +" call Dret("s:NetrwUpload") +endfun + +" --------------------------------------------------------------------- +" s:NetrwPreview: {{{2 +fun! s:NetrwPreview(path) range +" call Dfunc("NetrwPreview(path<".a:path.">)") + call s:NetrwOptionSave("s:") + if has("quickfix") + if !isdirectory(a:path) + exe (g:netrw_preview? "vert " : "")."pedit ".escape(a:path,g:netrw_fname_escape) + elseif !exists("g:netrw_quiet") + call netrw#ErrorMsg(s:WARNING,"sorry, cannot preview a directory such as <".a:path.">",38) + endif + elseif !exists("g:netrw_quiet") + call netrw#ErrorMsg(s:WARNING,"sorry, to preview your vim needs the quickfix feature compiled in",39) + endif + call s:NetrwOptionRestore("s:") +" call Dret("NetrwPreview") +endfun + +" --------------------------------------------------------------------- +" s:NetrwRefresh: {{{2 +fun! s:NetrwRefresh(islocal,dirname) +" call Dfunc("NetrwRefresh(islocal<".a:islocal.">,dirname=".a:dirname.") hide=".g:netrw_hide." sortdir=".g:netrw_sort_direction) + " at the current time (Mar 19, 2007) all calls to NetrwRefresh() call NetrwBrowseChgDir() first. + " 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("clear buffer<".expand("%")."> with :%d") %d if a:islocal call netrw#LocalBrowseCheck(a:dirname) else - call s:NetBrowse(a:islocal,a:dirname) + call s:NetrwBrowse(a:islocal,a:dirname) endif - call netrw#NetRestorePosn() + call netrw#NetrwRestorePosn() redraw! -" call Dret("NetRefresh") +" call Dret("NetrwRefresh") endfun " --------------------------------------------------------------------- -" NetSplit: mode {{{2 +" 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.">") + call s:NetrwSaveWordPosn() + let svpos= netrw#NetrwSavePosn() + + let g:netrw_sort_by= (g:netrw_sort_by =~ 'n')? 'time' : (g:netrw_sort_by =~ 't')? 'size' : 'name' + norm! 0 + call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) + call netrw#NetrwRestorePosn(svpos) + +" call Dret("s:NetrwSortStyle : netrw_sort_by<".g:netrw_sort_by.">") +endfun + +" --------------------------------------------------------------------- +" s:NetrwSplit: mode {{{2 " =0 : net and o " =1 : net and t " =2 : net and v " =3 : local and o " =4 : local and t " =5 : local and v -fun! s:NetSplit(mode) -" call Dfunc("NetSplit(mode=".a:mode.") alto=".g:netrw_alto." altv=".g:netrw_altv) +fun! s:NetrwSplit(mode) +" call Dfunc("NetrwSplit(mode=".a:mode.") alto=".g:netrw_alto." altv=".g:netrw_altv) call s:SaveWinVars() @@ -2797,16 +3582,16 @@ fun! s:NetSplit(mode) exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s" let s:didsplit= 1 call s:RestoreWinVars() - call s:NetBrowse(0,s:NetBrowseChgDir(0,s:NetGetWord())) + call s:NetrwBrowse(0,s:NetrwBrowseChgDir(0,s:NetrwGetWord())) unlet s:didsplit elseif a:mode == 1 " remote and t - let cursorword = s:NetGetWord() + let cursorword = s:NetrwGetWord() tabnew let s:didsplit= 1 call s:RestoreWinVars() - call s:NetBrowse(0,s:NetBrowseChgDir(0,cursorword)) + call s:NetrwBrowse(0,s:NetrwBrowseChgDir(0,cursorword)) unlet s:didsplit elseif a:mode == 2 @@ -2814,7 +3599,7 @@ fun! s:NetSplit(mode) exe (g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v" let s:didsplit= 1 call s:RestoreWinVars() - call s:NetBrowse(0,s:NetBrowseChgDir(0,s:NetGetWord())) + call s:NetrwBrowse(0,s:NetrwBrowseChgDir(0,s:NetrwGetWord())) unlet s:didsplit elseif a:mode == 3 @@ -2822,18 +3607,18 @@ fun! s:NetSplit(mode) exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s" let s:didsplit= 1 call s:RestoreWinVars() - call netrw#LocalBrowseCheck(s:NetBrowseChgDir(1,s:NetGetWord())) + call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,s:NetrwGetWord())) unlet s:didsplit elseif a:mode == 4 " local and t let netrw_curdir= b:netrw_curdir - let cursorword = s:NetGetWord() + let cursorword = s:NetrwGetWord() tabnew let b:netrw_curdir= netrw_curdir let s:didsplit= 1 call s:RestoreWinVars() - call netrw#LocalBrowseCheck(s:NetBrowseChgDir(1,cursorword)) + call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,cursorword)) unlet s:didsplit elseif a:mode == 5 @@ -2841,21 +3626,21 @@ fun! s:NetSplit(mode) exe (g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v" let s:didsplit= 1 call s:RestoreWinVars() - call netrw#LocalBrowseCheck(s:NetBrowseChgDir(1,s:NetGetWord())) + call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,s:NetrwGetWord())) unlet s:didsplit else - call netrw#ErrorMsg(s:ERROR,"(NetSplit) unsupported mode=".a:mode,45) + call netrw#ErrorMsg(s:ERROR,"(NetrwSplit) unsupported mode=".a:mode,45) endif -" call Dret("NetSplit") +" call Dret("NetrwSplit") endfun " --------------------------------------------------------------------- -" NetBrowseX: allows users to write custom functions to operate on {{{2 +" s:NetrwBrowseX: allows users to write custom functions to operate on {{{2 " files given their extension. Passes 0=local, 1=remote -fun! netrw#NetBrowseX(fname,remote) -" call Dfunc("NetBrowseX(fname<".a:fname."> remote=".a: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) @@ -2895,37 +3680,69 @@ fun! netrw#NetBrowseX(fname,remote) " set up redirection if &srr =~ "%s" - let redir= substitute(&srr,"%s","/dev/null","") + 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(g:netrw_browsex_viewer) + elseif exists("g:netrw_browsex_viewer") && executable(viewer) " call Decho("g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">") -" call Decho("exe silent !".g:netrw_browsex_viewer." '".escape(fname,'%#')."' ".redir) - exe "silent !".g:netrw_browsex_viewer." '".escape(fname,'%#')."'".redir +" 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 "'.escape(fname, '%#').'"') - exe 'silent !start rundll32 url.dll,FileProtocolHandler "'.escape(fname, '%#').'"' +" 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 '".escape(fname,'%#')."' ".redir) - exe "silent !gnome-open '".escape(fname,'%#')."'".redir +" 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 '".escape(fname,'%#')."' ".redir) - exe "silent !kfmclient exec '".escape(fname,'%#')."' ".redir +" 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 @@ -2957,16 +3774,336 @@ fun! netrw#NetBrowseX(fname,remote) redraw! endif -" call Dret("NetBrowseX") +" call Dret("NetrwBrowseX") endfun " --------------------------------------------------------------------- -" NetBrowseFtpCmd: unfortunately, not all ftp servers honor options for ls {{{2 +" Remote Directory Browsing Support: {{{1 +" =========================================== + +" --------------------------------------------------------------------- +" s:NetrwRemoteListing: {{{2 +fun! s:NetrwRemoteListing() +" call Dfunc("s:NetrwRemoteListing() b:netrw_curdir<".b:netrw_curdir.">)") + + call s:RemotePathAnalysis(b:netrw_curdir) + + " sanity check: + if exists("b:netrw_method") && b:netrw_method =~ '[235]' +" call Decho("b:netrw_method=".b:netrw_method) + if !executable("ftp") + if !exists("g:netrw_quiet") + call netrw#ErrorMsg(s:ERROR,"this system doesn't support remote directory listing via ftp",18) + endif + call s:NetrwOptionRestore("w:") +" call Dret("s:NetrwRemoteListing") + return + endif + + elseif !exists("g:netrw_list_cmd") || g:netrw_list_cmd == '' + if !exists("g:netrw_quiet") + if g:netrw_list_cmd == "" + call netrw#ErrorMsg(s:ERROR,g:netrw_ssh_cmd." is not executable on your system",47) + else + call netrw#ErrorMsg(s:ERROR,"this system doesn't support remote directory listing via ".g:netrw_list_cmd,19) + endif + endif + + call s:NetrwOptionRestore("w:") +" call Dret("s:NetrwRemoteListing") + return + endif " (remote handling sanity check) + + if exists("b:netrw_method") +" call Decho("setting w:netrw_method<".b:netrw_method.">") + let w:netrw_method= b:netrw_method + endif + + if s:method == "ftp" + " use ftp to get remote file listing +" call Decho("use ftp to get remote file listing") + let s:method = "ftp" + let listcmd = g:netrw_ftp_list_cmd + if g:netrw_sort_by =~ '^t' + let listcmd= g:netrw_ftp_timelist_cmd + elseif g:netrw_sort_by =~ '^s' + let listcmd= g:netrw_ftp_sizelist_cmd + endif +" call Decho("listcmd<".listcmd."> (using g:netrw_ftp_list_cmd)") + call s:NetrwRemoteFtpCmd(s:path,listcmd) +" exe "keepjumps ".w:netrw_bannercnt.',$g/^./call Decho("raw listing: ".getline("."))' + + if w:netrw_liststyle == s:THINLIST || w:netrw_liststyle == s:WIDELIST || w:netrw_liststyle == s:TREELIST + " shorten the listing +" call Decho("generate short listing") + exe "keepjumps ".w:netrw_bannercnt + + " cleanup + if g:netrw_ftp_browse_reject != "" + exe "silent! g/".g:netrw_ftp_browse_reject."/keepjumps d" + endif + silent! keepjumps %s/\r$//e + + " if there's no ../ listed, then put ./ and ../ in + let line1= line(".") + exe "keepjumps ".w:netrw_bannercnt + let line2= search('^\.\.\/\%(\s\|$\)','cnW') + if line2 == 0 +" call Decho("netrw is putting ./ and ../ into listing") + keepjumps put='../' + keepjumps put='./' + endif + exe "keepjumps ".line1 + keepjumps norm! 0 + +" call Decho("line1=".line1." line2=".line2." line(.)=".line(".")) + if search('^\d\{2}-\d\{2}-\d\{2}\s','n') " M$ ftp site cleanup +" call Decho("M$ ftp cleanup") + exe 'silent! keepjumps '.w:netrw_bannercnt.',$s/^\d\{2}-\d\{2}-\d\{2}\s\+\d\+:\d\+[AaPp][Mm]\s\+\%(\|\d\+\)\s\+//' + else " normal ftp cleanup +" call Decho("normal ftp cleanup") + exe 'silent! keepjumps '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2/e' + exe "silent! keepjumps ".w:netrw_bannercnt.',$g/ -> /s# -> .*/$#/#e' + exe "silent! keepjumps ".w:netrw_bannercnt.',$g/ -> /s# -> .*$#/#e' + endif + endif + + else + " use ssh to get remote file listing {{{3 +" call Decho("use ssh to get remote file listing: s:netrw_shq<".g:netrw_shq."> s:path<".s:path."> g:netrw_cd_escape<".g:netrw_cd_escape.">") + let listcmd= s:MakeSshCmd(g:netrw_list_cmd) +" call Decho("listcmd<".listcmd."> (using g:netrw_list_cmd)") + if g:netrw_scp_cmd =~ '^pscp' +" call Decho("1: exe silent r! ".listcmd.g:netrw_shq.s:path.g:netrw_shq) + exe "silent r! ".listcmd.g:netrw_shq.s:path.g:netrw_shq + " remove rubbish and adjust listing format of 'pscp' to 'ssh ls -FLa' like + g/^Listing directory/d + g/^d[-rwx][-rwx][-rwx]/s+$+/+e + silent g/^l[-rwx][-rwx][-rwx]/s+$+@+e + if g:netrw_liststyle != s:LONGLIST + g/^[dlsp-][-rwx][-rwx][-rwx]/s/^.*\s\(\S\+\)$/\1/e + endif + else + if s:path == "" +" call Decho("2: exe silent r! ".listcmd) + exe "silent r! ".listcmd + else +" call Decho("3: exe silent r! ".listcmd." ".g:netrw_shq.s:path.g:netrw_shq) + exe "silent r! ".listcmd." ".g:netrw_shq.s:path.g:netrw_shq + endif + endif + + " cleanup + if g:netrw_ftp_browse_reject != "" +" call Decho("(cleanup) exe silent! g/".g:netrw_ssh_browse_reject."/keepjumps d") + exe "silent! g/".g:netrw_ssh_browse_reject."/keepjumps d" + endif + endif + + if w:netrw_liststyle == s:LONGLIST + " do a long listing; these substitutions need to be done prior to sorting {{{3 +" call Decho("fix long listing:") + + if s:method == "ftp" + " cleanup + exe "keepjumps ".w:netrw_bannercnt + while getline(".") =~ g:netrw_ftp_browse_reject + keepjumps d + endwhile + " if there's no ../ listed, then put ./ and ../ in + let line1= line(".") + keepjumps 1 + silent keepjumps call search('^\.\.\/\%(\s\|$\)','W') + let line2= line(".") + if line2 == 0 + exe 'keepjumps '.w:netrw_bannercnt."put='./'" + if b:netrw_curdir != '/' + exe 'keepjumps '.w:netrw_bannercnt."put='../'" + endif + endif + exe "keepjumps ".line1 + keepjumps norm! 0 + endif + + if search('^\d\{2}-\d\{2}-\d\{2}\s','n') " M$ ftp site cleanup +" call Decho("M$ ftp site listing cleanup") + exe 'silent! keepjumps '.w:netrw_bannercnt.',$s/^\(\d\{2}-\d\{2}-\d\{2}\s\+\d\+:\d\+[AaPp][Mm]\s\+\%(\|\d\+\)\s\+\)\(\w.*\)$/\2\t\1/' + elseif exists("w:netrw_bannercnt") && w:netrw_bannercnt <= line("$") +" call Decho("normal ftp site listing cleanup: bannercnt=".w:netrw_bannercnt." line($)=".line("$")) + exe 'silent keepjumps '.w:netrw_bannercnt.',$s/ -> .*$//e' + exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2\t\1/e' + exe 'silent keepjumps '.w:netrw_bannercnt + endif + endif + +" if exists("w:netrw_bannercnt") && w:netrw_bannercnt <= line("$") " Decho +" exe "keepjumps ".w:netrw_bannercnt.',$g/^./call Decho("listing: ".getline("."))' +" endif " Decho +" call Dret("s:NetrwRemoteListing") +endfun + +" --------------------------------------------------------------------- +" s:NetrwRemoteRm: remove/delete a remote file or directory {{{2 +fun! s:NetrwRemoteRm(usrhost,path) range +" call Dfunc("s:NetrwRemoteRm(usrhost<".a:usrhost."> path<".a:path.">) virtcol=".virtcol(".")) +" call Decho("firstline=".a:firstline." lastline=".a:lastline) + let svpos= netrw#NetrwSavePosn() + + let all= 0 + if exists("s:netrwmarkfilelist") + " remove all marked files + for fname in s:netrwmarkfilelist + let ok= s:NetrwRemoteRmFile(a:path,fname,all) + if ok =~ 'q\%[uit]' + break + elseif ok =~ 'a\%[ll]' + let all= 1 + endif + endfor + unlet s:netrwmarkfilelist + unlet s:netrwmarkfilemtch + 2match none + + else + " remove files specified by range + + " preparation for removing multiple files/directories + let ctr= a:firstline + + " remove multiple files and directories + while ctr <= a:lastline + exe ctr + let ok= s:NetrwRemoteRmFile(a:path,s:NetrwGetWord(),all) + if ok =~ 'q\%[uit]' + break + elseif ok =~ 'a\%[ll]' + let all= 1 + endif + let ctr= ctr + 1 + endwhile + endif + + " refresh the (remote) directory listing +" call Decho("refresh remote directory listing") + call s:NetrwRefresh(0,s:NetrwBrowseChgDir(0,'./')) + call netrw#NetrwRestorePosn(svpos) + +" call Dret("s:NetrwRemoteRm") +endfun + +" --------------------------------------------------------------------- +" s:NetrwRemoteRmFile: {{{2 +fun! s:NetrwRemoteRmFile(path,rmfile,all) +" call Dfunc("s:NetrwRemoteRmFile(path<".a:path."> rmfile<".a:rmfile.">) all=".a:all) + + let all= a:all + let ok = "" + + if a:rmfile !~ '^"' && (a:rmfile =~ '@$' || a:rmfile !~ '[\/]$') + " attempt to remove file +" call Decho("attempt to remove file (all=".all.")") + if !all + echohl Statement + call inputsave() + let ok= input("Confirm deletion of file<".a:rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") + call inputrestore() + echohl NONE + if ok == "" + let ok="no" + endif + let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e') + if ok =~ 'a\%[ll]' + let all= 1 + endif + endif + + if all || ok =~ 'y\%[es]' || ok == "" + if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3) + silent! keepjumps .,$d + call s:NetrwRemoteFtpCmd(a:path,"delete ".a:rmfile) + else + let netrw_rm_cmd= s:MakeSshCmd(g:netrw_rm_cmd) +" call Decho("netrw_rm_cmd<".netrw_rm_cmd.">") + if !exists("b:netrw_curdir") + call netrw#ErrorMsg(s:ERROR,"for some reason b:netrw_curdir doesn't exist!",53) + let ok="q" + else + let remotedir= substitute(b:netrw_curdir,'^.*//[^/]\+/\(.*\)$','\1','') +" call Decho("netrw_rm_cmd<".netrw_rm_cmd.">") +" call Decho("remotedir<".remotedir.">") +" call Decho("rmfile<".a:rmfile.">") + if remotedir != "" + let netrw_rm_cmd= netrw_rm_cmd." ".remotedir.escape(a:rmfile,g:netrw_cd_escape) + else + let netrw_rm_cmd= netrw_rm_cmd." ".escape(a:rmfile,g:netrw_cd_escape) + endif +" call Decho("call system(".netrw_rm_cmd.")") + let ret= system(netrw_rm_cmd) + if ret != 0 + call netrw#ErrorMsg(s:WARNING,"cmd<".netrw_rm_cmd."> failed",60) + endif +" call Decho("returned=".ret." errcode=".v:shell_error) + endif + endif + elseif ok =~ 'q\%[uit]' + break + endif + + else + " attempt to remove directory +" call Decho("attempt to remove directory") + if !all + call inputsave() + let ok= input("Confirm deletion of directory<".a:rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") + call inputrestore() + if ok == "" + let ok="no" + endif + let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e') + if ok =~ 'a\%[ll]' + let all= 1 + endif + endif + + if all || ok =~ 'y\%[es]' || ok == "" + if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3) + call s:NetrwRemoteFtpCmd(a:path,"rmdir ".a:rmfile) + else + let rmfile = substitute(a:path.a:rmfile,'/$','','') + let netrw_rmdir_cmd = s:MakeSshCmd(g:netrw_rmdir_cmd).' '.rmfile +" call Decho("attempt to remove dir: system(".netrw_rmdir_cmd.")") + let ret= s:System("system",netrw_rmdir_cmd) +" call Decho("returned=".ret." errcode=".v:shell_error) + + if v:shell_error != 0 +" call Decho("v:shell_error not 0") + let netrw_rmf_cmd= s:MakeSshCmd(g:netrw_rmf_cmd).' '.substitute(rmfile,'[\/]$','','e') +" call Decho("2nd attempt to remove dir: system(".netrw_rmf_cmd.")") + let ret= s:System("system",netrw_rmf_cmd) +" call Decho("returned=".ret." errcode=".v:shell_error) + + if v:shell_error != 0 && !exists("g:netrw_quiet") + call netrw#ErrorMsg(s:ERROR,"unable to remove directory<".rmfile."> -- is it empty?",22) + endif + endif + endif + + elseif ok =~ 'q\%[uit]' + break + endif + endif + +" call Dret("s:NetrwRemoteRmFile ".ok) + return ok +endfun + +" --------------------------------------------------------------------- +" s:NetrwRemoteFtpCmd: unfortunately, not all ftp servers honor options for ls {{{2 " This function assumes that a long listing will be received. Size, time, " and reverse sorts will be requested of the server but not otherwise " enforced here. -fun! s:NetBrowseFtpCmd(path,listcmd) -" call Dfunc("NetBrowseFtpCmd(path<".a:path."> listcmd<".a:listcmd.">) netrw_method=".w:netrw_method) +fun! s:NetrwRemoteFtpCmd(path,listcmd) +" call Dfunc("NetrwRemoteFtpCmd(path<".a:path."> listcmd<".a:listcmd.">) netrw_method=".w:netrw_method) " call Decho("line($)=".line("$")." bannercnt=".w:netrw_bannercnt) " because WinXX ftp uses unix style input @@ -2979,7 +4116,7 @@ fun! s:NetBrowseFtpCmd(path,listcmd) exe "silent! keepjumps ".w:netrw_bannercnt.",$d" "......................................... - if w:netrw_method == 2 || w:netrw_method == 5 + if w:netrw_method == 2 || w:netrw_method == 5 " ftp + <.netrc>: Method #2 if a:path != "" put ='cd \"'.a:path.'\"' @@ -2989,13 +4126,13 @@ fun! s:NetBrowseFtpCmd(path,listcmd) " call Decho("filter input: ".getline(".")) endif exe "put ='".a:listcmd."'" -" exe w:netrw_bannercnt.',$g/^./call Decho("ftp#".line(".").": ".getline("."))' +" exe "keepjumps ".w:netrw_bannercnt.',$g/^./call Decho("ftp#".line(".").": ".getline("."))' if exists("g:netrw_port") && g:netrw_port != "" " call Decho("exe ".g:netrw_silentxfer.w:netrw_bannercnt.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) - exe g:netrw_silentxfer.w:netrw_bannercnt.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port + exe g:netrw_silentxfer." keepjumps ".w:netrw_bannercnt.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port else " call Decho("exe ".g:netrw_silentxfer.w:netrw_bannercnt.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine) - exe g:netrw_silentxfer.w:netrw_bannercnt.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine + exe g:netrw_silentxfer." keepjumps ".w:netrw_bannercnt.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine endif "......................................... @@ -3062,98 +4199,92 @@ fun! s:NetBrowseFtpCmd(path,listcmd) " restore settings let &ff= ffkeep -" call Dret("NetBrowseFtpCmd") +" call Dret("NetrwRemoteFtpCmd") endfun " --------------------------------------------------------------------- -" NetListHide: uses [range]g~...~d to delete files that match comma {{{2 -" separated patterns given in g:netrw_list_hide -fun! s:NetListHide() -" call Dfunc("NetListHide() hide=".g:netrw_hide." listhide<".g:netrw_list_hide.">") +" s:NetrwRemoteRename: rename a remote file or directory {{{2 +fun! s:NetrwRemoteRename(usrhost,path) range +" call Dfunc("NetrwRemoteRename(usrhost<".a:usrhost."> path<".a:path.">)") - " find a character not in the "hide" string to use as a separator for :g and :v commands - " How-it-works: take the hiding command, convert it into a range. Duplicate - " characters don't matter. Remove all such characters from the '/~...90' - " string. Use the first character left as a separator character. - let listhide= g:netrw_list_hide - let sep = strpart(substitute('/~@#$%^&*{};:,<.>?|1234567890','['.escape(listhide,'-]^\').']','','ge'),1,1) -" call Decho("sep=".sep) + " preparation for removing multiple files/directories + let svpos = netrw#NetrwSavePosn() + let ctr = a:firstline + let rename_cmd = s:MakeSshCmd(g:netrw_rename_cmd) - while listhide != "" - if listhide =~ ',' - let hide = substitute(listhide,',.*$','','e') - let listhide = substitute(listhide,'^.\{-},\(.*\)$','\1','e') - else - let hide = listhide - let listhide= "" - endif + " rename files given by the markfilelist + if exists("s:netrwmarkfilelist") + for oldname in s:netrwmarkfilelist +" call Decho("oldname<".oldname.">") + if exists("subfrom") + let newname= substitute(oldname,subfrom,subto,'') +" call Decho("subfrom<".subfrom."> subto<".subto."> newname<".newname.">") + else + call inputsave() + let newname= input("Moving ".oldname." to : ",oldname) + call inputrestore() + if newname =~ '^s/' + let subfrom = substitute(newname,'^s/\([^/]*\)/.*/$','\1','') + let subto = substitute(newname,'^s/[^/]*/\(.*\)/$','\1','') + let newname = substitute(oldname,subfrom,subto,'') +" call Decho("subfrom<".subfrom."> subto<".subto."> newname<".newname.">") + endif + endif + + if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3) + call s:NetrwRemoteFtpCmd(a:path,"rename ".oldname." ".newname) + else + let oldname= a:path.oldname + let newname= a:path.newname +" call Decho("system(rename_cmd".' "'.escape(oldname," ").'" "'.escape(newname,g:netrw_cd_escape).'"') + let ret= s:System("system",rename_cmd.' "'.escape(oldname,g:netrw_cd_escape).'" "'.escape(newname,g:netrw_cd_escape).'"') + endif - " Prune the list by hiding any files which match - if g:netrw_hide == 1 -" call Decho("hiding<".hide."> listhide<".listhide.">") - exe 'silent keepjumps '.w:netrw_bannercnt.',$g'.sep.hide.sep.'d' - elseif g:netrw_hide == 2 -" call Decho("showing<".hide."> listhide<".listhide.">") - exe 'silent keepjumps '.w:netrw_bannercnt.',$g'.sep.hide.sep.'s@^@ /-KEEP-/ @' - endif - endwhile - if g:netrw_hide == 2 - exe 'silent keepjumps '.w:netrw_bannercnt.',$v@^ /-KEEP-/ @d' - exe 'silent keepjumps '.w:netrw_bannercnt.',$s@^\%( /-KEEP-/ \)\+@@e' + endfor + 2match none + unlet s:netrwmarkfilelist + unlet s:netrwmarkfilemtch + + else + + " attempt to rename files/directories + while ctr <= a:lastline + exe "keepjumps ".ctr + + let oldname= s:NetrwGetWord() +" call Decho("oldname<".oldname.">") + + call inputsave() + let newname= input("Moving ".oldname." to : ",oldname) + call inputrestore() + + if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3) + call s:NetrwRemoteFtpCmd(a:path,"rename ".oldname." ".newname) + else + let oldname= a:path.oldname + let newname= a:path.newname +" call Decho("system(rename_cmd".' "'.escape(oldname," ").'" "'.escape(newname,g:netrw_cd_escape).'"') + let ret= s:System("system",rename_cmd.' "'.escape(oldname,g:netrw_cd_escape).'" "'.escape(newname,g:netrw_cd_escape).'"') + endif + + let ctr= ctr + 1 + endwhile endif -" call Dret("NetListHide") + " refresh the directory + call s:NetrwRefresh(0,s:NetrwBrowseChgDir(0,'./')) + call netrw#NetrwRestorePosn(svpos) + +" call Dret("NetrwRemoteRename") endfun " --------------------------------------------------------------------- -" NetHideEdit: allows user to edit the file/directory hiding list -fun! s:NetHideEdit(islocal) -" call Dfunc("NetHideEdit(islocal=".a:islocal.")") - - " save current cursor position - let s:nhe_curpos= getpos(".") - - " get new hiding list from user - call inputsave() - let newhide= input("Edit Hiding List: ",g:netrw_list_hide) - call inputrestore() - let g:netrw_list_hide= newhide -" call Decho("new g:netrw_list_hide<".g:netrw_list_hide.">") - - " refresh the listing - silent call s:NetRefresh(a:islocal,s:NetBrowseChgDir(a:islocal,"./")) - - " restore cursor position - call setpos('.',s:nhe_curpos) - unlet s:nhe_curpos - -" call Dret("NetHideEdit") -endfun - -" --------------------------------------------------------------------- -" NetSortSequence: allows user to edit the sorting sequence -fun! s:NetSortSequence(islocal) -" call Dfunc("NetSortSequence(islocal=".a:islocal.")") - - call inputsave() - let newsortseq= input("Edit Sorting Sequence: ",g:netrw_sort_sequence) - call inputrestore() - - " refresh the listing - let g:netrw_sort_sequence= newsortseq - call netrw#NetSavePosn() - call s:NetRefresh(a:islocal,s:NetBrowseChgDir(a:islocal,'./')) - -" call Dret("NetSortSequence") -endfun - -" --------------------------------------------------------------------- -" NetListStyle: {{{2 +" s:NetrwListStyle: {{{2 " islocal=0: remote browsing " =1: local browsing -fun! s:NetListStyle(islocal) -" call Dfunc("NetListStyle(islocal=".a:islocal.") w:netrw_liststyle=".w:netrw_liststyle) - let fname = s:NetGetWord() +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.">") @@ -3187,31 +4318,32 @@ fun! s:NetListStyle(islocal) endif setlocal ma noro - " clear buffer - this will cause NetBrowse/LocalBrowseCheck to do a refresh + " clear buffer - this will cause NetrwBrowse/LocalBrowseCheck to do a refresh " call Decho("clear buffer<".expand("%")."> with :%d") %d " refresh the listing - call netrw#NetSavePosn() - call s:NetRefresh(a:islocal,s:NetBrowseChgDir(a:islocal,'./')) + 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 w:netrw_bannercnt + exe "keepjumps ".w:netrw_bannercnt endif -" call Dret("NetListStyle".(exists("w:netrw_liststyle")? ' : w:netrw_liststyle='.w:netrw_liststyle : "")) +" call Dret("NetrwListStyle".(exists("w:netrw_liststyle")? ' : w:netrw_liststyle='.w:netrw_liststyle : "")) endfun " --------------------------------------------------------------------- -" NetWideListing: {{{2 -fun! s:NetWideListing() +" s:NetrwWideListing: {{{2 +fun! s:NetrwWideListing() if w:netrw_liststyle == s:WIDELIST -" call Dfunc("NetWideListing() w:netrw_liststyle=".w:netrw_liststyle.' fo='.&fo.' l:fo='.&l:fo) +" 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 @@ -3221,7 +4353,7 @@ fun! s:NetWideListing() 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("NetWideListing") +" call Dret("NetrwWideListing") return endif " call Decho("max file strlen+1=".b:netrw_cpf) @@ -3256,16 +4388,16 @@ fun! s:NetWideListing() silent! let @*= keepregstar exe "silent keepjumps ".w:netrw_bannercnt.',$s/\s\+$//e' setlocal noma nomod ro -" call Dret("NetWideListing") +" call Dret("NetrwWideListing") endif endfun " --------------------------------------------------------------------- -" NetTreeDir: determine tree directory given current cursor position {{{2 +" s:NetrwTreeDir: determine tree directory given current cursor position {{{2 " (full path directory with trailing slash returned) -fun! s:NetTreeDir() -" call Dfunc("NetTreeDir() curline#".line(".")."<".getline(".")."> b:netrw_curdir<".b:netrw_curdir."> tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%").">") +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.">") @@ -3288,7 +4420,7 @@ fun! s:NetTreeDir() " now force a refresh " call Decho("clear buffer<".expand("%")."> with :%d") keepjumps %d -" call Dret("NetTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">") +" call Dret("NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">") return b:netrw_curdir endif @@ -3322,14 +4454,14 @@ fun! s:NetTreeDir() " setlocal ma noro " keepjumps %d -" call Dret("NetTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">") +" call Dret("NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">") return treedir endfun " --------------------------------------------------------------------- -" NetTreeDisplay: recursive tree display {{{2 -fun! s:NetTreeDisplay(dir,depth) -" call Dfunc("NetTreeDisplay(dir<".a:dir."> depth<".a:depth.">)") +" 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 @@ -3366,23 +4498,23 @@ fun! s:NetTreeDisplay(dir,depth) " 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:NetTreeDisplay(direntry,depth) + 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:NetTreeDisplay(direntry.'/',depth) + 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("NetTreeDisplay") +" call Dret("NetrwTreeDisplay") endfun " --------------------------------------------------------------------- -" NetTreeListing: displays tree listing from treetop on down, using NetTreeDisplay() {{{2 -fun! s:NetTreeListing(dirname) +" s:NetrwTreeListing: displays tree listing from treetop on down, using NetrwTreeDisplay() {{{2 +fun! s:NetrwTreeListing(dirname) if w:netrw_liststyle == s:TREELIST -" call Dfunc("NetTreeListing() bufname<".expand("%").">") +" call Dfunc("NetrwTreeListing() bufname<".expand("%").">") " call Decho("curdir<".a:dirname.">") " update the treetop @@ -3390,7 +4522,7 @@ fun! s:NetTreeListing(dirname) 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) && strlen(a:dirname) < strlen(w:netrw_treetop)) || a:dirname !~ ('^'.w:netrw_treetop) + 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 @@ -3416,45 +4548,45 @@ fun! s:NetTreeListing(dirname) endif " display from treetop on down - call s:NetTreeDisplay(w:netrw_treetop,"") + call s:NetrwTreeDisplay(w:netrw_treetop,"") " place cursor if !exists("s:nbcd_curpos") if fname != "" -" call Decho("(NetTreeListing) place cursor <".fname.">") +" call Decho("(NetrwTreeListing) place cursor <".fname.">") call search('\<'.fname.'\>','cw') elseif exists("w:netrw_bannercnt") - exe (w:netrw_bannercnt+1) -" call Decho("(NetTreeListing) place cursor line#".(w:netrw_bannercnt+1)) + exe "keepjumps ".(w:netrw_bannercnt+1) +" call Decho("(NetrwTreeListing) place cursor line#".(w:netrw_bannercnt+1)) endif endif -" call Dret("NetTreeListing : bufname<".expand("%").">") +" call Dret("NetrwTreeListing : bufname<".expand("%").">") endif endfun " --------------------------------------------------------------------- -" NetSaveWordPosn: used by the "s" command in both remote and local {{{2 -" browsing. Along with NetRestoreWordPosn(), it keeps the cursor on +" 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:NetSaveWordPosn() -" call Dfunc("NetSaveWordPosn()") - let s:netrw_saveword= '^'.escape(getline("."),s:netrw_cd_escape).'$' -" call Dret("NetSaveWordPosn : saveword<".s:netrw_saveword.">") +fun! s:NetrwSaveWordPosn() +" call Dfunc("NetrwSaveWordPosn()") + let s:netrw_saveword= '^'.escape(getline("."),g:netrw_cd_escape).'$' +" call Dret("NetrwSaveWordPosn : saveword<".s:netrw_saveword.">") endfun " --------------------------------------------------------------------- -" NetRestoreWordPosn: used by the "s" command; see NetSaveWordPosn() above {{{2 -fun! s:NetRestoreWordPosn() -" call Dfunc("NetRestoreWordPosn()") +" 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("NetRestoreWordPosn") +" call Dret("NetrwRestoreWordPosn") endfun " --------------------------------------------------------------------- -" NetMakeDir: this function makes a directory (both local and remote) {{{2 -fun! s:NetMakeDir(usrhost) -" call Dfunc("NetMakeDir(usrhost<".a:usrhost.">)") +" 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 @@ -3465,7 +4597,7 @@ fun! s:NetMakeDir(usrhost) " call Decho("newdirname<".newdirname.">") if newdirname == "" -" call Dret("NetMakeDir : user aborted with bare ") +" call Dret("NetrwMakeDir : user aborted with bare ") return endif @@ -3479,14 +4611,14 @@ fun! s:NetMakeDir(usrhost) if !exists("g:netrw_quiet") call netrw#ErrorMsg(s:WARNING,"<".newdirname."> is already a directory!",24) endif -" call Dret("NetMakeDir : directory<".newdirname."> exists previously") +" 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("NetMakeDir : file<".newdirname."> exists previously") +" call Dret("NetrwMakeDir : file<".newdirname."> exists previously") return endif @@ -3495,7 +4627,7 @@ fun! s:NetMakeDir(usrhost) if exists("*mkdir") call mkdir(fullnewdir,"p") else - let netrw_origdir= s:NetGetcwd(1) + 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) @@ -3510,8 +4642,9 @@ fun! s:NetMakeDir(usrhost) if v:shell_error == 0 " refresh listing " call Decho("refresh listing") - call netrw#NetSavePosn() - call s:NetRefresh(1,s:NetBrowseChgDir(1,'./')) + 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 @@ -3525,27 +4658,28 @@ fun! s:NetMakeDir(usrhost) exe "silent! !".mkdircmd." ".g:netrw_shq.newdirname.g:netrw_shq if v:shell_error == 0 " refresh listing - call netrw#NetSavePosn() - call s:NetRefresh(0,s:NetBrowseChgDir(0,'./')) + 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("NetMakeDir") +" call Dret("NetrwMakeDir") endfun " --------------------------------------------------------------------- -" NetBookmarkDir: {{{2 +" 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:NetBookmarkDir(chg,curdir) -" call Dfunc("NetBookmarkDir(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) +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 @@ -3666,17 +4800,20 @@ fun! s:NetBookmarkDir(chg,curdir) echo "Sorry, no successor directory exists yet" endif endif - call s:NetBookmarkMenu() -" call Dret("NetBookmarkDir") + call s:NetrwBookmarkMenu() +" call Dret("NetrwBookmarkDir") endfun " --------------------------------------------------------------------- -" NetBookmarkMenu: {{{2 -fun! s:NetBookmarkMenu() +" 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("NetBookmarkMenu() bookmarkcnt=".g:NETRW_BOOKMARKMAX." histcnt=".g:NETRW_DIRHIST_CNT." menucnt=".s:netrw_menucnt) +" 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' @@ -3712,202 +4849,35 @@ fun! s:NetBookmarkMenu() endif endwhile endif -" call Dret("NetBookmarkMenu") +" call Dret("NetrwBookmarkMenu") endfun " --------------------------------------------------------------------- -" NetObtain: obtain file under cursor (for remote browsing support) {{{2 -fun! netrw#NetObtain(vismode,...) range -" call Dfunc("NetObtain(vismode=".a:vismode.") a:0=".a:0) - - if a:vismode == 0 - " normal mode - let fname= expand("") -" call Decho("no arguments, use <".fname.">") - elseif a:vismode == 1 - " visual mode - let keeprega = @a - norm! gv"ay - if g:netrw_liststyle == s:THINLIST - " thin listing - let filelist= split(@a,'\n') - elseif g:netrw_liststyle == s:LONGLIST - " long listing - let filelist= split(substitute(@a,'\t.\{-}\n','\n','g'),'\n') - else - " wide listing - let filelist = split(substitute(@a,'\s\{2,}','\n','g'),'\n') - let filelist = map(filelist,'substitute(v:val,"^\\s\\+","","")') - let filelist = map(filelist,'substitute(v:val,"\\s\\+$","","")') - endif -" call Decho("filelist<".string(filelist).">") - let @a= keeprega - for f in filelist - if f != "" - call netrw#NetObtain(2,f) - endif - endfor -" call Dret("NetObtain : visual mode handler") - return - elseif a:vismode == 2 - " multiple file mode - let fname= a:1 -" call Decho("visual mode handling: <".fname.">") - endif - - " NetrwStatusLine support - for obtaining support - call s:SetupNetrwStatusLine('%f %h%m%r%=%9*Obtaining '.fname) - - if exists("w:netrw_method") && w:netrw_method =~ '[235]' -" call Decho("method=".w:netrw_method) - if executable("ftp") -" call Decho("ftp is executable, method=".w:netrw_method) - let curdir = b:netrw_curdir - let path = substitute(curdir,'ftp://[^/]\+/','','e') - let curline= line(".") - let endline= line("$")+1 - setlocal ma noro - keepjumps $ -" call Decho("getcwd<".getcwd().">") -" call Decho("curdir<".curdir.">") -" call Decho("path<".path.">") -" call Decho("curline=".curline) -" call Decho("endline=".endline) - - "......................................... - if w:netrw_method == 2 - " ftp + <.netrc>: Method #2 - setlocal ff=unix - if path != "" - put ='cd '.path -" call Decho("ftp: cd ".path) - endif - put ='get '.fname -" call Decho("ftp: get ".fname) - put ='quit' -" call Decho("ftp: quit") - if exists("g:netrw_port") && g:netrw_port != "" -" call Decho("exe ".g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) - exe g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port - else -" call Decho("exe ".g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine) - exe g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine - endif - - "......................................... - elseif w:netrw_method == 3 - " ftp + machine,id,passwd,filename: Method #3 - setlocal ff=unix - if exists("g:netrw_port") && g:netrw_port != "" - put ='open '.g:netrw_machine.' '.g:netrw_port -" call Decho('ftp: open '.g:netrw_machine.' '.g:netrw_port) - else - put ='open '.g:netrw_machine -" call Decho('ftp: open '.g:netrw_machine) - endif - - if exists("g:netrw_ftp") && g:netrw_ftp == 1 - put =g:netrw_uid - put ='\"'.g:netrw_passwd.'\"' -" call Decho('ftp: g:netrw_uid') -" call Decho('ftp: g:netrw_passwd') - else - put ='user \"'.g:netrw_uid.'\" \"'.g:netrw_passwd.'\"' -" call Decho('user '.g:netrw_uid.' '.g:netrw_passwd) - endif - - if path != "" - put ='cd '.path -" call Decho('cd '.a:path) - endif - put ='get '.fname -" call Decho("ftp: get ".fname) - put ='quit' -" call Decho("ftp: quit") - - " perform ftp: - " -i : turns off interactive prompting from ftp - " -n unix : DON'T use <.netrc>, even though it exists - " -n win32: quit being obnoxious about password -" call Decho("exe ".g:netrw_silentxfer.curline.",$!".g:netrw_ftp_cmd." -i -n") - exe g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i -n" - - "......................................... - else - call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",28) - endif - " restore - exe "silent! ".endline.",$d" - exe "keepjumps ".curline - setlocal noma nomod ro - else -" call Decho("ftp not executable") - if !exists("g:netrw_quiet") - call netrw#ErrorMsg(s:ERROR,"this system doesn't support ftp",29) - endif - " restore status line - let &stl = s:netrw_users_stl - let &laststatus = s:netrw_users_ls - " restore NetMethod - if exists("keep_netrw_method") - call s:NetMethod(keep_netrw_choice) - let w:netrw_method = keep_netrw_wmethod - endif -" call Dret("NetObtain") - return - endif - - "......................................... - else - " scp: Method#4 -" call Decho("using scp") - let curdir = b:netrw_curdir - let path = substitute(curdir,'scp://[^/]\+/','','e') -" call Decho("path<".path.">") - if exists("g:netrw_port") && g:netrw_port != "" - let useport= " ".g:netrw_scpport." ".g:netrw_port - else - let useport= "" - endif -" call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".path.escape(fname,' ?&')." .") - exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".path.escape(fname,' ?&')." ." - endif - endif - - " restore status line - let &stl = s:netrw_users_stl - let &laststatus = s:netrw_users_ls - redraw! - - " restore NetMethod - if exists("keep_netrw_method") - call s:NetMethod(keep_netrw_choice) - let w:netrw_method = keep_netrw_wmethod - endif - -" call Dret("NetObtain") -endfun - -" --------------------------------------------------------------------- -" NetPrevWinOpen: open file/directory in previous window. {{{2 +" s:NetrwPrevWinOpen: open file/directory in previous window. {{{2 " If there's only one window, then the window will first be split. -fun! s:NetPrevWinOpen(islocal) -" call Dfunc("NetPrevWinOpen(islocal=".a:islocal.")") +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:NetGetWord() + let curword = s:NetrwGetWord() " 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.")") - exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s" + if g:netrw_preview + exe (g:netrw_alto? "top " : "bot ")."vert ".g:netrw_winsize."wincmd s" + else + exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s" + endif let didsplit = 1 else + call s:SaveBufVars() 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. @@ -3931,7 +4901,7 @@ fun! s:NetPrevWinOpen(islocal) else wincmd p endif -" call Dret("NetPrevWinOpen : unable to write <".bufname.">") +" call Dret("NetrwPrevWinOpen : unable to write <".bufname.">") return endif @@ -3947,7 +4917,7 @@ fun! s:NetPrevWinOpen(islocal) else wincmd p endif -" call Dret("NetPrevWinOpen : cancelled") +" call Dret("NetrwPrevWinOpen : cancelled") return endif endif @@ -3955,54 +4925,70 @@ fun! s:NetPrevWinOpen(islocal) endif if a:islocal - call netrw#LocalBrowseCheck(s:NetBrowseChgDir(a:islocal,curword)) + call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(a:islocal,curword)) else - call s:NetBrowse(a:islocal,s:NetBrowseChgDir(a:islocal,curword)) + call s:NetrwBrowse(a:islocal,s:NetrwBrowseChgDir(a:islocal,curword)) endif -" call Dret("NetPrevWinOpen") +" call Dret("NetrwPrevWinOpen") endfun " --------------------------------------------------------------------- -" NetMenu: generates the menu for gvim and netrw {{{2 -fun! s:NetMenu(domenu) +" 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("NetMenu(domenu=".a:domenu.")") +" 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:NetBookmarkMenu() " provide some history! - exe 'silent! menu '.g:NetrwMenuPriority.'.4 '.g:NetrwTopLvlMenu.'Go\ Up\ Directory- -' - exe 'silent! menu '.g:NetrwMenuPriority.'.5 '.g:NetrwTopLvlMenu.'Apply\ Special\ Viewerx x' - exe 'silent! menu '.g:NetrwMenuPriority.'.6 '.g:NetrwTopLvlMenu.'Bookmark\ Current\ Directorymb mb' - exe 'silent! menu '.g:NetrwMenuPriority.'.7 '.g:NetrwTopLvlMenu.'Goto\ Bookmarked\ Directorygb gb' - exe 'silent! menu '.g:NetrwMenuPriority.'.8 '.g:NetrwTopLvlMenu.'Change\ To\ Recently\ Used\ Directoryu u' - exe 'silent! menu '.g:NetrwMenuPriority.'.9 '.g:NetrwTopLvlMenu.'Change\ To\ Subsequently\ Used\ DirectoryU U' - exe 'silent! menu '.g:NetrwMenuPriority.'.10 '.g:NetrwTopLvlMenu.'Delete\ File/DirectoryD D' - exe 'silent! menu '.g:NetrwMenuPriority.'.11 '.g:NetrwTopLvlMenu.'Edit\ File\ Hiding\ List'." \" - exe 'silent! menu '.g:NetrwMenuPriority.'.12 '.g:NetrwTopLvlMenu.'Edit\ File/Directory '."\" - exe 'silent! menu '.g:NetrwMenuPriority.'.13 '.g:NetrwTopLvlMenu.'Edit\ File/Directory,\ New\ Windowo o' - exe 'silent! menu '.g:NetrwMenuPriority.'.14 '.g:NetrwTopLvlMenu.'Edit\ File/Directory,\ New\ Vertical\ Windowv v' - exe 'silent! menu '.g:NetrwMenuPriority.'.15 '.g:NetrwTopLvlMenu.'List\ Bookmarks\ and\ Historyq q' - exe 'silent! menu '.g:NetrwMenuPriority.'.16 '.g:NetrwTopLvlMenu.'Listing\ Style\ (thin-long-wide)i i' - exe 'silent! menu '.g:NetrwMenuPriority.'.17 '.g:NetrwTopLvlMenu.'Make\ Subdirectoryd d' - exe 'silent! menu '.g:NetrwMenuPriority.'.18 '.g:NetrwTopLvlMenu.'Normal-Hide-Showa a' - exe 'silent! menu '.g:NetrwMenuPriority.'.19 '.g:NetrwTopLvlMenu.'Obtain\ FileO O' - exe 'silent! menu '.g:NetrwMenuPriority.'.20 '.g:NetrwTopLvlMenu.'Preview\ File/Directoryp p' - exe 'silent! menu '.g:NetrwMenuPriority.'.21 '.g:NetrwTopLvlMenu.'Previous\ Window\ BrowserP P' - exe 'silent! menu '.g:NetrwMenuPriority.'.22 '.g:NetrwTopLvlMenu.'Refresh\ Listing'." \" - exe 'silent! menu '.g:NetrwMenuPriority.'.23 '.g:NetrwTopLvlMenu.'Rename\ File/DirectoryR R' - exe 'silent! menu '.g:NetrwMenuPriority.'.24 '.g:NetrwTopLvlMenu.'Reverse\ Sorting\ Order'."r r" - exe 'silent! menu '.g:NetrwMenuPriority.'.25 '.g:NetrwTopLvlMenu.'Select\ Sorting\ Styles s' - exe 'silent! menu '.g:NetrwMenuPriority.'.26 '.g:NetrwTopLvlMenu.'Sorting\ Sequence\ EditS S' - exe 'silent! menu '.g:NetrwMenuPriority.'.27 '.g:NetrwTopLvlMenu.'Set\ Current\ Directoryc c' - exe 'silent! menu '.g:NetrwMenuPriority.'.28 '.g:NetrwTopLvlMenu.'Settings/Options:NetrwSettings '.":NetrwSettings\" + 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 @@ -4010,43 +4996,15 @@ fun! s:NetMenu(domenu) 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.'Help' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Apply\ Special\ Viewer' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Bookmark\ Current\ Directory' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Go\ Up\ Directory' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Goto\ Bookmarked\ Directory' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Change\ To\ Recently\ Used\ Directory' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Change\ To\ Subsequently\ Used\ Directory' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Delete\ File/Directory' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Edit\ File/Directory' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Edit\ File/Directory,\ New\ Window' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Edit\ File/Directory,\ New\ Vertical\ Window' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Edit\ File\ Hiding\ List' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Edit\ File' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Enter\ File/Directory' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Enter\ File/Directory\ (vertical\ split)' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'List\ Bookmarks\ and\ History' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Listing\ Style\ (thin-long-wide)' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Make\ Subdirectory' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Normal-Hide-Show' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Obtain\ File' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Preview\ File/Directory' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Previous\ Window\ Browser' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Refresh\ Listing' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Rename\ File/Directory' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Reverse\ Sorting\ Order' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Select\ Sorting\ Style' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Sorting\ Sequence\ Edit' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Set\ Current\ Directory' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Settings/Options' - exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Bookmarks' + exe 'silent! unmenu '.g:NetrwTopLvlMenu +" call Decho('exe silent! unmenu '.g:NetrwTopLvlMenu.'*') silent! unlet s:netrw_menu_enabled endif endif -" call Dret("NetMenu") +" call Dret("NetrwMenu") endif endfun @@ -4056,7 +5014,7 @@ endfun " ========================================== " --------------------------------------------------------------------- -" LocalBrowseCheck: {{{2 +" netrw#LocalBrowseCheck: {{{2 fun! netrw#LocalBrowseCheck(dirname) " unfortunate interaction -- split window debugging can't be " " used here, must use DechoRemOn or DechoTabOn -- the BufEnter @@ -4064,22 +5022,27 @@ fun! netrw#LocalBrowseCheck(dirname) " to write to the DBG buffer are made. " call Dfunc("LocalBrowseCheck(dirname<".a:dirname.">") if isdirectory(a:dirname) - silent! call s:NetBrowse(1,a:dirname) + silent! call s:NetrwBrowse(1,a:dirname) endif " call Dret("LocalBrowseCheck") " not a directory, ignore it endfun " --------------------------------------------------------------------- -" LocalListing: does the job of "ls" for local directories {{{2 +" s:LocalListing: does the job of "ls" for local directories {{{2 fun! s:LocalListing() -" call Dfunc("LocalListing() &ma=".&ma." &mod=".&mod." &ro=".&ro." buf(%)=".buf("%")) +" call Dfunc("s:LocalListing()") +" call Decho("&ma=".&ma) +" call Decho("&mod=".&mod) +" call Decho("&ro=".&ro) +" call Decho("bufname(%)<".bufname("%").">") + " if exists("b:netrw_curdir") |call Decho('b:netrw_curdir<'.b:netrw_curdir.">") |else|call Decho("b:netrw_curdir doesn't exist") |endif " if exists("g:netrw_sort_by")|call Decho('g:netrw_sort_by<'.g:netrw_sort_by.">")|else|call Decho("g:netrw_sort_by doesn't exist")|endif " get the list of files contained in the current directory let dirname = escape(b:netrw_curdir,s:netrw_glob_escape) - let dirnamelen = strlen(b:netrw_curdir) + let dirnamelen = s:Strlen(b:netrw_curdir) let filelist = glob(s:ComposePath(dirname,"*")) " call Decho("glob(dirname<".dirname."/*>)=".filelist) if filelist != "" @@ -4110,10 +5073,12 @@ fun! s:LocalListing() " call Decho("remove .. from filelist") endif let filelist= substitute(filelist,'\n\{2,}','\n','ge') - if (has("win32") || has("win95") || has("win64") || has("win16")) - let filelist= substitute(filelist,'\','/','ge') + if !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16")) + " change all \s to /s + let filelist= substitute(filelist,'\','/','g') else - let filelist= substitute(filelist,'\','\\','ge') + " escape all \s to \\ + let filelist= substitute(filelist,'\','\\','g') endif " call Decho("dirname<".dirname.">") @@ -4143,7 +5108,7 @@ fun! s:LocalListing() if w:netrw_liststyle == s:LONGLIST let sz = getfsize(filename) - let fsz = strpart(" ",1,15-strlen(sz)).sz + let fsz = strpart(" ",1,15-s:Strlen(sz)).sz let pfile= pfile."\t".fsz." ".strftime(g:netrw_timefmt,getftime(filename)) " call Decho("sz=".sz." fsz=".fsz) endif @@ -4152,7 +5117,7 @@ fun! s:LocalListing() " sort by time (handles time up to 1 quintillion seconds, US) " call Decho("getftime(".filename.")=".getftime(filename)) let t = getftime(filename) - let ft = strpart("000000000000000000",1,18-strlen(t)).t + let ft = strpart("000000000000000000",1,18-s:Strlen(t)).t " call Decho("exe keepjumps put ='".ft.'/'.filename."'") let ftpfile= ft.'/'.pfile keepjumps silent! put=ftpfile @@ -4161,12 +5126,12 @@ fun! s:LocalListing() " sort by size (handles file sizes up to 1 quintillion bytes, US) " call Decho("getfsize(".filename.")=".getfsize(filename)) let sz = getfsize(filename) - let fsz = strpart("000000000000000000",1,18-strlen(sz)).sz + let fsz = strpart("000000000000000000",1,18-s:Strlen(sz)).sz " call Decho("exe keepjumps put ='".fsz.'/'.filename."'") let fszpfile= fsz.'/'.pfile keepjumps silent! put =fszpfile - else + else " sort by name " call Decho("exe keepjumps put ='".pfile."'") keepjumps silent! put=pfile @@ -4178,11 +5143,11 @@ fun! s:LocalListing() setlocal ts=32 " call Decho("setlocal ts=32") -" call Dret("LocalListing") +" call Dret("s:LocalListing") endfun " --------------------------------------------------------------------- -" LocalBrowseShellCmdRefresh: this function is called after a user has {{{2 +" s:LocalBrowseShellCmdRefresh: this function is called after a user has {{{2 " performed any shell command. The idea is to cause all local-browsing " 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. @@ -4213,7 +5178,7 @@ fun! s:LocalBrowseShellCmdRefresh() elseif index(tabpagebuflist(),ibuf) != -1 " call Decho("refresh buf#".ibuf.'-> win#'.bufwinnr(ibuf)) exe bufwinnr(ibuf)."wincmd w" - call s:NetRefresh(1,s:NetBrowseChgDir(1,'./')) + call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./')) endif let ibl= ibl + 1 endfor @@ -4223,169 +5188,229 @@ fun! s:LocalBrowseShellCmdRefresh() endfun " --------------------------------------------------------------------- -" LocalBrowseRm: {{{2 -fun! s:LocalBrowseRm(path) range -" call Dfunc("LocalBrowseRm(path<".a:path.">)") +" s:NetrwLocalRm: {{{2 +fun! s:NetrwLocalRm(path) range +" call Dfunc("NetrwLocalRm(path<".a:path.">)") " call Decho("firstline=".a:firstline." lastline=".a:lastline) " preparation for removing multiple files/directories - let ctr = a:firstline - let ret = 0 - let all= 0 + let ret = 0 + let all = 0 + let svpos = netrw#NetrwSavePosn() - " remove multiple files and directories - while ctr <= a:lastline - exe "keepjumps ".ctr - - " sanity checks - if line(".") < w:netrw_bannercnt - let ctr= ctr + 1 - continue - endif - let curword= s:NetGetWord() - if curword == "./" || curword == "../" - let ctr= ctr + 1 - continue - endif - - norm! 0 - let rmfile= s:ComposePath(a:path,curword) -" call Decho("rmfile<".rmfile.">") - - if rmfile !~ '^"' && (rmfile =~ '@$' || rmfile !~ '[\/]$') - " attempt to remove file - if !all - echohl Statement - call inputsave() - let ok= input("Confirm deletion of file<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") - call inputrestore() - echohl NONE - if ok == "" - let ok="no" - endif -" call Decho("response: ok<".ok.">") - let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e') -" call Decho("response: ok<".ok."> (after sub)") - if ok =~ 'a\%[ll]' - let all= 1 - endif - endif - - if all || ok =~ 'y\%[es]' || ok == "" - let ret= s:System("delete",rmfile) -" call Decho("errcode=".v:shell_error." ret=".ret) - elseif ok =~ 'q\%[uit]' + if exists("s:netrwmarkfilelist") + " remove all marked files +" call Decho("remove all marked files") + for fname in s:netrwmarkfilelist + let ok= s:NetrwLocalRmFile(a:path,fname,all) + if ok =~ 'q\%[uit]' break + elseif ok =~ 'a\%[ll]' + let all= 1 endif + endfor + unlet s:netrwmarkfilelist + unlet s:netrwmarkfilemtch + 2match none - else - " attempt to remove directory - if !all - echohl Statement - call inputsave() - let ok= input("Confirm deletion of directory<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") - call inputrestore() - let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e') - if ok == "" - let ok="no" - endif - if ok =~ 'a\%[ll]' - let all= 1 - endif + else + " remove (multiple) files and directories +" call Decho("remove files in range [".a:firstline.",".a:lastline."]") + + let ctr = a:firstline + while ctr <= a:lastline + exe "keepjumps ".ctr + + " sanity checks + if line(".") < w:netrw_bannercnt + let ctr= ctr + 1 + continue endif - let rmfile= substitute(rmfile,'[\/]$','','e') - - if all || ok =~ 'y\%[es]' || ok == "" -" call Decho("1st attempt: system(".g:netrw_local_rmdir.' "'.rmfile.'")') - call s:System("system",g:netrw_local_rmdir.' "'.rmfile.'"') -" call Decho("v:shell_error=".v:shell_error) - - if v:shell_error != 0 -" call Decho("2nd attempt to remove directory<".rmfile.">") - let errcode= s:System("delete",rmfile) -" call Decho("errcode=".errcode) - - if errcode != 0 - if has("unix") -" call Decho("3rd attempt to remove directory<".rmfile.">") - call s:System("system","rm ".rmfile) - if v:shell_error != 0 && !exists("g:netrw_quiet") - call netrw#ErrorMsg(s:ERROR,"unable to remove directory<".rmfile."> -- is it empty?",34) -endif - elseif !exists("g:netrw_quiet") - call netrw#ErrorMsg(s:ERROR,"unable to remove directory<".rmfile."> -- is it empty?",35) - endif - endif - endif - - elseif ok =~ 'q\%[uit]' + let curword= s:NetrwGetWord() + if curword == "./" || curword == "../" + let ctr= ctr + 1 + continue + endif + let ok= s:NetrwLocalRmFile(a:path,curword,all) + if ok =~ 'q\%[uit]' break + elseif ok =~ 'a\%[ll]' + let all= 1 endif - endif - - let ctr= ctr + 1 - endwhile + let ctr= ctr + 1 + endwhile + endif " refresh the directory - let curline= line(".") -" call Decho("refresh the directory") - call s:NetRefresh(1,s:NetBrowseChgDir(1,'./')) - exe curline + call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./')) + call netrw#NetrwRestorePosn(svpos) -" call Dret("LocalBrowseRm") +" call Dret("NetrwLocalRm") endfun " --------------------------------------------------------------------- -" LocalBrowseRename: rename a remote file or directory {{{2 -fun! s:LocalBrowseRename(path) range -" call Dfunc("LocalBrowseRename(path<".a:path.">)") +" s:NetrwLocalRmFile: remove file fname given the path {{{2 +" Give confirmation prompt unless all==1 +fun! s:NetrwLocalRmFile(path,fname,all) +" call Dfunc("s:NetrwLocalRmFile(path<".a:path."> fname<".a:fname."> all=".a:all) + + let all= a:all + let ok = "" + norm! 0 + let rmfile= s:ComposePath(a:path,a:fname) +" call Decho("rmfile<".rmfile.">") + + if rmfile !~ '^"' && (rmfile =~ '@$' || rmfile !~ '[\/]$') + " attempt to remove file + if !all + echohl Statement + call inputsave() + let ok= input("Confirm deletion of file<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") + call inputrestore() + echohl NONE + if ok == "" + let ok="no" + endif +" call Decho("response: ok<".ok.">") + let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e') +" call Decho("response: ok<".ok."> (after sub)") + if ok =~ 'a\%[ll]' + let all= 1 + endif + endif + + if all || ok =~ 'y\%[es]' || ok == "" + let ret= s:System("delete",rmfile) +" call Decho("errcode=".v:shell_error." ret=".ret) + endif + + else + " attempt to remove directory + if !all + echohl Statement + call inputsave() + let ok= input("Confirm deletion of directory<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") + call inputrestore() + let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e') + if ok == "" + let ok="no" + endif + if ok =~ 'a\%[ll]' + let all= 1 + endif + endif + let rmfile= substitute(rmfile,'[\/]$','','e') + + if all || ok =~ 'y\%[es]' || ok == "" +" call Decho("1st attempt: system(".g:netrw_local_rmdir.' "'.rmfile.'")') + call s:System("system",g:netrw_local_rmdir.' "'.rmfile.'"') +" call Decho("v:shell_error=".v:shell_error) + + if v:shell_error != 0 +" call Decho("2nd attempt to remove directory<".rmfile.">") + let errcode= s:System("delete",rmfile) +" call Decho("errcode=".errcode) + + if errcode != 0 + if has("unix") +" call Decho("3rd attempt to remove directory<".rmfile.">") + call s:System("system","rm ".rmfile) + if v:shell_error != 0 && !exists("g:netrw_quiet") + call netrw#ErrorMsg(s:ERROR,"unable to remove directory<".rmfile."> -- is it empty?",34) + endif + elseif !exists("g:netrw_quiet") + call netrw#ErrorMsg(s:ERROR,"unable to remove directory<".rmfile."> -- is it empty?",35) + endif + endif + endif + endif + endif + +" call Dret("s:NetrwLocalRmFile ".ok) + return ok +endfun + +" --------------------------------------------------------------------- +" s:NetrwLocalRename: rename a remote file or directory {{{2 +fun! s:NetrwLocalRename(path) range +" call Dfunc("NetrwLocalRename(path<".a:path.">)") " preparation for removing multiple files/directories - let ctr= a:firstline + let ctr = a:firstline + let svpos= netrw#NetrwSavePosn() - " attempt to rename files/directories - while ctr <= a:lastline - exe "keepjumps ".ctr + " rename files given by the markfilelist + if exists("s:netrwmarkfilelist") + for oldname in s:netrwmarkfilelist +" call Decho("oldname<".oldname.">") + if exists("subfrom") + let newname= substitute(oldname,subfrom,subto,'') +" call Decho("subfrom<".subfrom."> subto<".subto."> newname<".newname.">") + else + call inputsave() + let newname= input("Moving ".oldname." to : ",oldname) + call inputrestore() + if newname =~ '^s/' + let subfrom = substitute(newname,'^s/\([^/]*\)/.*/$','\1','') + let subto = substitute(newname,'^s/[^/]*/\(.*\)/$','\1','') +" call Decho("subfrom<".subfrom."> subto<".subto."> newname<".newname.">") + let newname = substitute(oldname,subfrom,subto,'') + endif + endif + let ret= rename(oldname,newname) + endfor + 2match none + unlet s:netrwmarkfilelist + unlet s:netrwmarkfilemtch + + else - " sanity checks - if line(".") < w:netrw_bannercnt - let ctr= ctr + 1 - continue - endif - let curword= s:NetGetWord() - if curword == "./" || curword == "../" - let ctr= ctr + 1 - continue - endif + " attempt to rename files/directories + while ctr <= a:lastline + exe "keepjumps ".ctr - norm! 0 - let oldname= s:ComposePath(a:path,curword) + " sanity checks + if line(".") < w:netrw_bannercnt + let ctr= ctr + 1 + continue + endif + let curword= s:NetrwGetWord() + if curword == "./" || curword == "../" + let ctr= ctr + 1 + continue + endif + + norm! 0 + let oldname= s:ComposePath(a:path,curword) " call Decho("oldname<".oldname.">") - call inputsave() - let newname= input("Moving ".oldname." to : ",substitute(oldname,'/*$','','e')) - call inputrestore() + call inputsave() + let newname= input("Moving ".oldname." to : ",substitute(oldname,'/*$','','e')) + call inputrestore() - let ret= rename(oldname,newname) + let ret= rename(oldname,newname) " call Decho("renaming <".oldname."> to <".newname.">") - let ctr= ctr + 1 - endwhile + let ctr= ctr + 1 + endwhile + endif " refresh the directory " call Decho("refresh the directory listing") - call netrw#NetSavePosn() - call s:NetRefresh(1,s:NetBrowseChgDir(1,'./')) -" call Dret("LocalBrowseRename") + call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./')) + call netrw#NetrwRestorePosn(svpos) + +" call Dret("NetrwLocalRename") endfun " --------------------------------------------------------------------- -" LocalFastBrowser: handles setting up/taking down fast browsing for the {{{2 -" local browser -" fastbrowse Local Remote Hiding a buffer implies it may be re-used (fast) -" slow 0 D D Deleting a buffer implies it will not be re-used (slow) -" med 1 D H -" fast 2 H H +" s:LocalFastBrowser: handles setting up/taking down fast browsing for the local browser {{{2 +" +" Directory Is +" fastbrowse Local Remote +" slow 0 D D D=Deleting a buffer implies it will not be re-used (slow) +" med 1 D H H=Hiding a buffer implies it may be re-used (fast) +" fast 2 H H fun! s:LocalFastBrowser() " call Dfunc("LocalFastBrowser() g:netrw_fastbrowse=".g:netrw_fastbrowse) @@ -4411,9 +5436,9 @@ fun! s:LocalFastBrowser() augroup AuNetrwShellCmd au! if (has("win32") || has("win95") || has("win64") || has("win16")) - au ShellCmdPost * call s:LocalBrowseShellCmdRefresh() + au ShellCmdPost * call s:LocalBrowseShellCmdRefresh() else - au ShellCmdPost,FocusGained * call s:LocalBrowseShellCmdRefresh() + au ShellCmdPost,FocusGained * call s:LocalBrowseShellCmdRefresh() endif augroup END endif @@ -4432,22 +5457,6 @@ fun! s:LocalFastBrowser() " call Dret("LocalFastBrowser") endfun -" --------------------------------------------------------------------- -" LocalObtain: copy selected file to current working directory {{{2 -fun! s:LocalObtain() -" call Dfunc("LocalObtain()") - if exists("b:netrw_curdir") && getcwd() != b:netrw_curdir - let fname= expand("") - let fcopy= readfile(b:netrw_curdir."/".fname,"b") - call writefile(fcopy,getcwd()."/".fname,"b") - elseif !exists("b:netrw_curdir") - call netrw#ErrorMsg(s:ERROR,"local browsing directory doesn't exist!",36) - else - call netrw#ErrorMsg(s:ERROR,"local browsing directory and current directory are identical",37) - endif -" call Dret("LocalObtain") -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 @@ -4472,6 +5481,7 @@ fun! netrw#Explore(indx,dosplit,style,...) if a:dosplit || &modified || a:style == 6 " call Decho("case: dosplit=".a:dosplit." modified=".&modified." a:style=".a:style) call s:SaveWinVars() + call s:NetrwOptionSave("s:") if a:style == 0 " Explore, Sexplore " call Decho("style=0: Explore or Sexplore") @@ -4504,6 +5514,7 @@ fun! netrw#Explore(indx,dosplit,style,...) call s:RestoreBufVars() endif call s:RestoreWinVars() + call s:NetrwOptionRestore("s:") endif norm! 0 @@ -4545,14 +5556,19 @@ fun! netrw#Explore(indx,dosplit,style,...) " call Decho("case Explore Hexplore Vexplore Sexplore") let newdir= substitute(expand("%:p"),'^\(.*[/\\]\)[^/\\]*$','\1','e') if newdir =~ '^scp:' || newdir =~ '^ftp:' -" call Decho("calling NetBrowse(0,newdir<".newdir.">)") - call s:NetBrowse(0,newdir) +" 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 search('\<'.substitute(curfile,'^.*/','','e').'\>','cW') +" 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 @@ -4727,7 +5743,7 @@ fun! netrw#Explore(indx,dosplit,style,...) if !exists("b:netrw_curdir") call netrw#LocalBrowseCheck(getcwd()) else - call netrw#LocalBrowseCheck(s:NetBrowseChgDir(1,newdir)) + call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,newdir)) endif endif @@ -4751,7 +5767,7 @@ fun! s:ExplorePatHls(pattern) endfun " --------------------------------------------------------------------- -" SetupNetrwStatusLine: {{{2 +" s:SetupNetrwStatusLine: {{{2 fun! s:SetupNetrwStatusLine(statline) " call Dfunc("SetupNetrwStatusLine(statline<".a:statline.">)") @@ -4827,24 +5843,24 @@ fun! NetrwStatusLine() endfun " --------------------------------------------------------------------- -" NetGetcwd: get the current directory. {{{2 +" s:NetrwGetcwd: get the current directory. {{{2 " Change backslashes to forward slashes, if any. " If doesc is true, escape certain troublesome characters -fun! s:NetGetcwd(doesc) -" call Dfunc("NetGetcwd(doesc=".a:doesc.")") +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,s:netrw_cd_escape) + let curdir= escape(curdir,g:netrw_cd_escape) endif -" call Dret("NetGetcwd <".curdir.">") +" call Dret("NetrwGetcwd <".curdir.">") return curdir endfun " --------------------------------------------------------------------- -" SetSort: sets up the sort based on the g:netrw_sort_sequence {{{2 +" 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 @@ -4910,11 +5926,11 @@ endfun " Support Functions: {{{1 " --------------------------------------------------------------------- -" ComposePath: Appends a new part to a path taking different systems into consideration {{{2 +" s:ComposePath: Appends a new part to a path taking different systems into consideration {{{2 fun! s:ComposePath(base,subdir) " call Dfunc("s:ComposePath(base<".a:base."> subdir<".a:subdir.">)") if(has("amiga")) - let ec = a:base[strlen(a:base)-1] + let ec = a:base[s:Strlen(a:base)-1] if ec != '/' && ec != ':' let ret = a:base . "/" . a:subdir else @@ -4929,6 +5945,10 @@ fun! s:ComposePath(base,subdir) " call Decho("ret<".ret.">") else let ret = substitute(a:base."/".a:subdir,"//","/","g") + if a:base =~ '^//' + " keeping initial '//' for the benefit of network share listing support + let ret= '/'.ret + endif endif " call Dret("s:ComposePath ".ret) return ret @@ -4939,7 +5959,7 @@ endfun " 0=note = s:NOTE " 1=warning = s:WARNING " 2=error = s:ERROR -" Mar 19, 2007 : max errnum currently is 49 +" Sep 17, 2007 : max errnum currently is 60 fun! netrw#ErrorMsg(level,msg,errnum) " call Dfunc("netrw#ErrorMsg(level=".a:level." msg<".a:msg."> errnum=".a:errnum.") g:netrw_use_errorwindow=".g:netrw_use_errorwindow) @@ -4955,9 +5975,9 @@ fun! netrw#ErrorMsg(level,msg,errnum) " (default) netrw creates a one-line window to show error/warning " messages (reliably displayed) - " record current window number for NetRestorePosn()'s benefit + " record current window number for NetrwRestorePosn()'s benefit let s:winBeforeErr= winnr() - + " getting messages out reliably is just plain difficult! " This attempt splits the current window, creating a one line window. if bufexists("NetrwMessage") && bufwinnr("NetrwMessage") > 0 @@ -5034,28 +6054,32 @@ fun! s:GetTempfile(fname) " get a brand new temporary filename let tmpfile= tempname() " call Decho("tmpfile<".tmpfile."> : from tempname()") - + let tmpfile= escape(substitute(tmpfile,'\','/','ge'),g:netrw_tmpfile_escape) " call Decho("tmpfile<".tmpfile."> : chgd any \\ -> /") - + " sanity check -- does the temporary file's directory exist? if !isdirectory(substitute(tmpfile,'[^/]\+$','','e')) call netrw#ErrorMsg(s:ERROR,"your <".substitute(tmpfile,'[^/]\+$','','e')."> directory is missing!",2) " call Dret("s:GetTempfile getcwd<".getcwd().">") return "" endif - + " let netrw#NetSource() know about the tmpfile let s:netrw_tmpfile= tmpfile " used by netrw#NetSource() " call Decho("tmpfile<".tmpfile."> s:netrw_tmpfile<".s:netrw_tmpfile.">") - + " o/s dependencies - if g:netrw_cygwin == 1 + if g:netrw_cygwin != 0 let tmpfile = substitute(tmpfile,'^\(\a\):','/cygdrive/\1','e') elseif has("win32") || has("win95") || has("win64") || has("win16") - let tmpfile = substitute(tmpfile,'/','\\','g') + if exists("+shellslash") + let tmpfile = substitute(tmpfile,'/',&ssl,'g') + else + let tmpfile = substitute(tmpfile,'/','\','g') + endif else - let tmpfile = tmpfile + let tmpfile = tmpfile endif let b:netrw_tmpfile= tmpfile " call Decho("o/s dependent fixed tempname<".tmpfile.">") @@ -5086,7 +6110,7 @@ fun! s:GetTempfile(fname) " call Dret("s:GetTempfile <".tmpfile.">") return tmpfile -endfun +endfun " --------------------------------------------------------------------- " s:MakeSshCmd: transforms input command using USEPORT HOSTNAME into {{{2 @@ -5105,6 +6129,31 @@ fun! s:MakeSshCmd(sshcmd) return sshcmd endfun +" --------------------------------------------------------------------- +" s:RemoteSystem: runs a command on a remote host using ssh {{{2 +" Returns status +fun! s:RemoteSystem(cmd) +" call Dfunc("s:RemoteSystem(cmd<".a:cmd.">)") + if !executable(g:netrw_ssh_cmd) + call netrw#ErrorMsg(s:ERROR,"g:netrw_ssh_cmd<".g:netrw_ssh_cmd."> is not executable!",52) + elseif !exists("b:netrw_curdir") + call netrw#ErrorMsg(s:ERROR,"for some reason b:netrw_curdir doesn't exist!",53) + else + let cmd = s:MakeSshCmd(g:netrw_ssh_cmd." USEPORT HOSTNAME") + let remotedir= substitute(b:netrw_curdir,'^.*//[^/]\+/\(.*\)$','\1','') + if remotedir != "" + let cmd= cmd.' "cd '."'".remotedir."';" + else + let cmd= cmd.' "' + endif + let cmd= cmd.a:cmd.'"' +" call Decho("call system(".cmd.")") + let ret= system(cmd) + endif +" call Dret("s:RemoteSystem ".ret) + return ret +endfun + " --------------------------------------------------------------------- " s:NetrwEnew: opens a new buffer, passes netrw buffer variables through {{{2 fun! s:NetrwEnew(curdir) @@ -5158,6 +6207,8 @@ fun! s:NetrwEnew(curdir) if b:netrw_curdir =~ '/$' if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST file NetrwTreeListing + nno [ :silent call TreeListMove('[') + nno ] :silent call TreeListMove(']') else exe "silent! file ".b:netrw_curdir endif @@ -5205,7 +6256,7 @@ fun! s:RestoreBufVars() endfun " --------------------------------------------------------------------- -" s:RestoreWinVars: (used by Explore() and NetSplit()) {{{2 +" s:RestoreWinVars: (used by Explore() and NetrwSplit()) {{{2 fun! s:RestoreWinVars() " call Dfunc("s:RestoreWinVars()") if exists("s:bannercnt") |let w:netrw_bannercnt = s:bannercnt |unlet s:bannercnt |endif @@ -5245,7 +6296,7 @@ fun! s:SaveBufVars() endfun " --------------------------------------------------------------------- -" s:SaveWinVars: (used by Explore() and NetSplit()) {{{2 +" s:SaveWinVars: (used by Explore() and NetrwSplit()) {{{2 fun! s:SaveWinVars() " call Dfunc("s:SaveWinVars()") if exists("w:netrw_bannercnt") |let s:bannercnt = w:netrw_bannercnt |endif @@ -5270,7 +6321,7 @@ fun! s:SaveWinVars() endfun " --------------------------------------------------------------------- -" s:SetBufWinVars: (used by NetBrowse() and LocalBrowseCheck()) {{{2 +" s:SetBufWinVars: (used by NetrwBrowse() and LocalBrowseCheck()) {{{2 " To allow separate windows to have their own activities, such as " Explore **/pattern, several variables have been made window-oriented. " However, when the user splits a browser window (ex: ctrl-w s), these @@ -5291,6 +6342,18 @@ fun! s:SetBufWinVars() " call Dret("s:SetBufWinVars") 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. +fun! s:Strlen(x) +" call Dfunc("s:Strlen(x<".a:x.">") + let ret= strlen(substitute(a:x,'.','c','g')) +" call Dret("s:Strlen ".ret) + return ret +endfun + " --------------------------------------------------------------------- " s:System: using Steve Hall's idea to insure that Windows paths stay {{{2 " acceptable. No effect on Unix paths. @@ -5300,7 +6363,7 @@ fun! s:System(cmd,path) " call Dfunc("s:System(cmd<".a:cmd."> path<".a:path.">)") let path = a:path - if (has("win32") || has("win95") || has("win64") || has("win16")) + if !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16")) " system call prep " remove trailing slash (Win95) let path = substitute(path, '\(\\\|/\)$', '', 'g') @@ -5320,13 +6383,68 @@ fun! s:System(cmd,path) exe "let result= ".a:cmd."('".path."')" endif -" call Decho("result<".result.">") -" call Dret("s:System") +" call Dret("s:System result<".result.">") return result endfun " --------------------------------------------------------------------- -" s:UseBufWinVars: (used by NetBrowse() and LocalBrowseCheck() {{{2 +" s:TreeListMove: {{{2 +fun! s:TreeListMove(dir) +" call Dfunc("s:TreeListMove(dir<".a:dir.">)") + let curline = getline(".") + let prvline = (line(".") > 1)? getline(line(".")-1) : '' + let nxtline = (line(".") < line("$"))? getline(line(".")+1) : '' + let curindent= substitute(curline,'^\([| ]*\).\{-}$','\1','') + let indentm1 = substitute(curindent,'^| ','','') +" call Decho("prvline <".prvline."> #".line(".")-1) +" call Decho("curline <".curline."> #".line(".")) +" call Decho("nxtline <".nxtline."> #".line(".")+1) +" call Decho("curindent<".curindent.">") +" call Decho("indentm1 <".indentm1.">") + + if curline !~ '/$' +" call Decho('regfile') + if a:dir == '[' && prvline != '' + norm! 0 + let nl = search('^'.indentm1.'[^|]','bWe') " search backwards from regular file +" call Decho("regfile srch back: ".nl) + elseif a:dir == ']' && nxtline != '' + norm! $ + let nl = search('^'.indentm1.'[^|]','We') " search forwards from regular file +" call Decho("regfile srch fwd: ".nl) + endif + + elseif a:dir == '[' && prvline != '' + norm! 0 + let curline= line(".") + let nl = search('^'.curindent.'[^|]','bWe') " search backwards From directory, same indentation +" call Decho("dir srch back ind: ".nl) + if nl != 0 + if line(".") == curline-1 + let nl= search('^'.indentm1.'[^|]','bWe') " search backwards from directory, indentation - 1 +" call Decho("dir srch back ind-1: ".nl) + endif + endif + + elseif a:dir == ']' && nxtline != '' + norm! $ + let curline = line(".") + let nl = search('^'.curindent.'[^|]','We') " search forwards from directory, same indentation +" call Decho("dir srch fwd ind: ".nl) + if nl != 0 + if line(".") == curline+1 + let nl= search('^'.indentm1.'[^|]','We') " search forwards from directory, indentation - 1 +" call Decho("dir srch fwd ind-1: ".nl) + endif + endif + + endif + +" call Dret("s:TreeListMove") +endfun + +" --------------------------------------------------------------------- +" s:UseBufWinVars: (used by NetrwBrowse() and LocalBrowseCheck() {{{2 " Matching function to BufferWinVars() fun! s:UseBufWinVars() " call Dfunc("s:UseBufWinVars()") diff --git a/vimfiles/autoload/netrwSettings.vim b/vimfiles/autoload/netrwSettings.vim index 5f4445f..3b7ef27 100644 --- a/vimfiles/autoload/netrwSettings.vim +++ b/vimfiles/autoload/netrwSettings.vim @@ -1,7 +1,7 @@ " netrwSettings.vim: makes netrw settings simpler -" Date: Mar 26, 2007 +" Date: Jun 04, 2007 " Maintainer: Charles E Campbell, Jr -" Version: 9 +" Version: 11 " 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 @@ -19,13 +19,13 @@ if exists("g:loaded_netrwSettings") || &cp finish endif -let g:loaded_netrwSettings = "v9" +let g:loaded_netrwSettings = "v11" " --------------------------------------------------------------------- " NetrwSettings: {{{1 fun! netrwSettings#NetrwSettings() " this call is here largely just to insure that netrw has been loaded - call netrw#NetSavePosn() + call netrw#NetrwSavePosn() if !exists("g:loaded_netrw") echohl WarningMsg | echomsg "***sorry*** netrw needs to be loaded prior to using NetrwSettings" | echohl None return @@ -101,6 +101,11 @@ fun! netrwSettings#NetrwSettings() else put = 'let g:netrw_browsex_viewer = (not defined)' endif + let cdescline= line("$") + put ='let g:netrw_cd_escape...' + put = 'let g:netrw_compress = '.g:netrw_compress + let decompressline= line("$") + put ='let g:netrw_decompress...' put = 'let g:netrw_dirhistmax = '.g:netrw_dirhistmax put = 'let g:netrw_fastbrowse = '.g:netrw_fastbrowse put = 'let g:netrw_ftp_browse_reject = '.g:netrw_ftp_browse_reject @@ -111,12 +116,15 @@ fun! netrwSettings#NetrwSettings() put = 'let g:netrw_keepdir = '.g:netrw_keepdir put = 'let g:netrw_list_cmd = '.g:netrw_list_cmd put = 'let g:netrw_list_hide = '.g:netrw_list_hide - put = 'let g:netrw_local_mkdir = '.g:netrw_local_mkdir - put = 'let g:netrw_local_rmdir = '.g:netrw_local_rmdir put = 'let g:netrw_liststyle = '.g:netrw_liststyle + put = 'let g:netrw_localcopycmd = '.g:netrw_localcopycmd + put = 'let g:netrw_local_mkdir = '.g:netrw_local_mkdir + put = 'let g:netrw_localmovecmd = '.g:netrw_localmovecmd + put = 'let g:netrw_local_rmdir = '.g:netrw_local_rmdir put = 'let g:netrw_maxfilenamelen = '.g:netrw_maxfilenamelen put = 'let g:netrw_menu = '.g:netrw_menu 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_rm_cmd = '.g:netrw_rm_cmd put = 'let g:netrw_rmdir_cmd = '.g:netrw_rmdir_cmd @@ -142,13 +150,15 @@ fun! netrwSettings#NetrwSettings() silent %s/= $/= ''/e 1 - " Put in shq setting. + " Put in g:netrw_shq setting and g:netrw_cd_escape " (deferred so as to avoid the quote manipulation just preceding) if g:netrw_shq == "'" call setline(shqline,'let g:netrw_shq = "'.g:netrw_shq.'"') else call setline(shqline,"let g:netrw_shq = '".g:netrw_shq."'") endif + call setline(cdescline,"let g:netrw_cd_escape = ".'"'.escape(g:netrw_cd_escape,'\"').'"') + call setline(decompressline,"let g:netrw_decompress = ".substitute(string(g:netrw_decompress),"^'\\(.*\\)'$",'\1','')) set nomod diff --git a/vimfiles/doc/pi_netrw.txt b/vimfiles/doc/pi_netrw.txt index c8369eb..ec54101 100644 --- a/vimfiles/doc/pi_netrw.txt +++ b/vimfiles/doc/pi_netrw.txt @@ -1,4 +1,4 @@ -*pi_netrw.txt* For Vim version 7.1a. Last change: 2007 May 05 +*pi_netrw.txt* For Vim version 7.1. Last change: 2007 Oct 02 ----------------------------------------------------- NETRW REFERENCE MANUAL by Charles E. Campbell, Jr. @@ -10,84 +10,79 @@ *ftp* *netrw.vim* *Nsource* *rsync* *sftp* ============================================================================== -1. Contents *netrw-contents* +1. Contents *netrw-contents* {{{1 1. Contents.............................................|netrw-contents| 2. Starting With Netrw..................................|netrw-start| 3. Netrw Reference......................................|netrw-ref| - CONTROLLING EXTERNAL APPLICATIONS..................|netrw-externapp| + EXTERNAL APPLICATIONS AND PROTOCOLS................|netrw-externapp| READING............................................|netrw-read| WRITING............................................|netrw-write| DIRECTORY LISTING..................................|netrw-dirlist| CHANGING THE USERID AND PASSWORD...................|netrw-chgup| - VARIABLES..........................................|netrw-variables| + VARIABLES AND SETTINGS.............................|netrw-variables| PATHS..............................................|netrw-path| 4. Network-Oriented File Transfer.......................|netrw-xfer| NETRC..............................................|netrw-netrc| PASSWORD...........................................|netrw-passwd| 5. Activation...........................................|netrw-activate| -6. Transparent File Transfer............................|netrw-transparent| +6. Transparent File Editing.............................|netrw-transparent| 7. Ex Commands..........................................|netrw-ex| 8. Variables and Options................................|netrw-var| -9. Directory Browsing...................................|netrw-browse| {{{1 - Maps...............................................|netrw-maps| - Exploring..........................................|netrw-explore-cmds| - Quick Reference Commands Table.....................|netrw-browse-cmds| - Netrw Browser Variables............................|netrw-browse-var| - Introduction To Directory Browsing.................|netrw-browse-intro| - Netrw Browsing And Option Incompatibilities........|netrw-incompatible| - Directory Exploring Commands.......................|netrw-explore| - Refreshing The Listing.............................|netrw-ctrl-l| - Going Up...........................................|netrw--| +9. Browsing.............................................|netrw-browse| + Introduction To Browsing...........................|netrw-browse-intro| + Quick Reference: Maps..............................|netrw-browse-maps| + Quick Reference: Commands..........................|netrw-browse-cmds| + Bookmarking A Directory............................|netrw-mb| Browsing...........................................|netrw-cr| - Obtaining A File...................................|netrw-O| - Change Listing Style...............................|netrw-i| - Making A New Directory.............................|netrw-d| - Deleting Files Or Directories......................|netrw-D| - Renaming Files Or Directories......................|netrw-move| - Hiding Files Or Directories........................|netrw-a| - Edit File Or Directory Hiding List.................|netrw-ctrl-h| Browsing With A Horizontally Split Window..........|netrw-o| - Browsing With A Vertically Split Window............|netrw-v| Browsing With A New Tab............................|netrw-t| - Preview Window.....................................|netrw-p| - Selecting Sorting Style............................|netrw-s| - Editing The Sorting Sequence.......................|netrw-S| - Reversing Sorting Order............................|netrw-r| + Browsing With A Vertically Split Window............|netrw-v| + Change Listing Style...............................|netrw-i| + Changing To A Bookmarked Directory.................|netrw-gb| Changing To A Predecessor Directory................|netrw-u| Changing To A Successor Directory..................|netrw-U| Customizing Browsing With A User Function..........|netrw-x| - Making The Browsing Directory The Current Directory|netrw-c| - Bookmarking A Directory............................|netrw-mb| - Changing To A Bookmarked Directory.................|netrw-gb| + Deleting Files Or Directories......................|netrw-D| + Directory Exploring Commands.......................|netrw-explore| + 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| - Improving Directory Browsing.......................|netrw-listhack| }}}1 + Making A New Directory.............................|netrw-d| + Making The Browsing Directory The Current Directory|netrw-c| + Marked Files: Compression And Decompression........|netrw-mz| + Marked Files: Printing.............................|netrw-mp| + Marked Files: Tagging..............................|netrw-mT| + Marked Files: Unmarking............................|netrw-mu| + Marking Files......................................|netrw-mf| + Marking Files By Regular Expression................|netrw-mr| + Netrw Browser Variables............................|netrw-browser-var| + Netrw Browsing And Option Incompatibilities........|netrw-incompatible| + Netrw Settings.....................................|netrw-settings| + Obtaining A File...................................|netrw-O| + Preview Window.....................................|netrw-p| + Previous Window....................................|netrw-P| + Refreshing The Listing.............................|netrw-ctrl-l| + Renaming Files Or Directories......................|netrw-move| + Reversing Sorting Order............................|netrw-r| + Selecting Sorting Style............................|netrw-s| 10. Problems and Fixes...................................|netrw-problems| -11. Debugging............................................|netrw-debug| +11. Debugging Netrw Itself...............................|netrw-debug| 12. History..............................................|netrw-history| 13. Credits..............................................|netrw-credits| -The Netrw plugin is generally sourced automatically as it is a -|standard-plugin|. That said, to make use of netrw, one must -have plugins available which can be done with the following -two lines in your <.vimrc>: > - - set nocp " 'compatible' is not set - filetype plugin on " plugins are enabled -< -You can avoid loading this plugin by setting the "loaded_netrw" variable -in your <.vimrc> file: > - - :let loaded_netrw = 1 - {Vi does not have any of this} ============================================================================== -2. Starting With Netrw *netrw-start* +2. Starting With Netrw *netrw-start* {{{1 -Netrw makes reading, writing, and browsing over a network connection easy! -First, make sure that you have plugins enabled, so you'll need to have at -least the following in your <.vimrc>: (or see |netrw-activate|) > +Netrw makes reading files, writing files, browsing over a network, and +browsing locally easy! First, make sure that you have plugins enabled, so +you'll need to have at least the following in your <.vimrc>: +(or see |netrw-activate|) > set nocp " 'compatible' is not set filetype plugin on " plugins are enabled @@ -96,14 +91,13 @@ least the following in your <.vimrc>: (or see |netrw-activate|) > Netrw supports "transparent" editing of files on other machines using urls (see |netrw-transparent|). As an example of this, let's assume you have an -account on some other machine; try > +account on some other machine; if you can use scp, try: > vim scp://hostname/path/to/file < -if you have an ssh connection. Want to make ssh/scp easier to use? Check -out |netrw-listhack|! +Want to make ssh/scp easier to use? Check out |netrw-ssh-hack|! -What if you have ftp, not ssh/scp? That's easy, too; try > +So, what if you have ftp, not ssh/scp? That's easy, too; try > vim ftp://hostname/path/to/file < @@ -117,7 +111,7 @@ and has lines resembling > ... default login USERID password "PASSWORD" < -Now about browsing -- ie. when you just want to look around before editing a +Now about browsing -- when you just want to look around before editing a file. For browsing on your current host, just "edit" a directory: > vim . @@ -131,13 +125,21 @@ the directory name is followed by a "/"): > < See |netrw-browse| for more! -There's more protocols supported than scp and ftp, too: see the next -section, |netrw-externapp|. +There are more protocols supported by netrw just than scp and ftp, too: see the +next section, |netrw-externapp|, for how to use these external applications. + +If you want to use plugins, but for some reason don't wish to use netrw, then +you need to avoid loading both the plugin and the autoload portions of netrw. +You may do so by placing the following two lines in your <.vimrc>: > + + :let g:loaded_netrw = 1 + :let g:loaded_netrwPlugin = 1 +< ============================================================================== -3. Netrw Reference *netrw-ref* +3. Netrw Reference *netrw-ref* {{{1 -CONTROLLING EXTERNAL APPLICATIONS *netrw-externapp* +EXTERNAL APPLICATIONS AND PROTOCOLS *netrw-externapp* {{{2 Protocol Variable Default Value -------- ---------------- ------------- @@ -152,7 +154,15 @@ CONTROLLING EXTERNAL APPLICATIONS *netrw-externapp* scp: *g:netrw_scp_cmd* = "scp -q" sftp: *g:netrw_sftp_cmd* = "sftp" -READING *netrw-read* *netrw-nread* +READING *netrw-read* *netrw-nread* {{{2 + + Generally, one may just use the url notation with a normal editing + command, such as > + + :e ftp://[user@]machine/path +< + Netrw also provides the Nread command: + :Nread ? give help :Nread "machine:path" uses rcp :Nread "machine path" uses ftp w/ <.netrc> @@ -166,7 +176,15 @@ READING *netrw-read* *netrw-nread* :Nread "scp://[user@]machine[[:#]port]/path" uses scp :Nread "sftp://[user@]machine/path" uses sftp -WRITING *netrw-write* *netrw-nwrite* +WRITING *netrw-write* *netrw-nwrite* {{{2 + + Generally, one may just use the url notation with a normal file writing + command, such as > + + :w ftp://[user@]machine/path +< + Netrw also provides the Nwrite command: + :Nwrite ? give help :Nwrite "machine:path" uses rcp :Nwrite "machine path" uses ftp w/ <.netrc> @@ -179,7 +197,15 @@ WRITING *netrw-write* *netrw-nwrite* :Nwrite "sftp://[user@]machine/path" uses sftp http: not supported! -SOURCING *netrw-source* +SOURCING *netrw-source* {{{2 + + Generally, one may just use the url notation with the normal file + sourcing command, such as > + + :so ftp://[user@]machine/path +< + Netrw also provides the Nsource command: + :Nsource ? give help :Nsource "dav://machine[:port]/path" uses cadaver :Nsource "fetch://[user@]machine/path" uses fetch @@ -190,11 +216,20 @@ SOURCING *netrw-source* :Nsource "scp://[user@]machine[[:#]port]/path" uses scp :Nsource "sftp://[user@]machine/path" uses sftp -DIRECTORY LISTING *netrw-dirlist* +DIRECTORY LISTING *netrw-dirlist* {{{2 + + Generally, one may browse a directory to get a listing by simply + attempting to edit the directory: > + + :e scp://[user]@hostname/path/ + :e ftp://[user]@hostname/path/ +< + However, the Nread command can also be used to accomplish this: + :Nread [protocol]://[user]@hostname/path/ - *netrw-login* *netrw-password* - CHANGING USERID AND PASSWORD *netrw-chgup* *netrw-userpass* + *netrw-login* *netrw-password* +CHANGING USERID AND PASSWORD *netrw-chgup* *netrw-userpass* {{{2 Attempts to use ftp will prompt you for a user-id and a password. These will be saved in global variables g:netrw_uid and @@ -204,16 +239,16 @@ DIRECTORY LISTING *netrw-dirlist* first. To work around the need to enter passwords, check if your ftp supports a <.netrc> file in your home directory. Also see |netrw-passwd| (and if you're using ssh/scp hoping to figure out how - to not need to use passwords, look at |netrw-listhack|). + to not need to use passwords, look at |netrw-ssh-hack|). :NetUserPass [uid [password]] -- prompts as needed :call NetUserPass() -- prompts for uid and password :call NetUserPass("uid") -- prompts for password :call NetUserPass("uid","password") -- sets global uid and password -VARIABLES *netrw-variables* +NETRW VARIABLES AND SETTINGS *netrw-variables* {{{2 -(also see: |netrw-browse-var| |netrw-protocol| |netrw-settings| |netrw-var|) +(also see: |netrw-browser-var| |netrw-protocol| |netrw-settings| |netrw-var|) *b:netrw_lastfile* last file Network-read/written retained on a per-buffer basis (supports plain :Nw ) @@ -248,6 +283,12 @@ VARIABLES *netrw-variables* *g:netrw_uid* (ftp) user-id, retained on a per-session basis *g:netrw_passwd* (ftp) password, retained on a per-session basis + *g:netrw_preview* =0 (default) preview window shown in a horizontally + split window + =1 preview window shown in a vertically split window. + Affects the "previous window" (see |netrw-P|) the same + way. + *g:netrw_shq* = "'" for Unix/Linux systems (ie. a single quote) = "'" for Windows + cygwin systems (ie. a single quote) = '"' for Windows systems, not using cygwin @@ -258,6 +299,9 @@ VARIABLES *netrw-variables* *g:netrw_scpport* = "-P" : option to use to set port for scp *g:netrw_sshport* = "-p" : option to use to set port for ssh + *g:netrw_silent* =0 : transfers done normally + =1 : transfers done silently + *g:netrw_use_errorwindow* =1 : messages from netrw will use a separate one line window. This window provides reliable delivery of messages. (default) @@ -279,7 +323,7 @@ VARIABLES *netrw-variables* *g:netrw_use_nt_rcp* =0 don't use the rcp of WinNT, Win2000 and WinXP =1 use WinNT's rcp in binary mode (default) -PATHS *netrw-path* +PATHS *netrw-path* {{{2 Paths to files are generally user-directory relative for most protocols. It is possible that some protocol will make paths relative to some @@ -288,7 +332,7 @@ associated directory, however. example: vim scp://user@host/somefile example: vim scp://user@host/subdir1/subdir2/somefile < -where "somefile" is the "user"'s home directory. If you wish to get a +where "somefile" is in the "user"'s home directory. If you wish to get a file using root-relative paths, use the full path: > example: vim scp://user@host//somefile @@ -296,7 +340,7 @@ file using root-relative paths, use the full path: < ============================================================================== -4. Network-Oriented File Transfer *netrw-xfer* +4. Network-Oriented File Transfer *netrw-xfer* {{{1 Network-oriented file transfer under Vim is implemented by a VimL-based script () using plugin techniques. It currently supports both reading and @@ -312,7 +356,7 @@ FileReadCmd, BufWriteCmd) to intercept reads/writes with url-like filenames. > ex. vim ftp://hostname/path/to/file < The characters preceding the colon specify the protocol to use; in the -example, its ftp. The script then formulates a command or a +example, it's ftp. The script then formulates a command or a series of commands (typically ftp) which it issues to an external program (ftp, scp, etc) which does the actual file transfer/protocol. Files are read from/written to a temporary file (under Unix/Linux, /tmp/...) which the @@ -419,6 +463,10 @@ Both the :Nread and the :Nwrite ex-commands can accept multiple filenames. NETRC *netrw-netrc* +The <.netrc> file, typically located in your home directory, contains lines +therein which map a hostname (machine name) to the user id and password you +prefer to use with it. + The typical syntax for lines in a <.netrc> file is given as shown below. Ftp under Unix usually supports <.netrc>; ftp under Windows usually doesn't. > @@ -433,7 +481,7 @@ password. Since this file contains passwords, make very sure nobody else can read this file! Most programs will refuse to use a .netrc that is readable for others. Don't forget that the system administrator can - still read the file! + still read the file! Ie. for Linux/Unix: chmod 600 .netrc PASSWORD *netrw-passwd* @@ -444,17 +492,19 @@ after one has set it. Unfortunately there doesn't appear to be a way for netrw to feed a password to scp. Thus every transfer via scp will require re-entry of the password. -However, |netrw-listhack| can help with this problem. +However, |netrw-ssh-hack| can help with this problem. ============================================================================== -5. Activation *netrw-activate* +5. Activation *netrw-activate* {{{1 Network-oriented file transfers are available by default whenever Vim's -|'nocompatible'| mode is enabled. The file resides in your -system's vim-plugin directory and is sourced automatically whenever you bring -up vim. I suggest that, at a minimum, you have at least the following in your -<.vimrc> customization file: > +|'nocompatible'| mode is enabled. Netrw's script files reside in your +system's plugin, autoload, and syntax directories; just the +plugin/netrwPlugin.vim script is sourced automatically whenever you bring up +vim. The main script in autoload/netrw.vim is only loaded when you actually +use netrw. I suggest that, at a minimum, you have at least the following in +your <.vimrc> customization file: > set nocp if version >= 600 @@ -463,11 +513,12 @@ up vim. I suggest that, at a minimum, you have at least the following in your < ============================================================================== -6. Transparent File Transfer *netrw-transparent* +6. Transparent File Editing *netrw-transparent* {{{1 Transparent file transfers occur whenever a regular file read or write -(invoked via an |:autocmd| for |BufReadCmd| or |BufWriteCmd| events) is made. -Thus one may use files across networks just as simply as if they were local. > +(invoked via an |:autocmd| for |BufReadCmd|, |BufWriteCmd|, or |SourceCmd| +events) is made. Thus one may read, write, or source files across networks +just as easily as if they were local files! > vim ftp://[user@]machine/path ... @@ -478,10 +529,10 @@ such as netrw. ============================================================================== -7. Ex Commands *netrw-ex* +7. Ex Commands *netrw-ex* {{{1 The usual read/write commands are supported. There are also a few -additional commands available. Often you won't need to use Nw or +additional commands available. Often you won't need to use Nwrite or Nread as shown in |netrw-transparent| (ie. simply use > :e url :r url @@ -489,20 +540,20 @@ Nread as shown in |netrw-transparent| (ie. simply use > instead, as appropriate) -- see |netrw-urls|. In the explanations below, a {netfile} is an url to a remote file. -:[range]Nw Write the specified lines to the current +:[range]Nw[rite] Write the specified lines to the current file as specified in b:netrw_lastfile. -:[range]Nw {netfile} [{netfile}]... +:[range]Nw[rite] {netfile} [{netfile}]... Write the specified lines to the {netfile}. -:Nread Read the specified lines into the current +:Nr[ead] Read the specified lines into the current buffer from the file specified in b:netrw_lastfile. -:Nread {netfile} {netfile}... +:Nr[ead] {netfile} {netfile}... Read the {netfile} after the current line. -:Nsource {netfile} +:Ns[ource] {netfile} Source the {netfile}. To start up vim using a remote .vimrc, one may use the following (all on one line) (tnx to Antoine Mechelynck) > @@ -529,13 +580,15 @@ below, a {netfile} is an url to a remote file. ============================================================================== -8. Variables and Options *netrw-options* *netrw-var* +8. Variables and Options *netrw-options* *netrw-var* {{{1 + +(if you're interested in the netrw browser settings, see: |netrw-browser-var|) The script provides several variables which act as options to -ffect 's behavior. These variables typically may be set in the -user's <.vimrc> file: -(also see: -|netrw-settings| |netrw-browse-var| |netrw-protocol| |netrw-settings|) > +affect 's file transfer behavior. These variables typically may be +set in the user's <.vimrc> file: (see also |netrw-settings| |netrw-protocol|) + +> ------------- Netrw Options @@ -706,83 +759,755 @@ itself: > ============================================================================== -9. Directory Browsing *netrw-browse* *netrw-dir* *netrw-list* *netrw-help* +9. Browsing *netrw-browsing* *netrw-browse* *netrw-help* {{{1 + *netrw-browser* *netrw-dir* *netrw-list* -MAPS *netrw-maps* - .............Help.......................................|netrw-help| - .............Browsing...................................|netrw-cr| - ............Deleting Files or Directories..............|netrw-delete| - -................Going Up...................................|netrw--| - a................Hiding Files or Directories................|netrw-a| - mb...............Bookmarking a Directory....................|netrw-mb| - gb...............Changing to a Bookmarked Directory.........|netrw-gb| - c................Make Browsing Directory The Current Dir....|netrw-c| - d................Make A New Directory.......................|netrw-d| - D................Deleting Files or Directories..............|netrw-D| - ............Edit File/Directory Hiding List............|netrw-ctrl-h| - i................Change Listing Style.......................|netrw-i| - ............Refreshing the Listing.....................|netrw-ctrl-l| - o................Browsing with a Horizontal Split...........|netrw-o| - p................Preview Window.............................|netrw-p| - q................Listing Bookmarks and History..............|netrw-q| - r................Reversing Sorting Order....................|netrw-r| - R................Renaming Files or Directories..............|netrw-R| - s................Selecting Sorting Style....................|netrw-s| - S................Editing the Sorting Sequence...............|netrw-S| - t................Browsing with a new tab....................|netrw-t| - u................Changing to a Predecessor Directory........|netrw-u| - U................Changing to a Successor Directory..........|netrw-U| - v................Browsing with a Vertical Split.............|netrw-v| - x................Customizing Browsing.......................|netrw-x| +INTRODUCTION TO BROWSING *netrw-browse-intro* {{{2 - COMMANDS *netrw-explore-cmds* - :Explore[!] [dir] Explore directory of current file........|netrw-explore| - :Sexplore[!] [dir] Split & Explore directory ...............|netrw-explore| - :Hexplore[!] [dir] Horizontal Split & Explore...............|netrw-explore| - :Vexplore[!] [dir] Vertical Split & Explore.................|netrw-explore| - :Texplore[!] [dir] Tab & Explore............................|netrw-explore| - :Pexplore[!] [dir] Vertical Split & Explore.................|netrw-explore| - :Nexplore[!] [dir] Vertical Split & Explore.................|netrw-explore| - :NetrwSettings.............................................|netrw-settings| +Netrw supports the browsing of directories on your local system and on remote +hosts; browsing includes listing files and directories, entering directories, +editing files therein, deleting files/directories, making new directories, +moving (renaming) files and directories, copying files and directories, etc. +One may mark files and execute any system command on them! The Netrw browser +generally implements the previous explorer's maps and commands for remote +directories, although details (such as pertinent global variable names) +necessarily differ. To browse a directory, simply "edit" it! > -QUICK REFERENCE COMMANDS TABLE *netrw-browse-cmds* + vim /your/directory/ + vim . + vim c:\your\directory\ +< +(Related topics: |netrw-cr| |netrw-o| |netrw-p| |netrw-P| |netrw-t| + |netrw-mf| |netrw-mx| |netrw-D| |netrw-R| |netrw-v| ) + +The Netrw remote file and directory browser handles two protocols: ssh and +ftp. The protocol in the url, if it is ftp, will cause netrw also to use ftp +in its remote browsing. Specifying any other protocol will cause it to be +used for file transfers; but the ssh protocol will be used to do remote +browsing. + +To use Netrw's remote directory browser, simply attempt to read a "file" with +a trailing slash and it will be interpreted as a request to list a directory: > - ------- ----------- - Command Explanation - ------- ----------- -< Causes Netrw to issue help - Netrw will enter the directory or read the file |netrw-cr| - Netrw will attempt to remove the file/directory |netrw-del| - - Makes Netrw go up one directory |netrw--| - a Toggles between normal display, |netrw-a| - hiding (suppress display of files matching g:netrw_list_hide) - showing (display only files which match g:netrw_list_hide) - mb bookmark current directory - gb go to previous bookmarked directory - c Make current browsing directory the current directory |netrw-c| - d Make a directory |netrw-d| - D Netrw will attempt to remove the file(s)/directory(ies) |netrw-D| - 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| - o Enter the file/directory under the cursor in a new browser - window. A horizontal split is used. |netrw-o| - 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| - 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| - S Specify suffix priority for name-sorting |netrw-S| - t Enter the file/directory under the cursor in a new tab|netrw-t| - u Change to recently-visited directory |netrw-u| - U Change to subsequently-visited directory |netrw-U| - v Enter the file/directory under the cursor in a new browser - window. A vertical split is used. |netrw-v| - x Apply a function to a file. (special browsers) |netrw-x| + vim [protocol]://[user@]hostname/path/ +< +where [protocol] is typically scp or ftp. As an example, try: > -NETRW BROWSER VARIABLES *netrw-browse-var* + vim ftp://ftp.home.vim.org/pub/vim/ +< +For local directories, the trailing slash is not required. Again, because its +easy to miss: to browse remote directories, the url must terminate with a +slash! + +If you'd like to avoid entering the password repeatedly for remote directory +listings with ssh or scp, see |netrw-ssh-hack|. To avoid password entry with +ftp, see |netrw-netrc| (if your ftp supports it). + +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! + + +QUICK REFERENCE: MAPS *netrw-browse-maps* {{{2 +> + --- ----------------- ---- + Map Quick Explanation Link + --- ----------------- ---- +< Causes Netrw to issue help + Netrw will enter the directory or read the file |netrw-cr| + Netrw will attempt to remove the file/directory |netrw-del| + - Makes Netrw go up one directory |netrw--| + a Toggles between normal display, |netrw-a| + hiding (suppress display of files matching g:netrw_list_hide) + showing (display only files which match g:netrw_list_hide) + c Make browsing directory the current directory |netrw-c| + 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| + 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| + mb Bookmark current directory |netrw-mb| + mc Copy marked files to marked-file target directory |netrw-mc| + 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| + 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| + mt Current browsing directory becomes markfile target |netrw-mt| + mT Apply ctags to marked files |netrw-mT| + mu Unmark all marked files |netrw-mu| + mx Apply arbitrary shell command to marked files |netrw-mx| + mz Compress/decompress marked files |netrw-mz| + o Enter the file/directory under the cursor in a new |netrw-o| + browser window. A horizontal split is used. + 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| + 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| + S Specify suffix priority for name-sorting |netrw-S| + t Enter the file/directory under the cursor in a new tab|netrw-t| + u Change to recently-visited directory |netrw-u| + U Change to subsequently-visited directory |netrw-U| + v Enter the file/directory under the cursor in a new |netrw-v| + browser window. A vertical split is used. + x View file with an associated program |netrw-x| + + (gvim only) selects word under mouse as if a + had been pressed (ie. edit file, change directory) + (gvim only) same as P selecting word under mouse; + 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. + (gvim only) like mf, will mark files + +QUICK REFERENCE: COMMANDS *netrw-explore-cmds* *netrw-browse-cmds* {{{2 + :NetrwClean[!] ...........................................|netrw-clean| + :NetrwSettings ...........................................|netrw-settings| + :Explore[!] [dir] Explore directory of current file......|netrw-explore| + :Hexplore[!] [dir] Horizontal Split & Explore.............|netrw-explore| + :Nexplore[!] [dir] Vertical Split & Explore...............|netrw-explore| + :Pexplore[!] [dir] Vertical Split & Explore...............|netrw-explore| + :Rexplore Return to Explorer.....................|netrw-explore| + :Sexplore[!] [dir] Split & Explore directory .............|netrw-explore| + :Texplore[!] [dir] Tab & Explore..........................|netrw-explore| + :Vexplore[!] [dir] Vertical Split & Explore...............|netrw-explore| + +BOOKMARKING A DIRECTORY *netrw-mb* *netrw-bookmark* *netrw-bookmarks* {{{2 +One may easily "bookmark" a directory by using > + + {cnt}mb +< +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. + + +BROWSING *netrw-cr* {{{2 + +Browsing is simple: move the cursor onto a file or directory of interest. +Hitting the (the return key) will select the file or directory. +Directories will themselves be listed, and files will be opened using the +protocol given in the original read request. + + CAVEAT: There are four forms of listing (see |netrw-i|). Netrw assumes that + two or more spaces delimit filenames and directory names for the long and + wide listing formats. Thus, if your filename or directory name has two or + more sequential spaces embedded in it, or any trailing spaces, then you'll + need to use the "thin" format to select it. + +The |g:netrw_browse_split| option, which is zero by default, may be used to +cause the opening of files to be done in a new window or tab instead of the +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). + +Related topics: |netrw-o| |netrw-p| |netrw-P| |netrw-t| |netrw-v| + + +BROWSING WITH A HORIZONTALLY SPLIT WINDOW *netrw-o* *netrw-horiz* {{{2 + +Normally one enters a file or directory using the . However, the "o" map +allows one to open a new window to hold the new directory listing or file. A +horizontal split is used. (for vertical splitting, see |netrw-v|) + +Normally, the o key splits the window horizontally with the new window and +cursor at the top. To change to splitting the window horizontally with the +new window and cursor at the bottom, have + + let g:netrw_alto = 1 + +in your <.vimrc>. (also see |netrw-t| |netrw-v| |g:netrw_alto|) + +There is only one tree listing buffer; using "o" on a displayed subdirectory +will split the screen, but the same buffer will be shown twice. + + +BROWSING WITH A NEW TAB *netrw-t* {{{2 + +Normally one enters a file or directory using the . The "t" map +allows one to open a new window hold the new directory listing or file in a +new tab. (also see: |netrw-o| |netrw-v|) + + +BROWSING WITH A VERTICALLY SPLIT WINDOW *netrw-v* {{{2 + +Normally one enters a file or directory using the . However, the "v" map +allows one to open a new window to hold the new directory listing or file. A +vertical split is used. (for horizontal splitting, see |netrw-o|) + +Normally, the v key splits the window vertically with the new window and +cursor at the left. To change to splitting the window vertically with the new +window and cursor at the right, have + + let g:netrw_altv = 1 + +in your <.vimrc>. (also see: |netrw-o| |netrw-t| |g:netrw_altv|) + +There is only one tree listing buffer; using "v" on a displayed subdirectory +will split the screen, but the same buffer will be shown twice. + + +CHANGE LISTING STYLE *netrw-i* {{{2 + +The "i" map cycles between the thin, long, wide, and tree listing formats. + +The short listing format gives just the files' and directories' names. + +The long listing is either based on the "ls" command via ssh for remote +directories or displays the filename, file size (in bytes), and the time and +date of last modification for local directories. With the long listing +format, netrw is not able to recognize filenames which have trailing spaces. +Use the thin listing format for such files. + +The wide listing format uses two or more contiguous spaces to delineate +filenames; when using that format, netrw won't be able to recognize or use +filenames which have two or more contiguous spaces embedded in the name or any +trailing spaces. The thin listing format will, however, work with such files. +This listing format is the most compact. + +The tree listing format has a top directory followed by files and directories +preceded by a "|". One may open and close directories by pressing the +key while atop the directory name. There is only one tree listing buffer; +hence, using "v" or "o" on a subdirectory will only show the same buffer, +twice. + + +CHANGING TO A BOOKMARKED DIRECTORY *netrw-gb* {{{2 + +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. + + +CHANGING TO A PREDECESSOR DIRECTORY *netrw-u* *netrw-updir* {{{2 + +Every time you change to a new directory (new for the current session), +netrw will save the directory in a recently-visited directory history +list (unless g:netrw_dirhistmax is zero; by default, it's ten). With the +"u" map, one can change to an earlier directory (predecessor). To do +the opposite, see |netrw-U|. + + +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|) + + +NETRW CLEAN *netrw-clean* + +With :NetrwClean one may easily remove netrw from one's home directory; +more precisely, from the first directory on your |'runtimepath'|. + +With :NetrwClean!, netrw will remove netrw from all directories on your +|'runtimepath'|. + +With either form of the command, netrw will first ask for confirmation +that the removal is in fact what you want to do. If netrw doesn't have +permission to remove a file, it will issue an error message. + + *netrw-gx* +CUSTOMIZING BROWSING WITH A USER FUNCTION *netrw-x* *netrw-handler* {{{2 + (also see |netrw_filehandler|) + +Certain files, such as html, gif, jpeg, (word/office) doc, etc, files, are +best seen with a special handler (ie. a tool provided with your computer). +Netrw allows one to invoke such special handlers by: > + + * when Exploring, hit the "x" key + * when editing, hit gx with the cursor atop the special filename +< (not available if the |g:netrw_nogx| variable exists) + +Netrw determines which special handler by the following method: + + * if |g:netrw_browsex_viewer| exists, then it will be used to attempt to + view files. Examples of useful settings (place into your <.vimrc>): > + + :let g:netrw_browsex_viewer= "kfmclient exec" +< or > + :let g:netrw_browsex_viewer= "gnome-open" +< + If g:netrw_browsex_viewer == '-', then netrwFileHandler() will be + invoked first (see |netrw_filehandler|). + + * for Windows 32 or 64, the url and FileProtocolHandler dlls are used. + * for Gnome (with gnome-open): gnome-open is used. + * for KDE (with kfmclient) : kfmclient is used. + * for Mac OS X : open is used. + * otherwise the netrwFileHandler plugin is used. + +The file's suffix is used by these various approaches to determine an +appropriate application to use to "handle" these files. Such things as +OpenOffice (*.sfx), visualization (*.jpg, *.gif, etc), and PostScript (*.ps, +*.eps) can be handled. + + *netrw_filehandler* + +The "x" map applies a function to a file, based on its extension. Of course, +the handler function must exist for it to be called! +> + Ex. mypgm.html x -> + NFH_html("scp://user@host/some/path/mypgm.html") +< +Users may write their own netrw File Handler functions to support more +suffixes with special handling. See for +examples on how to make file handler functions. As an example: > + + " NFH_suffix(filename) + fun! NFH_suffix(filename) + ..do something special with filename.. + endfun +< +These functions need to be defined in some file in your .vim/plugin +(vimfiles\plugin) directory. Vim's function names may not have punctuation +characters (except for the underscore) in them. To support suffices that +contain such characters, netrw will first convert the suffix using the +following table: > + + @ -> AT ! -> EXCLAMATION % -> PERCENT + : -> COLON = -> EQUAL ? -> QUESTION + , -> COMMA - -> MINUS ; -> SEMICOLON + $ -> DOLLAR + -> PLUS ~ -> TILDE +< +So, for example: > + + file.rcs,v -> NFH_rcsCOMMAv() +< +If more such translations are necessary, please send me email: > + NdrOchip at ScampbellPfamily.AbizM - NOSPAM +with a request. + + *netrw-curdir* +DELETING FILES OR DIRECTORIES *netrw-delete* *netrw-D* *netrw-del* {{{2 + +If files have not been marked with |netrw-mf|: + + Deleting/removing files and directories involves moving the cursor to the + file/directory to be deleted and pressing "D". Directories must be empty + first before they can be successfully removed. If the directory is a + softlink to a directory, then netrw will make two requests to remove the + directory before succeeding. Netrw will ask for confirmation before doing + the removal(s). You may select a range of lines with the "V" command + (visual selection), and then pressing "D". + +If files have been marked with |netrw-mf|: + + Marked files (and empty directories) will be deleted; again, you'll be + asked to confirm the deletion before it actually takes place. + +The g:netrw_rm_cmd, g:netrw_rmf_cmd, and g:netrw_rmdir_cmd variables are used +to control the attempts to remove files and directories. The g:netrw_rm_cmd +is used with files, and its default value is: + + g:netrw_rm_cmd: ssh HOSTNAME rm + +The g:netrw_rmdir_cmd variable is used to support the removal of directories. +Its default value is: + + g:netrw_rmdir_cmd: ssh HOSTNAME rmdir + +If removing a directory fails with g:netrw_rmdir_cmd, netrw then will attempt +to remove it again using the g:netrw_rmf_cmd variable. Its default value is: + + g:netrw_rmf_cmd: ssh HOSTNAME rm -f + +*netrw-explore* *netrw-hexplore* *netrw-nexplore* *netrw-pexplore* +*netrw-rexplore* *netrw-sexplore* *netrw-texplore* *netrw-vexplore* +DIRECTORY EXPLORATION COMMANDS {{{2 + + :Explore[!] [dir]... Explore directory of current file *:Explore* + :Hexplore[!] [dir]... Horizontal Split & Explore *:Hexplore* + :Rexplore ... Return to Explorer *:Rexplore* + :Sexplore[!] [dir]... Split&Explore directory of current file *:Sexplore* + :Texplore [dir]... Tab & Explore *:Texplore* + :Vexplore[!] [dir]... Vertical Split & Explore *:Vexplore* + + Used with :Explore **/pattern : (also see |netrw-starstar|) + :Nexplore............. go to next matching file *:Nexplore* + :Pexplore............. go to previous matching file *:Pexplore* + +:Explore will open the local-directory browser on the current file's + directory (or on directory [dir] if specified). The window will be + split only if the file has been modified, otherwise the browsing + window will take over that window. Normally the splitting is taken + horizontally. +:Explore! is like :Explore, but will use vertical splitting. +:Sexplore will always split the window before invoking the local-directory + browser. As with Explore, the splitting is normally done + horizontally. +:Sexplore! [dir] is like :Sexplore, but the splitting will be done vertically. +:Hexplore [dir] does an :Explore with |:belowright| horizontal splitting. +:Hexplore! [dir] does an :Explore with |:aboveleft| horizontal splitting. +:Vexplore [dir] does an :Explore with |:leftabove| vertical splitting. +:Vexplore! [dir] does an :Explore with |:rightbelow| vertical splitting. +:Texplore [dir] does a tabnew before generating the browser window + +By default, these commands use the current file's directory. However, one +may explicitly provide a directory (path) to use. + +: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 + that of the last netrw browser window. Its a command version + 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 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: + + == Nexplore, and + == Pexplore. + +As an example, consider +> + :Explore **/*.c + :Nexplore + :Nexplore + :Pexplore +< +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. + + +EDIT FILE OR DIRECTORY HIDING LIST *netrw-ctrl-h* *netrw-edithide* {{{2 + +The "" map brings up a requestor allowing the user to change the +file/directory hiding list. The hiding list consists of one or more patterns +delimited by commas. Files and/or directories satisfying these patterns will +either be hidden (ie. not shown) or be the only ones displayed (see +|netrw-a|). + + +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: +> + [\/]$,*,\.bak$,\.o$,\.h$,\.info$,\.swp$,\.obj$ +< +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 +g:netrw_sort_sequence variable (either manually or in your <.vimrc>) or by +using the "S" map. + + +GOING UP *netrw--* {{{2 + +To go up a directory, press "-" or press the when atop the ../ directory +entry in the listing. + +Netrw will use the command in |g:netrw_list_cmd| to perform the directory +listing operation after changing HOSTNAME to the host specified by the +user-provided url. By default netrw provides the command as: + + ssh HOSTNAME ls -FLa + +where the HOSTNAME becomes the [user@]hostname as requested by the attempt to +read. Naturally, the user may override this command with whatever is +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 + +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 +match. + +If no files have been marked via |netrw-mf|: + +The "a" map allows the user to cycle about these three ways. + +The g:netrw_list_hide variable holds a comma delimited list of patterns (ex. +\.obj) which specify the hiding list. (also see |netrw-ctrl-h|) To set the +hiding list, use the map. As an example, to hide files which begin with +a ".", one may use the map to set the hiding list to '^\..*' (or one may +put let g:netrw_list_hide= '^\..*' in one's <.vimrc>). One may then use the +"a" key to show all files, hide matching files, or to show only the matching +files. + + Example: ^.*\.[ch] + This hiding list command will hide/show all *.c and *.h files. + + Example: ^.*\.c,^.*\.h + This hiding list command will also hide/show all *.c and *.h + files. + +Don't forget to use the "a" map to select the normal/hiding/show mode you want! + +If files have been marked using |netrw-mf|, then this command will: + + if showing all files or non-hidden files: + modify the g:netrw_list_hide list by appending the marked files to it + and showing only non-hidden files. + + else if showing hidden files only: + modify the g:netrw_list_hide list by removing the marked files from it + and showing only non-hidden files. + endif + + *netrw-ctrl_h* +IMPROVING BROWSING *netrw-listhack* *netrw-ssh-hack* {{{2 + +Especially with the remote directory browser, constantly entering the password +is tedious. + +For Linux/Unix systems, the book "Linux Server Hacks - 100 industrial strength +tips & tools" by Rob Flickenger (O'Reilly, ISBN 0-596-00461-3) gives a tip +for setting up no-password ssh and scp and discusses associated security +issues. It used to be available at http://hacks.oreilly.com/pub/h/66 , +but apparently that address is now being redirected to some "hackzine". +I'll attempt a summary: + + 1. Generate a public/private key pair on the ssh server: + ssh-keygen -t rsa + (saving the file in ~/.ssh/id_rsa is ok) + 2. Just hit the when asked for passphrase (twice). + 3. This creates two files: + ~/.ssh/id_rsa + ~/.ssh/id_rsa.pub + 4. On the client: + cd + mkdir .ssh + chmod 0700 .ssh + scp {serverhostname}:.ssh/id_rsa.pub . + cat id_rsa.pub >> .ssh/authorized_keys2 + +For Windows, folks on the vim mailing list have mentioned that Pageant helps +with avoiding the constant need to enter the password. + +Kingston Fung wrote about another way to avoid constantly needing to enter +passwords: + + In order to avoid the need to type in the password for scp each time, you + provide a hack in the docs to set up a non password ssh account. I found a + better way to do that: I can use a regular ssh account which uses a + password to access the material without the need to key-in the password + each time. It's good for security and convenience. I tried ssh public key + authorization + ssh-agent, implementing this, and it works! Here are two + links with instructions: + + http://www.ibm.com/developerworks/library/l-keyc2/ + http://sial.org/howto/openssh/publickey-auth/ + + +LISTING BOOKMARKS AND HISTORY *netrw-q* *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|) + + +MAKING A NEW DIRECTORY *netrw-d* {{{2 + +With the "d" map one may make a new directory either remotely (which depends +on the global variable g:netrw_mkdir_cmd) or locally (which depends on the +global variable g:netrw_local_mkdir). Netrw will issue a request for the new +directory's name. A bare at that point will abort the making of the +directory. Attempts to make a local directory that already exists (as either +a file or a directory) will be detected, reported on, and ignored. + + +MAKING THE BROWSING DIRECTORY THE CURRENT DIRECTORY *netrw-c* {{{2 + +By default, |g:netrw_keepdir| is 1. This setting means that the current +directory will not track the browsing directory. + +Setting g:netrw_keepdir to 0 tells netrw to make vim's current directory to +track netrw's browsing directory. + +However, given the default setting for g:netrw_keepdir of 1 where netrw +maintains its own separate notion of the current directory, in order to make +the two directories the same, use the "c" map (just type c). That map will +set Vim's notion of the current directory to netrw's current browsing +directory. + + +MARKED FILES: ARBITRARY COMMAND *netrw-mx* {{{2 + (See |netrw-mf| and |netrw-mr| for how to mark files) + +Upon activation of the "mx" map, netrw will query the user for some command to +be applied to all marked files. All %s in the command will be substituted +with the name of a marked file. If no %s are in the command, then the command +will be followed by a space and a marked filename. + + +MARKED FILES: COMPRESSION AND DECOMPRESSION *netrw-mz* {{{2 + (See |netrw-mf| and |netrw-mr| for how to mark files) + +If any marked files are compressed, then "mz" will decompress them. +If any marked files are decompressed, then "mz" will compress them +using the command specified by |g:netrw_compress|; by default, +that's "gzip". + +For decompression, netrw provides a |Dictionary| of suffices and their +associated decompressing utilities; see |g:netrw_decompress|. + +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, +select file(s) (see |netrw-mf|), and press "mc". + +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 + (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: MOVING *netrw-mm* {{{2 + (See |netrw-mf| and |netrw-mr| for how to mark files) + +Select a target directory with mT (|netrw-mt|). Then change directory, +select file(s) (see |netrw-mf|), and press "mm". + +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 +is open each file in a one-line window, execute hardcopy, then close the +one-line window. + + +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 +"ctags") to marked files. For remote browsing, in order to create a tags file +netrw will use ssh (see |g:netrw_ssh_cmd|), and so ssh must be available for +this to work on remote systems. For your local system, see |ctags| on how to +get a version. I myself use hdrtags, currently available at +http://mysite.verizon.net/astronaut/src/index.html . + +When a remote set of files are tagged, the resulting tags file is "obtained"; +ie. a copy is transferred to the local system's directory. The local tags +file is then modified so that one may use it through the network. The +modification is concerns the names of the files in the tags; each filename is +preceded by the netrw-compatible url used to obtain it. When one subsequently +uses one of the go to tag actions (|tags|), the url will be used by netrw to +edit the desired file and go to the tag. + + +MARKED FILES: SETTING 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|). + + +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 + (also see |netrw-mr|) + +One may mark files with the cursor atop a filename and then pressing "mf". +With gvim, one may also mark files with . The following netrw +maps make use of marked files: + + |netrw-a| |netrw-O| |netrw-mc| |netrw-me| |netrw-mp| |netrw-mx| + |netrw-D| |netrw-R| |netrw-md| |netrw-mm| |netrw-mT| |netrw-mz| + +One may unmark files one at a time the same way one marks them; ie. place +the cursor atop a marked file and press "mf". This process also works +with using gvim. One may unmark all files by pressing +"mu" (see |netrw-mu|). + +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 + (also see |netrw-mf|) + +One may also mark files by pressing "mr"; netrw will then issue a prompt, +"Enter regexp: ". You may then enter a regular expression such as \.c$ . +All files in the current directory will then be marked. Note that the +regular expressions are vim-style |regexp| ones, not shell ones. So +entering *.c probably isn't what you want! + + +NETRW BROWSER VARIABLES *netrw-browser-options* *netrw-browser-var* {{{2 + +(if you're interestd in the netrw file transfer settings, see |netrw-options|) + +The browser provides settings in the form of variables which +you may modify; by placing these settings in your <.vimrc>, you may customize +your browsing preferences. (see also: |netrw-settings|) > --- ----------- Var Explanation @@ -810,6 +1535,15 @@ NETRW BROWSER VARIABLES *netrw-browse-var* a script/function to handle the given extension. (see |netrw_filehandler|). + *g:netrw_compress* ="gzip" + Will compress marked files with this + command + *g:netrw_decompress* = { ".gz" : "gunzip" , + ".bz2" : "bunzip2" , + ".zip" : "unzip" , + ".tar" : "tar -xf"} + A dictionary mapping suffices to + decompression programs. *g:netrw_fastbrowse* =0: slow speed browsing, never re-use directory listings; always obtain directory listings. @@ -884,6 +1618,16 @@ NETRW BROWSER VARIABLES *netrw-browse-var* *g:netrw_list_hide* comma separated pattern list for hiding files default: "" + *g:netrw_localcopycmd* ="cp" Linux/Unix/MacOS/Cygwin + ="copy" Windows + Copies marked files (|netrw-mf|) to target + directory (|netrw-mt|, |netrw-mc|) + + *g:netrw_localmovecmd* ="mv" Linux/Unix/MacOS/Cygwin + ="move" Windows + Moves marked files (|netrw-mf|) to target + directory (|netrw-mt|, |netrw-mm|) + *g:netrw_local_mkdir* command for making a local directory default: "mkdir" @@ -900,6 +1644,11 @@ NETRW BROWSER VARIABLES *netrw-browse-var* *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 + return to the netrw browser window. + default: =0 + *g:netrw_rm_cmd* command for removing files default: "ssh USEPORT HOSTNAME rm" @@ -947,36 +1696,11 @@ NETRW BROWSER VARIABLES *netrw-browse-var* default: "" *g:NetrwTopLvlMenu* This variable specifies the top level - menu name; by default, its "Netrw.". If + menu name; by default, it's "Netrw.". If you wish to change this, do so in your .vimrc. -INTRODUCTION TO DIRECTORY BROWSING *netrw-browse-intro* - -Netrw supports the browsing of directories on the local system and on remote -hosts, including listing files and directories, entering directories, editing -files therein, deleting files/directories, making new directories, and moving -(renaming) files and directories. The Netrw browser generally implements the -previous explorer maps and commands for remote directories, although details -(such as pertinent global variable names) necessarily differ. - -The Netrw remote file and directory browser handles two protocols: ssh and -ftp. The protocol in the url, if it is ftp, will cause netrw to use ftp -in its remote browsing. Any other protocol will be used for file transfers, -but otherwise the ssh protocol will be used to do remote directory browsing. - -To use Netrw's remote directory browser, simply attempt to read a "file" with a -trailing slash and it will be interpreted as a request to list a directory: - - vim [protocol]://[user@]hostname/path/ - -For local directories, the trailing slash is not required. - -If you'd like to avoid entering the password in for remote directory listings -with ssh or scp, see |netrw-listhack|. - - -NETRW BROWSING AND OPTION INCOMPATIBILITIES *netrw-incompatible* +NETRW BROWSING AND OPTION INCOMPATIBILITIES *netrw-incompatible* {{{2 Netrw will not work properly with > @@ -987,149 +1711,36 @@ If either of these options are present when browsing is attempted, netrw will change them by using noacd and removing the ta suboptions from the |'formatoptions'|. - *netrw-explore* *netrw-pexplore* *netrw-texplore* - *netrw-hexplore* *netrw-sexplore* *netrw-nexplore* - *netrw-vexplore* -DIRECTORY EXPLORING COMMANDS +NETRW SETTINGS *netrw-settings* {{{2 - :Explore[!] [dir]... Explore directory of current file *:Explore* - :Sexplore[!] [dir]... Split&Explore directory of current file *:Sexplore* - :Hexplore[!] [dir]... Horizontal Split & Explore *:Hexplore* - :Vexplore[!] [dir]... Vertical Split & Explore *:Vexplore* - :Texplore [dir]... Tab & Explore *:Texplore* +With the NetrwSettings.vim plugin, > + :NetrwSettings +will bring up a window with the many variables that netrw uses for its +settings. You may change any of their values; when you save the file, the +settings therein will be used. One may also press "?" on any of the lines for +help on what each of the variables do. - Used with :Explore **/pattern : (also see |netrw-starstar|) - :Nexplore............. go to next matching file *:Nexplore* - :Pexplore............. go to previous matching file *:Pexplore* - -:Explore will open the local-directory browser on the current file's - directory (or on directory [dir] if specified). The window will be - split only if the file has been modified, otherwise the browsing - window will take over that window. Normally the splitting is taken - horizontally. -:Explore! is like :Explore, but will use vertical splitting. -:Sexplore will always split the window before invoking the local-directory - browser. As with Explore, the splitting is normally done - horizontally. -:Sexplore! [dir] is like :Sexplore, but the splitting will be done vertically. -:Hexplore [dir] does an :Explore with |:belowright| horizontal splitting. -:Hexplore! [dir] does an :Explore with |:aboveleft| horizontal splitting. -:Vexplore [dir] does an :Explore with |:leftabove| vertical splitting. -:Vexplore! [dir] does an :Explore with |:rightbelow| vertical splitting. -:Texplore [dir] does a tabnew before generating the browser window - -By default, these commands use the current file's directory. However, one -may explicitly provide a directory (path) to use. - - *netrw-starstar* -When Explore, Sexplore, Hexplore, or Vexplore are used with a **/filepat, -such as: -> - :Explore **/filename_pattern -< -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: - - == Nexplore, and - == Pexplore. - -As an example, consider -> - :Explore **/*.c - :Nexplore - :Nexplore - :Pexplore -< -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. +(also see: |netrw-browser-var| |netrw-protocol| |netrw-var| |netrw-variables|) -REFRESHING THE LISTING *netrw-ctrl-l* *netrw-ctrl_l* +============================================================================== +OBTAINING A FILE *netrw-O* {{{2 -To refresh either a local or remote directory listing, press ctrl-l () or -hit the when atop the ./ directory entry in the listing. One may also -refresh a local directory by using ":e .". +If there are no marked files: + When browsing a remote directory, one may obtain a file under the cursor + (ie. get a copy on your local machine, but not edit it) by pressing the O + key. -GOING UP *netrw--* +If there are marked files: -To go up a directory, press "-" or press the when atop the ../ directory -entry in the listing. + The marked files will be obtained (ie. a copy will be transferred to your + local machine, but not set up for editing). -Netrw will use the command in |g:netrw_list_cmd| to perform the directory -listing operation after changing HOSTNAME to the host specified by the -user-provided url. By default netrw provides the command as: - - ssh HOSTNAME ls -FLa - -where the HOSTNAME becomes the [user@]hostname as requested by the attempt to -read. Naturally, the user may override this command with whatever is -preferred. The NetList function which implements remote directory browsing -expects that directories will be flagged by a trailing slash. - - -BROWSING *netrw-cr* - -Browsing is simple: move the cursor onto a file or directory of interest. -Hitting the (the return key) will select the file or directory. -Directories will themselves be listed, and files will be opened using the -protocol given in the original read request. - - CAVEAT: There are four forms of listing (see |netrw-i|). Netrw assumes - that two or more spaces delimit filenames and directory names for the long - and wide listing formats. Thus, if your filename or directory name has two - or more spaces embedded in it, or any trailing spaces, then you'll need to - use the "thin" format to select it. - -The |g:netrw_browse_split| option, which is zero by default, may be used to -cause the opening of files to be done in a new window or tab. 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. - - -OBTAINING A FILE *netrw-O* - -When browsing a remote directory, one may obtain a file under the cursor (ie. -get a copy on your local machine, but not edit it) by pressing the O key. Only ftp and scp are supported for this operation (but since these two are -available for browsing, that shouldn't be a problem). The status bar -will then show, on its right hand side, a message like "Obtaining filename". -The statusline will be restored after the transfer is complete. +available for browsing, that shouldn't be a problem). The status bar will +then show, on its right hand side, a message like "Obtaining filename". The +statusline will be restored after the transfer is complete. Netrw can also "obtain" a file using the local browser. Netrw's display of a directory is not necessarily the same as Vim's "current directory", @@ -1144,167 +1755,16 @@ Related topics: directory, see |g:netrw_keepdir|. -CHANGE LISTING STYLE *netrw-i* - -The "i" map cycles between the thin, long, wide, and tree listing formats. - -The short listing format gives just the files' and directories' names. - -The long listing is either based on the "ls" command via ssh for remote -directories or displays the filename, file size (in bytes), and the time and -date of last modification for local directories. With the long listing -format, netrw is not able to recognize filenames which have trailing spaces. -Use the thin listing format for such files. - -The wide listing format uses two or more contiguous spaces to delineate -filenames; when using that format, netrw won't be able to recognize or use -filenames which have two or more contiguous spaces embedded in the name or any -trailing spaces. The thin listing format will, however, work with such files. -This listing format is the most compact. - -The tree listing format has a top directory followed by files and directories -preceded by a "|". One may open and close directories by pressing the -key while atop the directory name. There is only one tree listing buffer; -hence, using "v" or "o" on a subdirectory will only show the same buffer, -twice. - - -MAKING A NEW DIRECTORY *netrw-d* - -With the "d" map one may make a new directory either remotely (which depends -on the global variable g:netrw_mkdir_cmd) or locally (which depends on the -global variable g:netrw_local_mkdir). Netrw will issue a request for the new -directory's name. A bare at that point will abort the making of the -directory. Attempts to make a local directory that already exists (as either -a file or a directory) will be detected, reported on, and ignored. - - -DELETING FILES OR DIRECTORIES *netrw-delete* *netrw-D* *netrw-del* - -Deleting/removing files and directories involves moving the cursor to the -file/directory to be deleted and pressing "D". Directories must be empty -first before they can be successfully removed. If the directory is a softlink -to a directory, then netrw will make two requests to remove the directory -before succeeding. Netrw will ask for confirmation before doing the -removal(s). You may select a range of lines with the "V" command (visual -selection), and then pressing "D". - -The g:netrw_rm_cmd, g:netrw_rmf_cmd, and g:netrw_rmdir_cmd variables are used -to control the attempts to remove files and directories. The g:netrw_rm_cmd -is used with files, and its default value is: - - g:netrw_rm_cmd: ssh HOSTNAME rm - -The g:netrw_rmdir_cmd variable is used to support the removal of directories. -Its default value is: - - g:netrw_rmdir_cmd: ssh HOSTNAME rmdir - -If removing a directory fails with g:netrw_rmdir_cmd, netrw then will attempt -to remove it again using the g:netrw_rmf_cmd variable. Its default value is: - - g:netrw_rmf_cmd: ssh HOSTNAME rm -f - - -RENAMING FILES OR DIRECTORIES *netrw-move* *netrw-rename* *netrw-R* - -Renaming/moving files and directories involves moving the cursor to the -file/directory to be moved (renamed) and pressing "R". You will then be -queried for where you want the file/directory to be moved. You may select a -range of lines with the "V" command (visual selection), and then pressing "R". - -The g:netrw_rename_cmd variable is used to implement renaming. By default its -value is: - - ssh HOSTNAME mv - -One may rename a block of files and directories by selecting them with -the V (|linewise-visual|). - - -HIDING FILES OR DIRECTORIES *netrw-a* *netrw-hiding* - -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 -match. The "a" map allows the user to cycle about these three ways. - -The g:netrw_list_hide variable holds a comma delimited list of patterns (ex. -\.obj) which specify the hiding list. (also see |netrw-ctrl-h|) To set the -hiding list, use the map. As an example, to hide files which begin with -a ".", one may use the map to set the hiding list to '^\..*' (or one may -put let g:netrw_list_hide= '^\..*' in one's <.vimrc>). One may then use the -"a" key to show all files, hide matching files, or to show only the matching -files. - - Example: ^.*\.[ch] - This hiding list command will hide/show all *.c and *.h files. - - Example: ^.*\.c,^.*\.h - This hiding list command will also hide/show all *.c and *.h - files. - -Don't forget to use the "a" map to select the normal/hiding/show mode you want! - - *netrw-ctrl_h* -EDIT FILE OR DIRECTORY HIDING LIST *netrw-ctrl-h* *netrw-edithide* - -The "" map brings up a requestor allowing the user to change the -file/directory hiding list. The hiding list consists of one or more patterns -delimited by commas. Files and/or directories satisfying these patterns will -either be hidden (ie. not shown) or be the only ones displayed (see -|netrw-a|). - - -BROWSING WITH A HORIZONTALLY SPLIT WINDOW *netrw-o* *netrw-horiz* - -Normally one enters a file or directory using the . However, the "o" map -allows one to open a new window to hold the new directory listing or file. A -horizontal split is used. (for vertical splitting, see |netrw-v|) - -Normally, the o key splits the window horizontally with the new window and -cursor at the top. To change to splitting the window horizontally with the -new window and cursor at the bottom, have - - let g:netrw_alto = 1 - -in your <.vimrc>. (also see |netrw-t| |netrw-v| |g:netrw_alto|) - -There is only one tree listing buffer; using "o" on a displayed subdirectory -will split the screen, but the same buffer will be shown twice. - - -BROWSING WITH A VERTICALLY SPLIT WINDOW *netrw-v* - -Normally one enters a file or directory using the . However, the "v" map -allows one to open a new window to hold the new directory listing or file. A -vertical split is used. (for horizontal splitting, see |netrw-o|) - -Normally, the v key splits the window vertically with the new window and -cursor at the left. To change to splitting the window vertically with the new -window and cursor at the right, have - - let g:netrw_altv = 1 - -in your <.vimrc>. (also see: |netrw-o| |netrw-t| |g:netrw_altv|) - -There is only one tree listing buffer; using "v" on a displayed subdirectory -will split the screen, but the same buffer will be shown twice. - - -BROWSING WITH A NEW TAB *netrw-t* - -Normally one enters a file or directory using the . The "t" map -allows one to open a new window hold the new directory listing or file in a -new tab. (also see: |netrw-o| |netrw-v|) - - -PREVIEW WINDOW *netrw-p* *netrw-preview* +PREVIEW WINDOW *netrw-p* *netrw-preview* {{{2 One may use a preview window by using the "p" key when the cursor is atop the -desired filename to be previewed. +desired filename to be previewed. The display will then split to show both +the browser (where the cursor will remain) and the file (see |:pedit|). +By default, the split will be taken horizontally; one may use vertical +splitting if one has set |g:netrw_preview| first. -PREVIOUS WINDOW *netrw-P* *netrw-prvwin* +PREVIOUS WINDOW *netrw-P* *netrw-prvwin* {{{2 To edit a file or directory in the previously used window (see :he |CTRL-W_P|), press a "P". If there's only one window, then the one window will be @@ -1318,205 +1778,51 @@ the user will be asked if s/he wishes to save the buffer first (yes, no, or cancel). -SELECTING SORTING STYLE *netrw-s* *netrw-sort* +REFRESHING THE LISTING *netrw-ctrl-l* *netrw-ctrl_l* {{{2 + +To refresh either a local or remote directory listing, press ctrl-l () or +hit the when atop the ./ directory entry in the listing. One may also +refresh a local directory by using ":e .". + + +RENAMING FILES OR DIRECTORIES *netrw-move* *netrw-rename* *netrw-R* {{{2 + +If there are no marked files: (see |netrw-mf|) + + Renaming/moving files and directories involves moving the cursor to the + file/directory to be moved (renamed) and pressing "R". You will then be + queried for where you want the file/directory to be moved. You may select + a range of lines with the "V" command (visual selection), and then + pressing "R". + +If there are marked files: (see |netrw-mf|) + + Marked files will be renamed (moved). You will be queried as above in + order to specify where you want the file/directory to be moved. + +The g:netrw_rename_cmd variable is used to implement renaming. By default its +value is: + + ssh HOSTNAME mv + +One may rename a block of files and directories by selecting them with +the V (|linewise-visual|). + + +REVERSING SORTING ORDER *netrw-r* *netrw-reverse* {{{2 + +One may toggle between normal and reverse sorting order by pressing the +"r" key. + + +SELECTING SORTING STYLE *netrw-s* *netrw-sort* {{{2 One may select the sorting style by name, time, or (file) size. The "s" map allows one to circulate amongst the three choices; the directory listing will automatically be refreshed to reflect the selected style. -EDITING THE SORTING SEQUENCE *netrw-S* *netrw-sortsequence* - -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: -> - [\/]$,*,\.bak$,\.o$,\.h$,\.info$,\.swp$,\.obj$ -< -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 -g:netrw_sort_sequence variable (either manually or in your <.vimrc>) or by -using the "S" map. - - -REVERSING SORTING ORDER *netrw-r* *netrw-reverse* - -One may toggle between normal and reverse sorting order by pressing the -"r" key. - - -CHANGING TO A PREDECESSOR DIRECTORY *netrw-u* *netrw-updir* - -Every time you change to a new directory (new for the current session), -netrw will save the directory in a recently-visited directory history -list (unless g:netrw_dirhistmax is zero; by default, its ten). With the -"u" map, one can change to an earlier directory (predecessor). To do -the opposite, see |netrw-U|. - - -CHANGING TO A SUCCESSOR DIRECTORY *netrw-U* *netrw-downdir* - -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|) - - *netrw-gx* -CUSTOMIZING BROWSING WITH A USER FUNCTION *netrw-x* *netrw-handler* - (also see |netrw_filehandler|) - -Certain files, such as html, gif, jpeg, (word/office) doc, etc, files, are -best seen with a special handler (ie. a tool provided with your computer). -Netrw allows one to invoke such special handlers by: > - - * when Exploring, hit the "x" key - * when editing, hit gx with the cursor atop the special filename -< (not available if the |g:netrw_nogx| variable exists) - -Netrw determines which special handler by the following method: - - * if |g:netrw_browsex_viewer| exists, then it will be used to attempt to - view files. Examples of useful settings (place into your <.vimrc>): > - - :let g:netrw_browsex_viewer= "kfmclient exec" -< or > - :let g:netrw_browsex_viewer= "gnome-open" -< - If g:netrw_browsex_viewer == '-', then netrwFileHandler() will be - invoked first (see |netrw_filehandler|). - - * for Windows 32 or 64, the url and FileProtocolHandler dlls are used. - * for Gnome (with gnome-open): gnome-open is used. - * for KDE (with kfmclient): kfmclient is used. - * otherwise the netrwFileHandler plugin is used. - -The file's suffix is used by these various approaches to determine an -appropriate application to use to "handle" these files. Such things as -OpenOffice (*.sfx), visualization (*.jpg, *.gif, etc), and PostScript (*.ps, -*.eps) can be handled. - - *netrw_filehandler* - -The "x" map applies a function to a file, based on its extension. Of course, -the handler function must exist for it to be called! -> - Ex. mypgm.html x -> - NFH_html("scp://user@host/some/path/mypgm.html") -< -Users may write their own netrw File Handler functions to support more -suffixes with special handling. See for -examples on how to make file handler functions. As an example: > - - " NFH_suffix(filename) - fun! NFH_suffix(filename) - ..do something special with filename.. - endfun -< -These functions need to be defined in some file in your .vim/plugin -(vimfiles\plugin) directory. Vim's function names may not have punctuation -characters (except for the underscore) in them. To support suffices that -contain such characters, netrw will first convert the suffix using the -following table: > - - @ -> AT ! -> EXCLAMATION % -> PERCENT - : -> COLON = -> EQUAL ? -> QUESTION - , -> COMMA - -> MINUS ; -> SEMICOLON - $ -> DOLLAR + -> PLUS ~ -> TILDE -< -So, for example: > - - file.rcs,v -> NFH_rcsCOMMAv() -< -If more such translations are necessary, please send me email: > - NdrOchip at ScampbellPfamily.AbizM - NOSPAM -with a request. - - -MAKING THE BROWSING DIRECTORY THE CURRENT DIRECTORY *netrw-c* *netrw-curdir* - -By default, |g:netrw_keepdir| is 1. This setting means that the current -directory will not track the browsing directory. - -Setting g:netrw_keepdir to 0 tells netrw to make vim's current directory to -track netrw's browsing directory. - -However, given the default setting for g:netrw_keepdir of 1 where netrw -maintains its own separate notion of the current directory, in order to make -the two directories the same, use the "c" map (just type c). That map will -set Vim's notion of the current directory to netrw's current browsing -directory. - - -BOOKMARKING A DIRECTORY *netrw-mb* *netrw-bookmark* *netrw-bookmarks* -One may easily "bookmark" a directory by using > - - {cnt}mb -< -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. - - -CHANGING TO A BOOKMARKED DIRECTORY *netrw-gb* - -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. - - -LISTING BOOKMARKS AND HISTORY *netrw-q* *netrw-listbookmark* - -Pressing "q" will list the bookmarked directories and directory traversal -history (query). (see |netrw-mb|, |netrw-gb|, |netrw-u|, and |netrw-U|) - - -IMPROVING DIRECTORY BROWSING *netrw-listhack* - -Especially with the remote directory browser, constantly entering the password -is tedious. - -For Linux/Unix systems, the book "Linux Server Hacks - 100 industrial strength -tips & tools" by Rob Flickenger (O'Reilly, ISBN 0-596-00461-3) gives a tip -for setting up no-password ssh and scp and discusses associated security -issues. It used to be available at http://hacks.oreilly.com/pub/h/66 , -but apparently that address is now being redirected to some "hackzine". -I'll attempt a summary: - - 1. Generate a public/private key pair on the ssh server: - ssh-keygen -t rsa - (saving the file in ~/.ssh/id_rsa is ok) - 2. Just hit the when asked for passphrase (twice). - 3. This creates two files: - ~/.ssh/id_rsa - ~/.ssh/id_rsa.pub - 4. On the client: - cd - mkdir .ssh - chmod 0700 .ssh - scp {serverhostname}:.ssh/id_rsa.pub . - cat id_rsa.pub >> .ssh/authorized_keys2 - -For Windows, folks on the vim mailing list have mentioned that Pageant helps -with avoiding the constant need to enter the password. - - -NETRW SETTINGS *netrw-settings* - -With the NetrwSettings.vim plugin, > - :NetrwSettings -will bring up a window with the many variables that netrw uses for its -settings. You may change any of their values; when you save the file, the -settings therein will be used. One may also press "?" on any of the lines for -help on what each of the variables do. - -(also see: |netrw-browse-var| |netrw-protocol| |netrw-var| |netrw-variables|) - - -============================================================================== -10. Problems and Fixes *netrw-problems* +10. Problems and Fixes *netrw-problems* {{{1 (This section is likely to grow as I get feedback) (also see |netrw-debug|) @@ -1568,9 +1874,11 @@ help on what each of the variables do. *netrw-p4* P4. I would like long listings to be the default. - let g:netrw_liststyle= 1 + Put the following statement into your |.vimrc|: > - Check out |netrw-browse-var| for more customizations that + let g:netrw_liststyle= 1 +< + Check out |netrw-browser-var| for more customizations that you can set. *netrw-p5* @@ -1579,15 +1887,18 @@ help on what each of the variables do. Does your system's strftime() accept the "%c" to yield dates such as "Sun Apr 27 11:49:23 1997"? If not, do a "man strftime" and find out what option should be used. Then put it into - your <.vimrc>: - let g:netrw_timefmt= "%X" (where X is the option) + your |.vimrc|: > + let g:netrw_timefmt= "%X" (where X is the option) +< *netrw-p6* P6. I want my current directory to track my browsing. How do I do that? + Put the following line in your |.vimrc|: +> let g:netrw_keepdir= 0 - +< *netrw-p7* P7. I use Chinese (or other non-ascii) characters in my filenames, and netrw (Explore, Sexplore, Hexplore, etc) doesn't display them! @@ -1652,9 +1963,9 @@ help on what each of the variables do. {asterisk}.{asterisk} (all files), or whatever types you want (cec: change {asterisk} to * ; I had to write it that way because otherwise the helptags - system thinks its a tag) - - Make sure its at the top of the listbox (click it, - then click "Up" if its not) + system thinks it's a tag) + - Make sure it's at the top of the listbox (click it, + then click "Up" if it's not) If using the Norton Commander style, you just have to hit to edit a file in a local copy of gvim. @@ -1663,7 +1974,7 @@ help on what each of the variables do. http://www.tartarus.org/~simon/puttydoc/Chapter8.html#pubkey-gettingready 8.3 Getting ready for public key authentication < - How to use private key with 'pscp': > + How to use a private key with 'pscp': > http://www.tartarus.org/~simon/puttydoc/Chapter5.html 5.2.4 Using public key authentication with PSCP < @@ -1688,52 +1999,77 @@ help on what each of the variables do. in your <.vimrc>: > let g:netrw_use_noswf= 0 < + *netrw-p10* + P10. I'm being pestered with "[something] is a directory" and + "Press ENTER or type command to continue" prompts... + + The "[something] is a directory" prompt is issued by Vim, + not by netrw, and there appears to be no way to work around + it. Coupled with the default cmdheight of 1, this message + causes the "Press ENTER..." prompt. So: read |hit-enter|; + I also suggest that you set your |'cmdheight'| to 2 (or more) in + your <.vimrc> file. + + *netrw-p11* + P11. I want to have two windows; a thin one on the left and my editing + window on the right. How can I do this? + + * Put the following line in your <.vimrc>: + let g:netrw_altv = 1 + * Edit the current directory: :e . + * Select some file, press v + * Resize the windows as you wish (see |ctrl-w_<| and + |ctrl-w_>|). If you're using gvim, you can drag + the separating bar with your mouse. + * When you want a new file, use ctrl-w h to go back to the + netrw browser, select a file, then press P (see |ctrl-w_h| + and |netrw-P|). If you're using gvim, you can press + in the browser window and then press the + to select the file. ============================================================================== -11. Debugging *netrw-debug* +11. Debugging Netrw Itself *netrw-debug* {{{1 The script is typically available as: > - /usr/local/share/vim/vim6x/plugin/netrw.vim + /usr/local/share/vim/vim6x/plugin/netrwPlugin.vim + /usr/local/share/vim/vim6x/autoload/netrw.vim < -or- > - /usr/local/share/vim/vim7x/plugin/netrw.vim + /usr/local/share/vim/vim7x/plugin/netrwPlugin.vim + /usr/local/share/vim/vim7x/autoload/netrw.vim < which is loaded automatically at startup (assuming :set nocp). 1. Get the script, available as: - http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_scripts - as "Decho, a vimL debugging aid" + http://mysite.verizon.net/astronaut/vim/index.html#DECHO or http://vim.sourceforge.net/scripts/script.php?script_id=120 - and put it into your local plugin directory. + It now comes as a "vimball"; if you're using vim 7.0 or earlier, + you'll need to update vimball, too. See + http://mysite.verizon.net/astronaut/vim/index.html#VIMBALL - 2. itself needs the script, so you'll need - to put it into your .vim/plugin, too. You may obtain it from: - - http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs - as "DrC's Utilities" - - 3. Edit the file by typing: + 2. Edit the file by typing: > vim netrw.vim :DechoOn :wq - - To restore to normal non-debugging behavior, edit - by typing +< + To restore to normal non-debugging behavior, re-edit + and type > vim netrw.vim :DechoOff :wq - +< This command, provided by , will comment out all Decho-debugging statements (Dfunc(), Dret(), Decho(), Dredir()). - 4. Then bring up vim and attempt a transfer or do browsing. A set of - messages should appear concerning the steps that took - in attempting to read/write your file over the network. + 3. Then bring up vim and attempt to evoke the problem by doing a + transfer or doing some browsing. A set of messages should appear + concerning the steps that took in attempting to + read/write your file over the network in a separate tab. To save the file, use > :wincmd j @@ -1745,15 +2081,75 @@ which is loaded automatically at startup (assuming :set nocp). ============================================================================== 12. History *netrw-history* {{{1 + v114: Sep 28, 2007 * mT, the map that invokes tags, has been improved + to support use of remote tags files. + Oct 02, 2007 * changed Netrw menu to use more submenus + v113: Sep 07, 2007 * worked out why the cursor position wasn't being + saved and restored as intended after doing such + things as deleting and renaming files. + Sep 11, 2007 * Fixed bug which effectively disabled and + maps + Sep 18, 2007 * there used to be one NetrwOptionRestore() call at + the end of the s:NetrwBrowseChgDir() function; + they're now at the end of every if..elseif..else + block. The edit-a-file one is not quite at the end + of its block; instead, its just before the edit. + Restores user options, then this new placement + allows ftplugins, autocmds, etc to change settings + (ex. ftplugin/cpp.vim sets cindent). + Sep 19, 2007 * changed all strlen() calls to use s:Strlen(), a + function which handles utf-8 wide characters + correctly. + Sep 20, 2007 * (Nico Weber) the "x" command has been extended + to Mac's OS/X (macunix); it now uses open to + handle |netrw-x| browsing with special files. + Sep 22, 2007 * Added |g:netrw_noretmap| to netrw at Tony M's + request. + * Included path to NetrwRemoteRmFile() + v112: Aug 18, 2007 * added mx (|netrw-mx|) for executing arbitrary + commands on marked files + Aug 22, 2007 * more option save/restore work for + s:NetrwBrowseChgDir(); s:NetrwOptionSave() + and s:NetrwOptionRestore() now take a parameter + specifying the type of variables to be used for + saving and restoring (either "w:" or "s:") + Sep 04, 2007 * added the :NetrwClean[!] command + v111: Jul 25, 2007 * using Windows but not using Cygwin, netrw does a + "file bufname" where the bufname uses /s + instead of \s; Vim "fixes" it by changing the + bufname to use \s anyway. This meant that + NetrwGetBuffer() didn't find the appropriately + named buffer, and so would generate a new + buffer listing; hence the cursor would appear + to have been moved when doing a preview. + * added <2-leftmouse> map to return to netrw's + browser display + Aug 16, 2007 * added the mark-file system, including + maps for mf mp mt mz and mu. Modifications + made to maps for a D O and R to support + marked files. + v110: May 10, 2007 * added [ and ] maps to NetrwTreeListing + May 25, 2007 * |g:netrw_preview| included + May 29, 2007 * modifed netrw#NetBrowseX to consistently use + |g:netrw_shq| instead of hardcoded quotes, + and modified the snippet that sets up redir + so Windows machines use "nul" instead of + "/dev/null". + Jun 01, 2007 * fixed bug -- NetGetBuffer() wasn't always + recognizing a buffer name match when it should, + thus resulting in [Scratch] buffers. + Jun 04, 2007 * Gary Johnson found a bugfix for the "c" mapping + when the directory is to be made current but + the name contains spaces. v109: Mar 26, 2007 * if a directory name includes a "$" character, Explore() will use expand() in an attempt to decipher the name. May 07, 2007 * g:netrw_use_errorwindow now allows one to - have error messages go to a reliable window + have error messages go to a reliable window or to use a less reliable but recallable echoerr method May 07, 2007 * g:netrw_scpport and g:netrw_sshport support - use of -P and -p, respectively, to set port + use of -P and -p, respectively, to set port for scp/ssh. v108: Jan 03, 2007 * included preview map (|netrw-p|), supporting remote browsing @@ -1879,257 +2275,319 @@ which is loaded automatically at startup (assuming :set nocp). v97: May 01, 2006 * exists("&acd") now used to determine if the 'acd' option exists * "obtain" now works again under Windows - v96: * bugfix - the |'acd'| option is not always defined but is - now bypassed only when it is - v95: * bugfix - Hiding mode worked correctly (don't show any file - matching any of the g:netrw_hide patterns), but - showing mode was showing only those files that didn't - match any of the g:netrw_hide patterns. Instead, it now - shows all files that match any of the g:netrw_hide patterns - (the difference between a logical and and logical or). - v94: * bugfix - a Decho() had a missing quote; only affects things - when debugging was enabled. - v93: * bugfix - removed FocusGained event from causing a slow-browser - refresh for Windows - v92: * :Explore **//pattern implemented (**/filepattern already taken) - v91: * :Explore */pattern implemented - * |'acd'| option bypassed - v90: * mark ', as suggested by Yegappan Lakshmanan, used to help - guarantee entry into the jump list when appropriate. - * and are no longer defined until a - :Explore **/pattern is used (if the user already has a map - for them). They will be defined for new browser windows - from that point forward. - v89: * A , , :Nexplore, or a :Pexplore without having - first done an :Explore **/pattern (see |netrw-starstar|) caused - a lot of unhelpful error messages to appear - v88: * moved DrChip.Netrw menu to Netrw. Now has priority 80 by - default. g:NetrwTopLvlMenu == "Netrw" and can be changed - by the user to suit. The priority is g:NetrwMenuPriority. - * Changed filetype for browser displays from netrwlist to netrw. - v87: * bug fix -- menus were partially disappearing - v85: * bug fix -- missing an endif - * bug fix -- handles spaces in names and directories when using - ftp-based browsing - v83: * disabled stop-acd handling; the change in directory handling - may allow acd to be used again. Awaiting feedback. - * D was refusing to delete remote files/directories in wide - listing mode. - v81: * FocusGained also used to refresh/wipe local browser directory - buffers - * (bugfix) netrw was leaving [Scratch] buffers behind when the - user had the "hidden" option set. The 'hidden' option is - now bypassed. - v80: * ShellCmdPost event used in conjunction with g:netrw_fastbrowse - to refresh/wipe local browser directory buffers. - v79: * directories are now displayed with nowrap - * (bugfix) if the column width was smaller than the largest - file's name, then netrw would hang when using wide-listing - mode - fixed - * g:netrw_fastbrowse introduced - v78: * progress has been made on allowing spaces inside directory - names for remote work (reading, writing, browsing). (scp) - v77: * Mikolaj Machowski fixed a bug in a substitute command - * g:netrw_browsex_viewer implemented - * Mikolaj Machowski pointed out that gnome-open is often - executable under KDE systems, although it is effectively - not functional. NetBrowseX now looks for "kicker" as - a running process to determine if KDE is actually the - really running. - * Explorer's O functionality was inadvertently left out. - Netrw now does the same thing, but with the "P" key. - * added g:netrw_browse_split option - * fixed a bug where the directory contained a "." but - the file didn't (was treating the dirname from "." - onwards as a suffix) - v76: * "directory is missing" error message now restores echo - highlighting - v75: * file://... now conforms to RFC2396 (thanks to S. Zacchiroli) - * if the binary option is set, then NetWrite() will only write - the whole file (line numbers don't make sense with this). - Supports writing of tar and zip files. - v74: * bugfix (vim, then :Explore) now works - * ctrl-L keeps cursor at same screen location (both local and - remote browsing) - * netrw now can read remote zip and tar files - * Obtain now uses WinXP ftp+.netrc successfully - v73: * bugfix -- scp://host/path/file was getting named incorrectly - * netrw detects use of earlier-than-7.0 version of vim and issues - a pertinent error message. - * netrwSettings.vim is now uses autoloading. Only - is needed as a pure plugin - (ie. always loaded). - v72: * bugfix -- formerly, one could prevent the loading of netrw - by "let g:loaded_netrw=1"; when autoloading became supported, - this feature was lost. It is now restored. - v71: * bugfix -- made some "set nomodifiable"s into setlocal variants - (allows :e somenewfile to be modifiable as usual) - * NetrwSettings calls a netrw function, thereby assuring that - netrw has loaded. However, if netrw does not load for whatever - reason, then NetrwSettings will now issue a warning message. - * For what reason I don't recall, when wget and fetch are both - not present, and an attempt to read a http://... url is made, - netrw exited. It now only returns. - * When ch=1, on the second and subsequent uses of browsing Netrw - would issue a blank line to clear the echo'd messages. This - caused an annoying "Hit-Enter" prompt; now a blank line message - is echo'd only if &ch>1. - v70: * when using |netrw-O|, the "Obtaining filename" message is now - shown using |hl-User9|. If User9 has not been defined, netrw - will define it. - v69: * Bugfix: win95/98 machines were experiencing a - "E121: Undefined variable: g:netrw_win95ftp" message - v68: * double-click-leftmouse selects word under mouse - v67: * Passwords which contain blanks will now be surrounded by - double-quotes automatically (Yongwei) - v66: * Netrw now seems to work with a few more Windows situations - * O now obtains a file: remote browsing file -> local copy, - locally browsing file -> current directory (see :pwd) - * i now cycles between thin, long, and wide listing styles - * NB and Nb are maps that are always available; corresponding - B and b maps are only available when not using wide listing - in order to allow them to be used for motions - v65: * Browser functions now use NetOptionSave/Restore; in particular, - netrw now works around the report setting - v64: * Bugfix - browsing a "/" directory (Unix) yielded buffers - named "[Scratch]" instead of "/" - * Bugfix - remote browsing with ftp was omitting the ./ and ../ - v63: * netrw now takes advantage of autoload (and requires 7.0) - * Bugfix - using r (to reverse sort) working again - v62: * Bugfix - spaces allowed again in directory names with - g:netrw_keepdir=0. In fact, I've tested netrw (again) - with most ANSI punctuation marks for directory names. - * Bugfix - NetrwSettings gave errors when g:netrw_silent - had not be set. - v61: * document upgrade -- netrw variable-based settings all should - have tags. Supports NetrwSettings command. - * several important variables are window-oriented. Netrw has - to transfer these across a window split. See s:BufWinVars() - and s:UseBufWinVars(). - v60: * when using the i map to switch between long and short listings, - netrw will now keep cursor on same line - * "Match # of #" now uses status line - * :Explore **/*.c will now work from a non-netrw-browser window - * :Explore **/patterns can now be run in separate browser windows - * active banner (hit will cause various things to happen) - v59: * bugfix -- another keepalt work-around installed (for vim6.3) - * "Match # of #" for Explore **/pattern matches - v58: * Explore and relatives can now handle **/somefilepattern (v7) - * Nexplore and Pexplore introduced (v7). shift-down and shift-up - cursor keys will invoke Nexplore and Pexplore, respectively. - * bug fixed with o and v - * autochdir only worked around for vim when it has been - compiled with either |+netbeans_intg| or |+sun_workshop| - * Under Windows, all directories and files were being preceded - with a "/" when local browsing. Fixed. - * When: syntax highlighting is off, laststatus=2, and remote - browsing is used, sometimes the laststatus highlighting - bleeds into the entire display. Work around - do an extra - redraw in that case. - * Bugfix: when g:netrw_keepdir=0, due to re-use of buffers, - netrw didn't change the directory when it should've - * Bugfix: D and R commands work again - v57: * Explore and relatives can now handle RO files - * reverse sort restored with vim7's sort command - * g:netrw_keepdir now being used to keep the current directory - unchanged as intended (sense change) - * vim 6.3 still supported - v56: * LocalBrowse now saves autochdir setting, unsets it, and - restores it before returning. - * using vim's rename() instead of system + local_rename variable - * avoids changing directory when g:netrw_keepdir is false - v55: * -bar used with :Explore :Sexplore etc to allow multiple - commands to be separated by |s - * browser listings now use the "nowrap" option - * browser: some unuseful error messages now suppressed - v54: * For backwards compatibility, Explore and Sexplore have been - implemented. In addition, Hexplore and Vexplore commands - are available, too. - * used instead of in the transparency - support (BufReadCmd, FileReadCmd, FileWriteCmd) - * ***netrw*** prepended to various error messages netrw may emit - * g:netrw_port used instead of b:netrw_port for scp - * any leading [:#] is removed from port numbers - v53: * backslashes as well as slashes placed in various patterns - (ex. g:netrw_sort_sequence) to better support Windows - v52: * nonumber'ing now set for browsing buffers - * when the hiding list hid all files, error messages ensued. Fixed - * when browsing, swf is set, but directory is not set, when netrw - was attempting to restore options, vim wanted to save a swapfile - to a local directory using an url-style path. Fixed - v51: * cygwin detection now automated (using windows and &shell is bash) - * customizable browser "file" rejection patterns - * directory history - * :[range]w url now supported (ie. netrw has a FileWriteCmd event) - * error messages have a "Press to continue" to allow them - to be seen - * directory browser displays no longer bother the swapfile - * u/U commands to go up and down the history stack - * history stack may be saved with viminfo with its "!" option - * bugfixes associated with unwanted [No Files] entries - v50: * directories now displayed using buftype=nofile; should keep the - directory names as-is - * attempts to remove empty "[No File]" buffers leftover - from :file ..name.. commands - * bugfix: a "caps-lock" editing difficulty left in v49 was fixed - * syntax highlighting for "Showing:" the hiding list included - * bookmarks can now be retained if "!" is in the viminfo option - v49: * will use ftp for http://.../ browsing v48: - * One may use ftp to do remote host file browsing - * (windows and !cygwin) remote browsing with ftp can now use - the "dir" command internally to provide listings - * g:netrw_keepdir now allows one to keep the initial current - directory as the current directory (normally the local file - browser makes the currently viewed directory the current - directory) - * g:netrw_alto and g:netrw_altv now support alternate placement - of windows started with o or v - * Nread ? and Nwrite ? now uses echomsg (instead of echo) so - :messages can repeat showing the help - * bugfix: avoids problems with partial matches of directory names - to prior buffers with longer names - * one can suppress error messages with g:netrw_quiet ctrl-h used - * instead of h for editing hiding list one may edit the - * sorting sequence with the S map now allows confirmation of - * deletion with [y(es) n(o) a(ll) q(uit)] the "x" map now handles - * special file viewing with: - (windows) rundll32 url.dll (gnome) gnome-open (kde) - kfmclient If none of these are on the executable path, then - netrwFileHandlers.vim is used. - * directory bookmarking during both local and remote browsing - implemented - * one may view all, use the hiding list to suppress, or use the - hiding list to show-only remote and local file/directory - listings - * improved unusual file and directory name handling preview - * window support - v47: * now handles local directory browsing. - v46: * now handles remote directory browsing - * g:netrw_silent (if 1) will cause all transfers to be silent - v45: * made the [user@]hostname:path form a bit more restrictive to - better handle errors in using protocols (e.g. scp:usr@host:file - was being recognized as an rcp request) v44: * changed from - "rsync -a" to just "rsync" - * somehow an editing error messed up the test to recognize - use of the fetch method for NetRead. - * more debugging statements included - v43: * moved "Explanation" comments to help file as - "Network Reference" (|netrw-ref|) - * now uses Dfunc() Decho() and Dret() for debugging - * removed superfluous NetRestorePosn() calls - v42: * now does BufReadPre and BufReadPost events on file:///* and - file://localhost/* v41: * installed file:///* and - file://localhost/* handling v40: * prevents redraw when a - protocol error occurs so that the user may see it v39: * sftp - support v38: * Now uses NetRestorePosn() calls with - Nread/Nwrite commands - * Temporary files now removed via bwipe! instead of bwipe - (thanks to Dave Roberts) v37: * Claar's modifications which - test if ftp is successful, otherwise give an error message - * After a read, the alternate file was pointing to the temp file. - The temp file buffer is now wiped out. - * removed silent from transfer methods so user can see what's - happening + v96: * bugfix - the |'acd'| option is not always defined + but is now bypassed only when it is + v95: * bugfix - Hiding mode worked correctly (don't show + any file matching any of the g:netrw_hide + patterns), but showing mode was showing only those + files that didn't match any of the g:netrw_hide + patterns. Instead, it now shows all files that + match any of the g:netrw_hide patterns (the + difference between a logical and and logical or). + v94: * bugfix - a Decho() had a missing quote; only + affects things when debugging was enabled. + v93: * bugfix - removed FocusGained event from causing a + slow-browser refresh for Windows + v92: * :Explore **//pattern implemented + (**/filepattern was already taken) + v91: * :Explore */pattern implemented + * |'acd'| option bypassed + v90: * mark ', as suggested by Yegappan Lakshmanan, used + to help guarantee entry into the jump list when + appropriate. + * and are no longer defined until a + :Explore **/pattern is used (if the user already + has a map for them). They will be defined for new + browser windows from that point forward. + v89: * A , , :Nexplore, or a :Pexplore + without having first done an :Explore **/pattern + (see |netrw-starstar|) caused + a lot of unhelpful error messages to appear + v88: * moved DrChip.Netrw menu to Netrw. Now has + priority 80 by default. + g:NetrwTopLvlMenu == "Netrw" and can be changed + by the user to suit. The priority is given by + g:NetrwMenuPriority. + * Changed filetype for browser displays from + netrwlist to netrw. + v87: * bug fix -- menus were partially disappearing + v85: * bug fix -- missing an endif + * bug fix -- handles spaces in names and directories + when using ftp-based browsing + v83: * disabled stop-acd handling; the change in directory + handling may allow acd to be used again. + * D was refusing to delete remote files/directories + in wide listing mode. + v81: * FocusGained also used to refresh/wipe local browser + directory buffers + * (bugfix) netrw was leaving [Scratch] buffers behind + when the user had the "hidden" option set. The + 'hidden' option is now bypassed. + v80: * ShellCmdPost event used in conjunction with + g:netrw_fastbrowse to refresh/wipe local browser + directory buffers. + v79: * directories are now displayed with nowrap + * (bugfix) if the column width was smaller than the + largest file's name, then netrw would hang when + using wide-listing mode - fixed + * g:netrw_fastbrowse introduced + v78: * progress has been made on allowing spaces inside + directory names for remote work (reading, writing, + browsing). (scp) + v77: * Mikolaj Machowski fixed a bug in a substitute cmd + * g:netrw_browsex_viewer implemented + * Mikolaj Machowski pointed out that gnome-open is + often executable under KDE systems, although it is + effectively not functional. NetBrowseX now looks + for "kicker" as a running process to determine if + KDE is actually running. + * Explorer's O functionality was inadvertently left + out. Netrw now does the same thing, but with the + "P" key. + * added g:netrw_browse_split option + * fixed a bug where the directory contained a "." but + the file didn't (was treating the dirname from "." + onwards as a suffix) + v76: * "directory is missing" error message now restores + echo highlighting + v75: * file://... now conforms to RFC2396 (thanks to + S. Zacchiroli) + * if the binary option is set, then NetWrite() will + only write the whole file (line numbers don't make + sense with this). Supports writing of tar and zip + files. + v74: * bugfix (vim, then :Explore) now works + * ctrl-L keeps cursor at same screen location (both + local and remote browsing) + * netrw now can read remote zip and tar files + * Obtain now uses WinXP ftp+.netrc successfully + v73: * bugfix -- scp://host/path/file was getting named + incorrectly + * netrw detects use of earlier-than-7.0 version of + vim and issues a pertinent error message. + * netrwSettings.vim is now uses autoloading. Only + is needed as a pure plugin + (ie. always loaded). + v72: * bugfix -- formerly, one could prevent the loading + of netrw by "let g:loaded_netrw=1"; when + autoloading became supported, this feature was + lost. It is now restored. + v71: * bugfix -- made some "set nomodifiable"s into + setlocal variants (allows :e somenewfile to be + modifiable as usual) + * NetrwSettings calls a netrw function, thereby + assuring that netrw has loaded. However, if netrw + does not load for whatever reason, then + NetrwSettings will now issue a warning message. + * For what reason I don't recall, when wget and fetch + are both not present, and an attempt to read a + http://... url is made, netrw exited. It now only + returns. + * When ch=1, on the second and subsequent uses of + browsing Netrw would issue a blank line to clear + the echo'd messages. This caused an annoying + "Hit-Enter" prompt; now a blank line message + is echo'd only if &ch>1. + v70: * when using |netrw-O|, the "Obtaining filename" + message is now shown using |hl-User9|. If User9 + has not been defined, netrw itself will define it. + v69: * Bugfix: win95/98 machines were experiencing a + "E121: Undefined variable: g:netrw_win95ftp" + message + v68: * double-click-leftmouse selects word under mouse + v67: * Passwords which contain blanks will now be + surrounded by double-quotes automatically (Yongwei) + v66: * Netrw now seems to work with a few more Windows + situations + * O now obtains a file: remote browsing + file -> local copy, locally browsing + file -> current directory (see :pwd) + * i now cycles between thin, long, and wide listing + styles + * NB and Nb are maps that are always available; + corresponding B and b maps are only available when + not using wide listing in order to allow them to + be used for motions + v65: * Browser functions now use NetOptionSave/Restore; in + particular, netrw now works around the report + setting + v64: * Bugfix - browsing a "/" directory (Unix) yielded + buffers named "[Scratch]" instead of "/" + * Bugfix - remote browsing with ftp was omitting + the ./ and ../ + v63: * netrw now takes advantage of autoload (needs 7.0) + * Bugfix - using r (to reverse sort) working again + v62: * Bugfix - spaces allowed again in directory names + with g:netrw_keepdir=0. In fact, I've tested netrw + with most ANSI punctuation marks for directory + names. + * Bugfix - NetrwSettings gave errors when + g:netrw_silent had not be set. + v61: * Document upgrade -- netrw variable-based settings + all should have tags. Supports NetrwSettings cmd. + * Several important variables are window-oriented. + Netrw has to transfer these across a window split. + See s:BufWinVars() and s:UseBufWinVars(). + v60: * When using the i map to switch between long and + short listings, netrw will now keep cursor on same + line + * "Match # of #" now uses status line + * :Explore **/*.c will now work from a + non-netrw-browser window + * :Explore **/patterns can now be run in separate + browser windows + * active banner (hit will cause various things + to happen) + v59: * bugfix -- another keepalt work-around installed + (for vim6.3) + * "Match # of #" for Explore **/pattern matches + v58: * Explore and relatives can now handle + **/somefilepattern (v7) + * Nexplore and Pexplore introduced (v7). shift-down + and shift-up cursor keys will invoke Nexplore and + Pexplore, respectively. + * bug fixed with o and v + * autochdir only worked around for vim when it has + been compiled with either + |+netbeans_intg| or |+sun_workshop| + * Under Windows, all directories and files were + being preceded with a "/" when local browsing. + Fixed. + * When: syntax highlighting is off, laststatus=2, and + remote browsing is used, sometimes the laststatus + highlighting bleeds into the entire display. Work + around - do an extra redraw in that case. + * Bugfix: when g:netrw_keepdir=0, due to re-use of + buffers, netrw didn't change the directory when it + should've + * Bugfix: D and R commands work again + v57: * Explore and relatives can now handle RO files + * reverse sort restored with vim7's sort command + * g:netrw_keepdir now being used to keep the current + directory unchanged as intended (sense change) + * vim 6.3 still supported + v56: * LocalBrowse now saves autochdir setting, unsets it, + and restores it before returning. + * using vim's rename() instead of system + + local_rename variable + * avoids changing directory when g:netrw_keepdir is + false + v55: * -bar used with :Explore :Sexplore etc to allow + multiple commands to be separated by |s + * browser listings now use the "nowrap" option + * browser: some unuseful error messages now + suppressed + v54: * For backwards compatibility, Explore and Sexplore + have been implemented. In addition, Hexplore and + Vexplore commands are available, too. + * used instead of in the + transparency support (BufReadCmd, FileReadCmd, + FileWriteCmd) + * ***netrw*** prepended to various error messages + netrw may emit + * g:netrw_port used instead of b:netrw_port for scp + * any leading [:#] is removed from port numbers + v53: * backslashes as well as slashes placed in various + patterns (ex. g:netrw_sort_sequence) to better + support Windows + v52: * nonumber'ing now set for browsing buffers + * when the hiding list hid all files, error messages + ensued. Fixed + * when browsing, swf is set, but directory is not + set, when netrw was attempting to restore options, + vim wanted to save a swapfile to a local directory + using an url-style path. Fixed + v51: * cygwin detection now automated + (using windows and &shell is bash) + * customizable browser "file" rejection patterns + * directory history + * :[range]w url now supported (ie. netrw uses a + FileWriteCmd event) + * error messages have a "Press to continue" to + allow them to be seen + * directory browser displays no longer bother the + swapfile + * u/U commands to go up and down the history stack + * history stack may be saved with viminfo with it's + "!" option + * bugfixes associated with unwanted [No Files] + entries + v50: * directories now displayed using buftype=nofile; + should keep the directory names as-is + * attempts to remove empty "[No File]" buffers + leftover from :file ..name.. commands + * bugfix: a "caps-lock" editing difficulty left in + v49 was fixed + * syntax highlighting for "Showing:" the hiding list + included + * bookmarks can now be retained if "!" is in the + viminfo option + v49: * will use ftp for http://.../ browsing + v48: * One may use ftp to do remote host file browsing + * (windows and !cygwin) remote browsing with ftp can + now use the "dir" command internally to provide + listings + * g:netrw_keepdir now allows one to keep the initial + current directory as the current directory + (normally the local file browser makes the + currently viewed directory the current directory) + * g:netrw_alto and g:netrw_altv now support + alternate placement of windows started with o or v + * Nread ? and Nwrite ? now uses echomsg (instead of + echo) so :messages can repeat showing the help + * bugfix: avoids problems with partial matches of + directory names to prior buffers with longer names + * one can suppress error messages with g:netrw_quiet + ctrl-h used + * instead of h for editing hiding list one + may edit the sorting sequence with the S map, which + now allows confirmation of deletion with + [y(es) n(o) a(ll) q(uit)] + * the "x" map now handles special file viewing with: + (windows) rundll32 url.dll (gnome) gnome-open (kde) + kfmclient If none of these are on the executable + path, then netrwFileHandlers.vim is used. + * directory bookmarking during both local and remote + browsing implemented + * one may view all, use the hiding list to suppress, + or use the hiding list to show-only remote and + local file/directory listings + * improved unusual file and directory name handling + preview window support + v47: * now handles local browsing. + v46: * now handles remote browsing + * g:netrw_silent (if 1) will cause all transfers to + be silent + v45: * made the [user@]hostname:path form a bit more + restrictive to better handle errors in using + protocols (e.g. scp:usr@host:file was being + recognized as an rcp request) + v44: * changed from "rsync -a" to just "rsync" + * somehow an editing error messed up the test to + recognize use of the fetch method for NetRead. + * more debugging statements included + v43: * moved "Explanation" comments to help + file as "Network Reference" (|netrw-ref|) + * now uses Dfunc() Decho() and Dret() for + debugging + * removed superfluous NetRestorePosn() calls + v42: * now does BufReadPre and BufReadPost events on + file:///* and file://localhost/* + v41: * installed file:///* and file://localhost/* handling + v40: * prevents redraw when a protocol error occurs so + that the user may see it + v39: * sftp support + v38: * Now uses NetRestorePosn() calls with Nread/Nwrite + commands + * Temporary files now removed via bwipe! instead of + bwipe (thanks to Dave Roberts) + v37: * Claar's modifications which test if ftp is + successful, otherwise give an error message + * After a read, the alternate file was pointing to + the temp file. The temp file buffer is now wiped + out. + * removed silent from transfer methods so user can + see what's happening ============================================================================== @@ -2157,4 +2615,5 @@ which is loaded automatically at startup (assuming :set nocp). operation ============================================================================== +Modelines: {{{1 vim:tw=78:ts=8:ft=help:norl:fdm=marker diff --git a/vimfiles/doc/tComment.txt b/vimfiles/doc/tComment.txt index ecce643..89542d7 100644 --- a/vimfiles/doc/tComment.txt +++ b/vimfiles/doc/tComment.txt @@ -1,37 +1,65 @@ *tComment.txt* tComment -- An easily extensible & universal comment plugin -Author: Thomas Link, samul AT web.de +Author: Thomas Link, micathom AT gmail com?subject=vim -tComment provides easy to use, file type sensible comments for Vim. It +tComment provides easy to use, file-type sensible comments for Vim. It can handle embedded syntax. *tComment-Installation* Installation~ -Copy the file tComment.vim to your plugin directory (~/.vim/plugins/ or -similar). See |standard-plugin| for further details. +Edit the vba file and type: + + :so % + +See :help vimball for details. If you use vim 7.0, you may need to +update your vimball installation first. - *tComment-uninstall* -In case you have some bash or similar, you can feed the file -etc/tComment.lst to rm: > - - cd $HOME/.vim/ - rm -i `cat etc/tComment.lst` *tComment-Usage* Usage~ -The command TComment is bound to by default. TComment works -like a toggle, i.e., it will comment out text that contains uncommented -lines, and it will remove comment markup for already commented text -(i.e. text that contains no uncommented lines). +TComment works like a toggle, i.e., it will comment out text that +contains uncommented lines, and it will remove comment markup for +already commented text (i.e. text that contains no uncommented lines). + +If the file-type is properly defined, TComment will figure out which +comment string to use. Otherwise you use |TCommentDefineType()| to +override the default choice. + +TComment can properly handle an embedded syntax, e.g., ruby/python/perl +regions in vim scripts, HTML or JavaScript in php code etc. + *tComment-Key-Bindings* Key bindings~ +Most of the time the default toggle keys will do what you want (or to be +more precise: what I think it should to ;-). + + *g:tcommentMapLeaderOp1* + *g:tcommentMapLeaderOp2* +As operator (the prefix can be customized via g:tcommentMapLeaderOp1 +and g:tcommentMapLeaderOp2): + + gc{motion} :: Toggle comments (for small comments within one line + the &filetype_inline style will be used, if + defined) + gcc :: Toggle comment for the current line + gC{motion} :: Comment region + gCc :: Comment the current line + + *g:tcommentOpModeExtra* +By default the cursor stays put. If you want the cursor to the end of +the commented text, set g:tcommentOpModeExtra to '>' (but this may not +work properly with exclusive motions). + +Primary key maps: + :: :TComment :: :TComment b :: :TCommentBlock a :: :TCommentAs + n :: :TCommentAs &filetype s :: :TCommentAs &filetype_ i :: :TCommentInline r :: :TCommentRight @@ -46,6 +74,7 @@ A secondary set of key maps is defined for normal mode. _r :: :TCommentRight _b :: :TCommentBlock _a :: :TCommentAs + _n :: :TCommentAs &filetype _s :: :TCommentAs &filetype_ Keymaps are configurable via the following variables: @@ -96,7 +125,7 @@ Alternatively, you can type (? meaning "optional argument"): :? TCommentRight! NOTE: This command comments out the text to the right of the cursor. If a visual selection was made (be it block-wise or not), all lines - are commented out at from the current cursor positon downwards. + are commented out at from the current cursor position downwards. The bang (!) variants always comment out the selected text and don't work as toggles. @@ -112,7 +141,7 @@ Alternatively, you can type (? meaning "optional argument"): 'commentstring'. If you want to define, e.g., a fancy block comment style for html - you could do something like: > + you put something like this into ~/.vim/after/plugin/tComment.vim:> call TCommentDefineType("html_fancy_block", "\n -- ") @@ -135,7 +164,7 @@ Goals~ - Handle embedded syntax like php+html or html+javaScript+css; you have to set g:tcommentGuessFileType_{&filetype} to 1 or to the - fallback file type in order to activate this feature for other file + fall-back file-type in order to activate this feature for other file types than php or html tComment deduces the correct file type from the syntax name, similar @@ -149,7 +178,7 @@ Goals~ buffer local &commentstring option (which can be set on a vim |modeline|) -- Use 'commentstring' or 'comments' as a fallback (i.e., if a filetype +- Use 'commentstring' or 'comments' as a fallback (i.e., if a file-type is properly defined, TComment will automatically support it) - Same short-cut for commenting text and for removing comment markup @@ -157,10 +186,10 @@ Goals~ - The decision whether text should be commented or uncommented is made on the basis of the whole selection (not line by line); comments in code that should be commented aren't uncommented as it is the case - with some other plugins + with some other plug-ins As of version 1.5, the following file types are explicitly defined -(other filetypes are most likely supported through the 'commentstring' +(other file-types are most likely supported through the 'commentstring' or 'comments' variables): ada, apache, autoit, catalog, cpp, css, c, cfg, conf, desktop, diff --git a/vimfiles/doc/tags b/vimfiles/doc/tags index 1bd651f..584a59a 100644 --- a/vimfiles/doc/tags +++ b/vimfiles/doc/tags @@ -8,6 +8,7 @@ :MkVimball pi_vimball.txt /*:MkVimball* :Nexplore pi_netrw.txt /*:Nexplore* :Pexplore pi_netrw.txt /*:Pexplore* +:Rexplore pi_netrw.txt /*:Rexplore* :RmVimball pi_vimball.txt /*:RmVimball* :Sexplore pi_netrw.txt /*:Sexplore* :TComment tComment.txt /*:TComment* @@ -1283,8 +1284,10 @@ g:netrw_alto pi_netrw.txt /*g:netrw_alto* g:netrw_altv pi_netrw.txt /*g:netrw_altv* g:netrw_browse_split pi_netrw.txt /*g:netrw_browse_split* g:netrw_browsex_viewer pi_netrw.txt /*g:netrw_browsex_viewer* +g:netrw_compress pi_netrw.txt /*g:netrw_compress* g:netrw_cygwin pi_netrw.txt /*g:netrw_cygwin* g:netrw_dav_cmd pi_netrw.txt /*g:netrw_dav_cmd* +g:netrw_decompress pi_netrw.txt /*g:netrw_decompress* g:netrw_extracmd pi_netrw.txt /*g:netrw_extracmd* g:netrw_fastbrowse pi_netrw.txt /*g:netrw_fastbrowse* g:netrw_fetch_cmd pi_netrw.txt /*g:netrw_fetch_cmd* @@ -1304,11 +1307,15 @@ g:netrw_list_hide pi_netrw.txt /*g:netrw_list_hide* g:netrw_liststyle pi_netrw.txt /*g:netrw_liststyle* g:netrw_local_mkdir pi_netrw.txt /*g:netrw_local_mkdir* g:netrw_local_rmdir pi_netrw.txt /*g:netrw_local_rmdir* +g:netrw_localcopycmd pi_netrw.txt /*g:netrw_localcopycmd* +g:netrw_localmovecmd pi_netrw.txt /*g:netrw_localmovecmd* 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_passwd pi_netrw.txt /*g:netrw_passwd* +g:netrw_preview pi_netrw.txt /*g:netrw_preview* g:netrw_rcp_cmd pi_netrw.txt /*g:netrw_rcp_cmd* g:netrw_rm_cmd pi_netrw.txt /*g:netrw_rm_cmd* g:netrw_rmdir_cmd pi_netrw.txt /*g:netrw_rmdir_cmd* @@ -1318,6 +1325,7 @@ g:netrw_scp_cmd pi_netrw.txt /*g:netrw_scp_cmd* g:netrw_scpport pi_netrw.txt /*g:netrw_scpport* g:netrw_sftp_cmd pi_netrw.txt /*g:netrw_sftp_cmd* g:netrw_shq pi_netrw.txt /*g:netrw_shq* +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* @@ -1333,6 +1341,9 @@ g:netrw_win95ftp pi_netrw.txt /*g:netrw_win95ftp* g:netrw_winsize pi_netrw.txt /*g:netrw_winsize* g:tcommentMapLeader1 tComment.txt /*g:tcommentMapLeader1* g:tcommentMapLeader2 tComment.txt /*g:tcommentMapLeader2* +g:tcommentMapLeaderOp1 tComment.txt /*g:tcommentMapLeaderOp1* +g:tcommentMapLeaderOp2 tComment.txt /*g:tcommentMapLeaderOp2* +g:tcommentOpModeExtra tComment.txt /*g:tcommentOpModeExtra* g:vimball_home pi_vimball.txt /*g:vimball_home* g:visincr_datedivset visincr.txt /*g:visincr_datedivset* getlatestvimscripts-install pi_getscript.txt /*getlatestvimscripts-install* @@ -1384,10 +1395,15 @@ netrw-bookmarks pi_netrw.txt /*netrw-bookmarks* netrw-browse pi_netrw.txt /*netrw-browse* netrw-browse-cmds pi_netrw.txt /*netrw-browse-cmds* netrw-browse-intro pi_netrw.txt /*netrw-browse-intro* -netrw-browse-var pi_netrw.txt /*netrw-browse-var* +netrw-browse-maps pi_netrw.txt /*netrw-browse-maps* +netrw-browser pi_netrw.txt /*netrw-browser* +netrw-browser-options pi_netrw.txt /*netrw-browser-options* +netrw-browser-var pi_netrw.txt /*netrw-browser-var* +netrw-browsing pi_netrw.txt /*netrw-browsing* netrw-c pi_netrw.txt /*netrw-c* netrw-cadaver pi_netrw.txt /*netrw-cadaver* netrw-chgup pi_netrw.txt /*netrw-chgup* +netrw-clean pi_netrw.txt /*netrw-clean* netrw-contents pi_netrw.txt /*netrw-contents* netrw-cr pi_netrw.txt /*netrw-cr* netrw-credits pi_netrw.txt /*netrw-credits* @@ -1425,10 +1441,21 @@ netrw-list pi_netrw.txt /*netrw-list* netrw-listbookmark pi_netrw.txt /*netrw-listbookmark* netrw-listhack pi_netrw.txt /*netrw-listhack* netrw-login pi_netrw.txt /*netrw-login* -netrw-maps pi_netrw.txt /*netrw-maps* +netrw-mT pi_netrw.txt /*netrw-mT* netrw-mb pi_netrw.txt /*netrw-mb* +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-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-mt pi_netrw.txt /*netrw-mt* +netrw-mu pi_netrw.txt /*netrw-mu* +netrw-mx pi_netrw.txt /*netrw-mx* +netrw-mz pi_netrw.txt /*netrw-mz* netrw-netrc pi_netrw.txt /*netrw-netrc* netrw-nexplore pi_netrw.txt /*netrw-nexplore* netrw-nread pi_netrw.txt /*netrw-nread* @@ -1437,6 +1464,8 @@ netrw-o pi_netrw.txt /*netrw-o* netrw-options pi_netrw.txt /*netrw-options* netrw-p pi_netrw.txt /*netrw-p* netrw-p1 pi_netrw.txt /*netrw-p1* +netrw-p10 pi_netrw.txt /*netrw-p10* +netrw-p11 pi_netrw.txt /*netrw-p11* netrw-p2 pi_netrw.txt /*netrw-p2* netrw-p3 pi_netrw.txt /*netrw-p3* netrw-p4 pi_netrw.txt /*netrw-p4* @@ -1462,12 +1491,14 @@ netrw-read pi_netrw.txt /*netrw-read* netrw-ref pi_netrw.txt /*netrw-ref* netrw-rename pi_netrw.txt /*netrw-rename* netrw-reverse pi_netrw.txt /*netrw-reverse* +netrw-rexplore pi_netrw.txt /*netrw-rexplore* netrw-s pi_netrw.txt /*netrw-s* netrw-settings pi_netrw.txt /*netrw-settings* netrw-sexplore pi_netrw.txt /*netrw-sexplore* 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-starpat pi_netrw.txt /*netrw-starpat* netrw-starstar pi_netrw.txt /*netrw-starstar* netrw-starstarpat pi_netrw.txt /*netrw-starstarpat* @@ -1505,7 +1536,6 @@ tComment-Installation tComment.txt /*tComment-Installation* tComment-Key-Bindings tComment.txt /*tComment-Key-Bindings* tComment-Usage tComment.txt /*tComment-Usage* tComment-commands tComment.txt /*tComment-commands* -tComment-uninstall tComment.txt /*tComment-uninstall* tComment.txt tComment.txt /*tComment.txt* vba pi_vimball.txt /*vba* vimball pi_vimball.txt /*vimball* diff --git a/vimfiles/plugin/blockdiff.vim b/vimfiles/plugin/blockdiff.vim new file mode 100644 index 0000000..9eaf7e5 --- /dev/null +++ b/vimfiles/plugin/blockdiff.vim @@ -0,0 +1,86 @@ +" Vim BlockDiff-Plugin +" +" Author: Timo Teifel +" Email: timo dot teifel at teifel dot net +" Version: 1.0 +" Date: 22 Oct 2007 +" Licence: GPL v2.0 +" +" Usage: +" - Select first block +" - Depending on the configuration, select: +" - Menu BlockDiff-> This\ is\ Block\ 1 +" - Popup-Menu -> This\ is\ Block\ 1 +" - ,d1 +" - select second block (may be in another file, but in the same +" Vim window) +" - Menu BlockDiff-> This\ is\ Block\ 2,\ start\ diff +" - Popup-Menu -> This\ is\ Block\ 2,\ start\ diff +" - ,d2 +" - Script opens a new tab, splits it and shows the diff between +" the two blocks. +" - Close the tab when done +" + +let s:save_cpo = &cpo +set cpo&vim + +" ---------- Configuration ---------------------------------------------------- +" uncomment one or more of these blocks: + + +" Create menu entry: + vmenu BlockDiff.This\ is\ block\ 1 :call BlockDiff_GetBlock1() + vmenu BlockDiff.This\ is\ block\ 2,\ start\ diff :call BlockDiff_GetBlock2() + + +" Create popup-menu-entry: + "vmenu PopUp.BlockDiff.This\ is\ block\ 1 :call BlockDiff_GetBlock1() + "vmenu PopUp.BlockDiff.This\ is\ block\ 2,\ start\ diff :call BlockDiff_GetBlock2() + +" Shortcuts + "vmap ,d1 :call BlockDiff_GetBlock1() + "vmap ,d2 :call BlockDiff_GetBlock2() + + + +" ---------- Code ------------------------------------------------------------- +fun! BlockDiff_GetBlock1() range + let s:regd = @@ + " copy selected block into unnamed register + exe a:firstline . "," . a:lastline . "y" + " save block for later use in variable + let s:block1 = @@ + " restore unnamed register + let @@ = s:regd +endfun + +fun! BlockDiff_GetBlock2() range + let s:regd = @@ + exe a:firstline . "," . a:lastline . "y" + + " Open new tab, paste second selected block + tabnew + normal p + " to prevent 'No write since last change' message: + se buftype=nowrite + diffthis + + " vsplit left for first selected block + lefta vnew + " copy first block into unnamed register & paste + let @@ = s:block1 + normal p + se buftype=nowrite + + " start diff + diffthis + + " restore unnamed register + let @@ = s:regd +endfun + + +let &cpo = s:save_cpo +unlet s:save_cpo + diff --git a/vimfiles/plugin/netrwPlugin.vim b/vimfiles/plugin/netrwPlugin.vim index 152eb32..c25aaa0 100644 --- a/vimfiles/plugin/netrwPlugin.vim +++ b/vimfiles/plugin/netrwPlugin.vim @@ -1,6 +1,6 @@ " netrwPlugin.vim: Handles file transfer and remote directory listing across a network " PLUGIN SECTION -" Date: Jan 05, 2007 +" Date: Aug 09, 2007 " Maintainer: Charles E Campbell, Jr " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{1 @@ -64,11 +64,10 @@ augroup Network augroup END " Commands: :Nread, :Nwrite, :NetUserPass {{{2 -com! -count=1 -nargs=* Nread call netrw#NetSavePosn()call netrw#NetRead(,)call netrw#NetRestorePosn() -com! -range=% -nargs=* Nwrite call netrw#NetSavePosn(),call netrw#NetWrite()call netrw#NetRestorePosn() +com! -count=1 -nargs=* Nread call netrw#NetrwSavePosn()call netrw#NetRead(,)call netrw#NetrwRestorePosn() +com! -range=% -nargs=* Nwrite call netrw#NetrwSavePosn(),call netrw#NetWrite()call netrw#NetrwRestorePosn() com! -nargs=* NetUserPass call NetUserPass() -com! -nargs=+ Ncopy call netrw#NetObtain() -com! -nargs=* Nsource call netrw#NetSavePosn()call netrw#NetSource()call netrw#NetRestorePosn() +com! -nargs=* Nsource call netrw#NetrwSavePosn()call netrw#NetSource()call netrw#NetrwRestorePosn() " Commands: :Explore, :Sexplore, Hexplore, Vexplore {{{2 com! -nargs=* -bar -bang -count=0 -complete=dir Explore call netrw#Explore(,0,0+0,) @@ -80,7 +79,8 @@ com! -nargs=* -bar -bang Nexplore call netrw#Explore(-1,0,0,) com! -nargs=* -bar -bang Pexplore call netrw#Explore(-2,0,0,) " Commands: NetrwSettings {{{2 -com! -nargs=0 NetrwSettings :call netrwSettings#NetrwSettings() +com! -nargs=0 NetrwSettings call netrwSettings#NetrwSettings() +com! -bang NetrwClean call netrw#NetrwClean(0) " Maps: if !exists("g:netrw_nogx") && maparg('g','n') == "" diff --git a/vimfiles/plugin/svndiff.vim b/vimfiles/plugin/svndiff.vim index 862be66..5563860 100644 --- a/vimfiles/plugin/svndiff.vim +++ b/vimfiles/plugin/svndiff.vim @@ -1,51 +1,59 @@ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" svndiff (C) 2007 Ico Doornekamp +" svndiff 2.0 (C) 2007 Ico Doornekamp " " Introduction " ------------ " -" NOTE: This plugin is linux-only! +" NOTE: This plugin is unix-only! " -" An experimental vim 7.0 plugin for showing svn diff information in a file -" while editing. This plugin runs a diff between the current buffer and the -" original subversion file, and applies highlighting to show where the buffer -" differs. The original text is not shown, only colors are used to indicate -" where changes were made. +" An small vim 7.0 plugin for showing svn diff information in a file while +" editing. This plugin runs a diff between the current buffer and the original +" subversion file, and shows coloured tags indicating where the buffer differs +" from the original file from the subversion repository. The original text is +" not shown, only signs are used to indicate where changes were made. " -" The following syntax highlight groups are used: +" The following symbols and syntax highlight groups are used for the tags: " -" DiffAdd: Newly added lines. (default=blue) +" > DiffAdd: Newly added lines. (default=blue) " -" DiffChange: Lines which are changed from the original. (default=cyan) -" -" DiffDel: Applied to the lines directly above and below a deleted -" block (default=magenta) +" ! DiffChange: Lines which are changed from the original. (default=cyan) " +" < DiffDel: Applied to the lines directly above and below a deleted block +" (default=magenta) " Usage " ----- " -" The plugin defines one function: Svndiff_show(). This function figures out -" the difference between the current file and it's subversion original, and -" creates the syntax highlighting patterns. You'll need to call this function -" after making changes to update the highlighting. +" The plugin defines one function: Svndiff(). This function figures out the +" difference between the current file and it's subversion original, and adds +" the tags at the places where the buffer differs from the original file from +" subversion. You'll need to call this function after making changes to update +" the highlighting. +" " " The function takes an optional argument specifying an additional action to " perform: " -" "prev": jump to the previous different block -" "next": jump to the next different block +" "prev" : jump to the previous different block +" "next" : jump to the next different block +" "clear" : clean up all tags " -" You might want to map some keys to run the Svndiff_show function. For example, -" add to your .vimrc: +" You might want to map some keys to run the Svndiff function. For +" example, add to your .vimrc: " -" noremap :call Svndiff_show("prev") -" noremap :call Svndiff_show("next") +" noremap :call Svndiff("prev") +" noremap :call Svndiff("next") +" noremap :call Svndiff("clear") " -" And optionally another keymap to cleanup the diff highlighting and revert to -" the original syntax: +" Colors +" ------ " -" noremap :syntax on +" Personally, I find the following colours more intuitive for diff colours: +" red=deleted, green=added, yellow=changed. If you want to use these colours, +" try adding the following lines to your .vimrc " +" hi DiffAdd ctermfg=0 ctermbg=2 guibg='green' +" hi DiffDelete ctermfg=0 ctermbg=1 guibg='red' +" hi DiffChange ctermfg=0 ctermbg=3 guibg='yellow' " " Changelog " --------- @@ -56,10 +64,15 @@ " " 1.2 2007-06-14 Updated diff arguments from -u0 (obsolete) to -U0 " +" 2.0 2007-08-16 Changed from syntax highlighting to using tags, thanks +" to Noah Spurrier for the idea. NOTE: the name of the +" function changed from Svndiff_show() to Svndiff(), so +" you might need to update your .vimrc mappings! +" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -function! Svndiff_show(...) +function! Svndiff(...) let cmd = exists("a:1") ? a:1 : '' let fname = bufname("%") @@ -75,19 +88,32 @@ function! Svndiff_show(...) end - " Reset syntax highlighting + " Remove all signs. If the cmd is 'clear', return right away. NOTE: this + " command removes all signs from the file, also if they were not placed by + " the this plugin. If this bothers your, tell me and I'll fix it. + + sign unplace * + + if cmd == 'clear' + return + endif + + + " Define sign characters and colors - syntax off + sign define svnadd text=> texthl=diffAdd + sign define svndelete text=< texthl=diffDelete + sign define svnchange text=! texthl=diffChange - " Pipe the current buffer contents to a shell command calculating the diff - " in a friendly parsable format + " This is where the magic happens: pipe the current buffer contents to a + " shell command calculating the diff in a friendly parsable format. let contents = join(getbufline("%", 1, "$"), "\n") let diff = system("diff -U0 <(svn cat " . fname . ") <(cat;echo)", contents) - " Parse the output of the diff command and hightlight changed, added and + " Parse the output of the diff command and put signs at changed, added and " removed lines for line in split(diff, '\n') @@ -105,20 +131,25 @@ function! Svndiff_show(...) if old_count == 0 let from = new_from let to = new_from + new_count - 1 - let group = 'DiffAdd' + let name = 'svnadd' elseif new_count == 0 let from = new_from let to = new_from + 1 - let group = 'DiffDelete' + let name = 'svndelete' else let from = new_from let to = new_from + new_count - 1 - let group = 'DiffChange' + let name = 'svnchange' endif - " Set the actual syntax highlight + + " Add signs to mark the changed lines - exec 'syntax region ' . group . ' start=".*\%' . from . 'l" end=".*\%' . to . 'l"' + let line = from + while line <= to + exec 'sign place ' . from . ' line=' . line . ' name=' . name . ' file=' . fname + let line = line + 1 + endwhile " Check if we need to jump to prev/next diff block @@ -141,6 +172,9 @@ function! Svndiff_show(...) endfor + + " Set the cursor to the new position, if requested + if jump_to > 0 call setpos(".", [ 0, jump_to, 1, 0 ]) endif diff --git a/vimfiles/plugin/tComment.vim b/vimfiles/plugin/tComment.vim index c20b2c5..3810663 100644 --- a/vimfiles/plugin/tComment.vim +++ b/vimfiles/plugin/tComment.vim @@ -1,18 +1,18 @@ " tComment.vim -- An easily extensible & universal comment plugin -" @Author: Thomas Link (samul AT web.de) +" @Author: Thomas Link (micathom AT gmail com) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 27-Dez-2004. -" @Last Change: 2007-04-15. -" @Revision: 1.6.285 +" @Last Change: 2007-08-30. +" @Revision: 1.7.608 " " vimscript #1173 if &cp || exists('loaded_tcomment') finish endif -let loaded_tcomment = 106 +let loaded_tcomment = 107 -fun! s:DefVar(name, val) +function! s:DefVar(name, val) if !exists(a:name) " exec "let ". a:name ."='". a:val ."'" exec 'let '. a:name .'="'. escape(a:val, '"\') .'"' @@ -24,6 +24,10 @@ call s:DefVar('g:tcommentBlankLines', 1) call s:DefVar('g:tcommentMapLeader1', '') call s:DefVar('g:tcommentMapLeader2', '_') +" call s:DefVar('g:tcommentMapLeaderOp1', '-') +call s:DefVar('g:tcommentMapLeaderOp1', 'gc') +call s:DefVar('g:tcommentMapLeaderOp2', 'gC') +call s:DefVar('g:tcommentOpModeExtra', '') " Guess the file type based on syntax names always or for some fileformat only call s:DefVar('g:tcommentGuessFileType', 0) @@ -37,6 +41,16 @@ call s:DefVar('g:tcommentGuessFileType_vim', 1) call s:DefVar('g:tcommentIgnoreTypes_php', 'sql') +if !exists('g:tcommentSyntaxMap') "{{{2 + let g:tcommentSyntaxMap = { + \ 'vimMzSchemeRegion': 'scheme', + \ 'vimPerlRegion': 'perl', + \ 'vimPythonRegion': 'python', + \ 'vimRubyRegion': 'ruby', + \ 'vimTclRegion': 'tcl', + \ } +endif + " If you don't define these variables, TComment will use &commentstring " instead. We override the default values here in order to have a blank after " the comment marker. Block comments work only if we explicitly define the @@ -56,12 +70,12 @@ call s:DefVar('g:tcommentBlockXML', "\n ") call s:DefVar('g:tcommentInlineXML', "") " Currently this function just sets a variable -fun! TCommentDefineType(name, commentstring) +function! TCommentDefineType(name, commentstring) call s:DefVar('g:tcomment_'. a:name, a:commentstring) let s:tcommentFileTypesDirty = 1 endf -fun! TCommentTypeExists(name) +function! TCommentTypeExists(name) return exists('g:tcomment_'. a:name) endf @@ -110,6 +124,7 @@ call TCommentDefineType('java_inline', g:tcommentInlineC ) call TCommentDefineType('java_block', g:tcommentBlockC ) call TCommentDefineType('lisp', '; %s' ) call TCommentDefineType('m4', 'dnl %s' ) +call TCommentDefineType('mail', '> %s' ) call TCommentDefineType('nroff', '.\\" %s' ) call TCommentDefineType('objc', '/* %s */' ) call TCommentDefineType('objc_inline', g:tcommentInlineC ) @@ -144,6 +159,7 @@ call TCommentDefineType('sh', '# %s' ) call TCommentDefineType('sql', '-- %s' ) call TCommentDefineType('spec', '# %s' ) call TCommentDefineType('sps', '* %s.' ) +call TCommentDefineType('sps_block', '* %s.' ) call TCommentDefineType('tcl', '# %s' ) call TCommentDefineType('tex', '%% %s' ) call TCommentDefineType('tpl', '' ) @@ -151,6 +167,7 @@ call TCommentDefineType('viki', '%% %s' ) call TCommentDefineType('viki_3', '%%%%%% %s' ) call TCommentDefineType('viki_inline', '{cmt: %s}' ) call TCommentDefineType('vim', '" %s' ) +call TCommentDefineType('vim_3', '""" %s' ) call TCommentDefineType('websec', '# %s' ) call TCommentDefineType('xml', '' ) call TCommentDefineType('xml_inline', g:tcommentInlineXML) @@ -162,7 +179,7 @@ call TCommentDefineType('yaml', '# %s' ) let s:tcommentFileTypesDirty = 1 -fun! s:DefaultValue(option) +function! s:DefaultValue(option) exec 'let '. a:option .' = &'. a:option exec 'set '. a:option .'&' exec 'let default = &'. a:option @@ -180,22 +197,23 @@ let s:nullCommentString = '%s' " B ... block " I ... inline " R ... right -fun! TComment(beg, end, ...) +function! TComment(beg, end, ...) " save the cursor position let co = col('.') let li = line('.') + let s:pos_end = getpos("'>") let commentMode = a:0 >= 1 ? a:1 : 'G' let commentAnyway = a:0 >= 2 ? (a:2 == '!') : 0 - if commentMode ==# 'IG' - let commentMode = line("'<") == line("'>") ? 'I' : 'G' + if commentMode =~# 'i' + let commentMode = substitute(commentMode, '\Ci', line("'<") == line("'>") ? 'I' : 'G', 'g') endif - if commentMode ==# 'R' || commentMode ==# 'I' + if commentMode =~# 'R' || commentMode =~# 'I' let cstart = col("'<") if cstart == 0 let cstart = col('.') endif - if commentMode ==# 'R' - let commentMode = 'G' + if commentMode =~# 'R' + let commentMode = substitute(commentMode, '\CR', 'G', 'g') let cend = 0 else let cend = col("'>") @@ -204,6 +222,7 @@ fun! TComment(beg, end, ...) let cstart = 0 let cend = 0 endif + " TLogVAR commentMode, cstart, cend " get the correct commentstring if a:0 >= 3 && a:3 != '' let cms = s:EncodeCommentPart(a:3) .'%s' @@ -211,7 +230,7 @@ fun! TComment(beg, end, ...) let cms = cms . s:EncodeCommentPart(a:4) endif else - exec s:GetCommentString(a:beg, a:end, commentMode) + let [cms, commentMode] = s:GetCommentString(a:beg, a:end, commentMode) endif let cms0 = s:BlockGetCommentString(cms) let cms0 = escape(cms0, '\') @@ -221,14 +240,15 @@ fun! TComment(beg, end, ...) " turn commentstring into a search pattern let cmtCheck = s:SPrintF(cmtCheck, '\(\_.\{-}\)') " set commentMode and indentStr - exec s:CommentDef(a:beg, a:end, cmtCheck, commentMode, cstart, cend) + let [indentStr, uncomment] = s:CommentDef(a:beg, a:end, cmtCheck, commentMode, cstart, cend) + " TLogVAR indentStr, uncomment if commentAnyway - let mode = 0 + let uncomment = 0 endif " go - if commentMode ==# 'B' + if commentMode =~# 'B' " We want a comment block - call s:CommentBlock(a:beg, a:end, mode, cmtCheck, cms, indentStr) + call s:CommentBlock(a:beg, a:end, uncomment, cmtCheck, cms, indentStr) else " We want commented lines " final search pattern for uncommenting @@ -237,11 +257,16 @@ fun! TComment(beg, end, ...) let cmtReplace = escape(cms0, '"/') silent exec a:beg .','. a:end .'s/\V'. \ s:StartRx(cstart) . indentStr .'\zs\(\.\*\)'. s:EndRx(cend) .'/'. - \ '\=s:ProcessedLine('. mode .', submatch(0), "'. cmtCheck .'", "'. cmtReplace .'")/ge' + \ '\=s:ProcessedLine('. uncomment .', submatch(0), "'. cmtCheck .'", "'. cmtReplace .'")/ge' endif " reposition cursor - " silent exec 'norm! '. li .'G'. co .'|' - call cursor(li, co) + " TLogVAR commentMode + if commentMode =~ '>' + call setpos('.', s:pos_end) + else + " TLogVAR li, co + call cursor(li, co) + endif endf " :line1,line2 TComment ?commentBegin ?commentEnd @@ -257,10 +282,68 @@ command! -bang -range -nargs=* TCommentBlock keepjumps call TComment(, , , 'I', "", ) " :line1,line2 TCommentMaybeInline ?commentBegin ?commentEnd -command! -bang -range -nargs=* TCommentMaybeInline keepjumps call TComment(, , 'IG', "", ) +command! -bang -range -nargs=* TCommentMaybeInline keepjumps call TComment(, , 'i', "", ) + + +function! TCommentOperator(type, ...) "{{{3 + let commentMode = a:0 >= 1 ? a:1 : '' + let bang = a:0 >= 2 ? a:2 : '' + let sel_save = &selection + let &selection = "inclusive" + let reg_save = @@ + " let pos = getpos('.') + " TLogVAR a:type + try + if a:type == 'line' + silent exe "normal! '[V']" + let commentMode1 = 'G' + elseif a:type == 'block' + silent exe "normal! `[\`]" + let commentMode1 = 'I' + else + silent exe "normal! `[v`]" + let commentMode1 = 'i' + endif + if empty(commentMode) + let commentMode = commentMode1 + endif + let beg = line("'[") + let end = line("']") + norm!  + let commentMode .= g:tcommentOpModeExtra + call TComment(beg, end, commentMode, bang) + finally + let &selection = sel_save + let @@ = reg_save + if g:tcommentOpModeExtra !~ '>' + " TLogVAR pos + " call setpos('.', pos) + call setpos('.', w:tcommentPos) + unlet! w:tcommentPos + endif + endtry +endf + + +function! TCommentOperatorLine(type) "{{{3 + call TCommentOperator(a:type, 'G') +endf + + +function! TCommentOperatorAnyway(type) "{{{3 + call TCommentOperator(a:type, '', '!') +endf + + +function! TCommentOperatorLineAnyway(type) "{{{3 + call TCommentOperator(a:type, 'G', '!') +endf + " comment text as if it were of a specific filetype -fun! TCommentAs(beg, end, commentAnyway, filetype) +function! TCommentAs(beg, end, commentAnyway, filetype, ...) + let ccount = a:0 >= 1 ? a:1 : 1 + " TLogVAR ccount if a:filetype =~ '_block$' let commentMode = 'B' let ft = substitute(a:filetype, '_block$', '', '') @@ -271,23 +354,36 @@ fun! TCommentAs(beg, end, commentAnyway, filetype) let commentMode = 'G' let ft = a:filetype endif - exec s:GetCommentString(a:beg, a:end, commentMode, ft) - let pre = substitute(cms, '%s.*$', '', '') + let [cms, commentMode] = s:GetCommentString(a:beg, a:end, commentMode, ft) + let pre = substitute(cms, '%s.*$', '', '') let pre = substitute(pre, '%%', '%', 'g') let post = substitute(cms, '^.\{-}%s', '', '') let post = substitute(post, '%%', '%', 'g') - call TComment(a:beg, a:end, commentMode, a:commentAnyway, pre, post) + if ccount > 1 + let pre_l = matchlist(pre, '^\(\S\+\)\(.*\)$') + " TLogVAR pre_l + if !empty(get(pre_l, 1)) + let pre = repeat(pre_l[1], ccount) . pre_l[2] + endif + let post_l = matchlist(post, '^\(\s*\)\(.\+\)$') + " TLogVAR post_l + if !empty(get(post_l, 2)) + let post = post_l[1] . repeat(post_l[2], ccount) + endif + endif + keepjumps call TComment(a:beg, a:end, commentMode, a:commentAnyway, pre, post) endf " :line1,line2 TCommentAs commenttype -command! -bang -complete=custom,TCommentFileTypes -range -nargs=1 TCommentAs +command! -bang -complete=custom,TCommentFileTypes -range -nargs=+ TCommentAs \ call TCommentAs(, , "", ) if (g:tcommentMapLeader1 != '') exec 'noremap '. g:tcommentMapLeader1 .' :TComment' exec 'vnoremap '. g:tcommentMapLeader1 .' :TCommentMaybeInline' exec 'inoremap '. g:tcommentMapLeader1 .' :TComment' - exec 'noremap '. g:tcommentMapLeader1 .'p vip:TComment' + exec 'noremap '. g:tcommentMapLeader1 .'p m`vip:TComment``' + exec 'inoremap '. g:tcommentMapLeader1 .'p :norm! m`vip:TComment``' exec 'noremap '. g:tcommentMapLeader1 .' :TComment ' exec 'inoremap '. g:tcommentMapLeader1 .' :TComment ' exec 'inoremap '. g:tcommentMapLeader1 .'r :TCommentRight' @@ -298,6 +394,8 @@ if (g:tcommentMapLeader1 != '') exec 'inoremap '. g:tcommentMapLeader1 .'b :TCommentBlock' exec 'noremap '. g:tcommentMapLeader1 .'a :TCommentAs ' exec 'inoremap '. g:tcommentMapLeader1 .'a :TCommentAs ' + exec 'noremap '. g:tcommentMapLeader1 .'n :TCommentAs =&ft ' + exec 'inoremap '. g:tcommentMapLeader1 .'n :TCommentAs =&ft ' exec 'noremap '. g:tcommentMapLeader1 .'s :TCommentAs =&ft_' exec 'inoremap '. g:tcommentMapLeader1 .'s :TCommentAs =&ft_' endif @@ -311,13 +409,22 @@ if (g:tcommentMapLeader2 != '') exec 'vnoremap '. g:tcommentMapLeader2 .'r :TCommentRight' exec 'noremap '. g:tcommentMapLeader2 .'b :TCommentBlock' exec 'noremap '. g:tcommentMapLeader2 .'a :TCommentAs ' + exec 'noremap '. g:tcommentMapLeader2 .'n :TCommentAs =&ft ' exec 'noremap '. g:tcommentMapLeader2 .'s :TCommentAs =&ft_' endif +if (g:tcommentMapLeaderOp1 != '') + exec 'noremap '. g:tcommentMapLeaderOp1 .' :let w:tcommentPos = getpos(".") \| set opfunc=TCommentOperatorg@' + exec 'noremap '. g:tcommentMapLeaderOp1 .'c :let w:tcommentPos = getpos(".") \| set opfunc=TCommentOperatorLineg@$' +endif +if (g:tcommentMapLeaderOp2 != '') + exec 'noremap '. g:tcommentMapLeaderOp2 .' :let w:tcommentPos = getpos(".") \| set opfunc=TCommentOperatorAnywayg@' + exec 'noremap '. g:tcommentMapLeaderOp2 .'c :let w:tcommentPos = getpos(".") \| set opfunc=TCommentOperatorLineAnywayg@$' +endif " ---------------------------------------------------------------- " collect all variables matching ^tcomment_ -fun! TCommentCollectFileTypes() +function! TCommentCollectFileTypes() if s:tcommentFileTypesDirty let t = @t try @@ -338,7 +445,7 @@ endf call TCommentCollectFileTypes() " return a list of filetypes for which a tcomment_{&ft} is defined -fun! TCommentFileTypes(ArgLead, CmdLine, CursorPos) +function! TCommentFileTypes(ArgLead, CmdLine, CursorPos) call TCommentCollectFileTypes() if a:ArgLead == '' return &filetype ."\n". g:tcommentFileTypes @@ -347,16 +454,15 @@ fun! TCommentFileTypes(ArgLead, CmdLine, CursorPos) endif endf -fun! s:EncodeCommentPart(string) +function! s:EncodeCommentPart(string) return substitute(a:string, '%', '%%', 'g') endf " s:GetCommentString(beg, end, commentMode, ?filetype="") -" => RecordCMS -fun! s:GetCommentString(beg, end, commentMode, ...) +function! s:GetCommentString(beg, end, commentMode, ...) let ft = a:0 >= 1 ? a:1 : '' if ft != '' - exec s:GetCustomCommentString(ft, a:commentMode) + let [cms, commentMode] = s:GetCustomCommentString(ft, a:commentMode) else let cms = '' let commentMode = a:commentMode @@ -383,12 +489,12 @@ fun! s:GetCommentString(beg, end, commentMode, ...) return s:GetCustomCommentString(&filetype, a:commentMode, s:GuessCurrentCommentString(a:commentMode)) endif endif - return s:RecordCMS(cms, commentMode) + return [cms, commentMode] endf " s:SPrintF(formatstring, ?values ...) " => string -fun! s:SPrintF(string, ...) +function! s:SPrintF(string, ...) let n = 1 let r = '' let s = a:string @@ -421,7 +527,7 @@ fun! s:SPrintF(string, ...) endwh endf -fun! s:StartRx(pos) +function! s:StartRx(pos) if a:pos == 0 return '\^' else @@ -429,7 +535,7 @@ fun! s:StartRx(pos) endif endf -fun! s:EndRx(pos) +function! s:EndRx(pos) if a:pos == 0 return '\$' else @@ -437,18 +543,18 @@ fun! s:EndRx(pos) endif endf -fun! s:GetIndentString(line, start) +function! s:GetIndentString(line, start) let start = a:start > 0 ? a:start - 1 : 0 return substitute(strpart(getline(a:line), start), '\V\^\s\*\zs\.\*\$', '', '') endf -fun! s:CommentDef(beg, end, checkRx, commentMode, cstart, cend) +function! s:CommentDef(beg, end, checkRx, commentMode, cstart, cend) let mdrx = '\V'. s:StartRx(a:cstart) .'\s\*'. a:checkRx .'\s\*'. s:EndRx(0) let line = getline(a:beg) if a:cstart != 0 && a:cend != 0 let line = strpart(line, 0, a:cend - 1) endif - let mode = (line =~ mdrx) + let uncomment = (line =~ mdrx) let it = s:GetIndentString(a:beg, a:cstart) let il = indent(a:beg) let n = a:beg + 1 @@ -459,50 +565,52 @@ fun! s:CommentDef(beg, end, checkRx, commentMode, cstart, cend) let it = s:GetIndentString(n, a:cstart) let il = jl endif - if a:commentMode ==# 'G' + if a:commentMode =~# 'G' if !(getline(n) =~ mdrx) - let mode = 0 + let uncomment = 0 endif endif endif let n = n + 1 endwh - if a:commentMode ==# 'B' + if a:commentMode =~# 'B' let t = @t try silent exec 'norm! '. a:beg.'G1|v'.a:end.'G$"ty' - let mode = (@t =~ mdrx) + let uncomment = (@t =~ mdrx) finally let @t = t endtry endif - return 'let indentStr="'. it .'" | let mode='. mode + return [it, uncomment] endf -fun! s:ProcessedLine(mode, match, checkRx, replace) +function! s:ProcessedLine(uncomment, match, checkRx, replace) if !(a:match =~ '\S' || g:tcommentBlankLines) return a:match endif - if a:mode - " uncomment + let ml = len(a:match) + if a:uncomment let rv = substitute(a:match, a:checkRx, '\1\2', '') else - " comment let rv = s:SPrintF(a:replace, a:match) endif + " let md = len(rv) - ml + let s:pos_end = getpos('.') + let s:pos_end[2] += len(rv) + " TLogVAR pe, md, a:match let rv = escape(rv, '\ ') let rv = substitute(rv, '\n', '\\\n', 'g') return rv endf -fun! s:CommentBlock(beg, end, mode, checkRx, replace, indentStr) +function! s:CommentBlock(beg, end, uncomment, checkRx, replace, indentStr) let t = @t try silent exec 'norm! '. a:beg.'G1|v'.a:end.'G$"td' let ms = s:BlockGetMiddleString(a:replace) let mx = escape(ms, '\') - if a:mode - " uncomment + if a:uncomment let @t = substitute(@t, '\V\^\s\*'. a:checkRx .'\$', '\1', '') if ms != '' let @t = substitute(@t, '\V\n'. a:indentStr . mx, '\n'. a:indentStr, 'g') @@ -510,7 +618,6 @@ fun! s:CommentBlock(beg, end, mode, checkRx, replace, indentStr) let @t = substitute(@t, '^\n', '', '') let @t = substitute(@t, '\n\s*$', '', '') else - " comment let cs = s:BlockGetCommentString(a:replace) let cs = a:indentStr . substitute(cs, '%s', '%s'. a:indentStr, '') if ms != '' @@ -530,15 +637,14 @@ endf " inspired by Meikel Brandmeyer's EnhancedCommentify.vim " this requires that a syntax names are prefixed by the filetype name " s:GuessFileType(beg, end, commentMode, filetype, ?fallbackFiletype) -" => RecordCMS -fun! s:GuessFileType(beg, end, commentMode, filetype, ...) +function! s:GuessFileType(beg, end, commentMode, filetype, ...) if a:0 >= 1 && a:1 != '' - exec s:GetCustomCommentString(a:1, a:commentMode) + let [cms, commentMode] = s:GetCustomCommentString(a:1, a:commentMode) if cms == '' let cms = s:GuessCurrentCommentString(a:commentMode) endif else - let commentMode = 'G' + let commentMode = s:CommentMode(a:commentMode, 'G') let cms = s:GuessCurrentCommentString(0) endif let n = a:beg @@ -547,7 +653,10 @@ fun! s:GuessFileType(beg, end, commentMode, filetype, ...) let le = col('$') while m < le let syntaxName = synIDattr(synID(n, m, 1), 'name') - if syntaxName =~ g:tcommentFileTypesRx + let ftypeMap = get(g:tcommentSyntaxMap, syntaxName) + if !empty(ftypeMap) + return s:GetCustomCommentString(ftypeMap, a:commentMode, cms) + elseif syntaxName =~ g:tcommentFileTypesRx let ft = substitute(syntaxName, g:tcommentFileTypesRx, '\1', '') if exists('g:tcommentIgnoreTypes_'. a:filetype) && g:tcommentIgnoreTypes_{a:filetype} =~ '\<'.ft.'\>' let m = m + 1 @@ -562,10 +671,14 @@ fun! s:GuessFileType(beg, end, commentMode, filetype, ...) endwh let n = n + 1 endwh - return s:RecordCMS(cms, commentMode) + return [cms, commentMode] endf -fun! s:GuessCurrentCommentString(commentMode) +function! s:CommentMode(commentMode, newmode) "{{{3 + return substitute(a:commentMode, '\w\+', a:newmode, 'g') +endf + +function! s:GuessCurrentCommentString(commentMode) let valid_cms = (stridx(&commentstring, '%s') != -1) if &commentstring != s:defaultCommentString && valid_cms " The &commentstring appears to have been set and to be valid @@ -589,9 +702,9 @@ fun! s:GuessCurrentCommentString(commentMode) endif endf -fun! s:ConstructFromComments(commentMode) +function! s:ConstructFromComments(commentMode) exec s:ExtractCommentsPart('') - if a:commentMode == 'G' && line != '' + if a:commentMode =~# 'G' && line != '' return line .' %s' endif exec s:ExtractCommentsPart('s') @@ -614,7 +727,7 @@ fun! s:ConstructFromComments(commentMode) endif endf -fun! s:ExtractCommentsPart(key) +function! s:ExtractCommentsPart(key) " let key = a:key != "" ? a:key .'[^:]*' : "" let key = a:key . '[bnflrxO0-9-]*' let val = substitute(&comments, '^\(.\{-},\)\{-}'. key .':\([^,]\+\).*$', '\2', '') @@ -628,36 +741,31 @@ fun! s:ExtractCommentsPart(key) endf " s:GetCustomCommentString(ft, commentMode, ?default="") -" => RecordCMS -fun! s:GetCustomCommentString(ft, commentMode, ...) +function! s:GetCustomCommentString(ft, commentMode, ...) let commentMode = a:commentMode let customComment = exists('g:tcomment_'. a:ft) - if commentMode ==# 'B' && exists('g:tcomment_'. a:ft .'_block') + if commentMode =~# 'B' && exists('g:tcomment_'. a:ft .'_block') let cms = g:tcomment_{a:ft}_block - elseif commentMode ==# 'I' && exists('g:tcomment_'. a:ft .'_inline') + elseif commentMode =~? 'I' && exists('g:tcomment_'. a:ft .'_inline') let cms = g:tcomment_{a:ft}_inline elseif customComment let cms = g:tcomment_{a:ft} - let commentMode = 'G' + let commentMode = s:CommentMode(commentMode, 'G') elseif a:0 >= 1 let cms = a:1 - let commentMode = 'G' + let commentMode = s:CommentMode(commentMode, 'G') else let cms = '' - let commentMode = 'G' + let commentMode = s:CommentMode(commentMode, 'G') endif - return s:RecordCMS(cms, commentMode) + return [cms, commentMode] endf -fun! s:RecordCMS(cms, commentMode) - return 'let cms="'. escape(a:cms, '"') .'" | let commentMode="'. a:commentMode .'"' -endf - -fun! s:BlockGetCommentString(cms) +function! s:BlockGetCommentString(cms) return substitute(a:cms, '\n.*$', '', '') endf -fun! s:BlockGetMiddleString(cms) +function! s:BlockGetMiddleString(cms) let rv = substitute(a:cms, '^.\{-}\n\([^\n]*\)', '\1', '') return rv == a:cms ? '' : rv endf @@ -724,3 +832,18 @@ code you have to use TCommentAs - Made key maps configurable via g:tcommentMapLeader1 and g:tcommentMapLeader2 +1.7 +- gc{motion} (see g:tcommentMapLeaderOp1) functions as a comment toggle +operator (i.e., something like gcl... works, mostly); gC{motion} (see +g:tcommentMapLeaderOp2) will unconditionally comment the text. +- TCommentAs takes an optional second argument (the comment level) +- New "n" map: TCommentAs &filetype [COUNT] +- Defined mail comments/citations +- g:tcommentSyntaxMap: Map syntax names to filetypes for buffers with +mixed syntax groups that don't match the filetypeEmbeddedsyntax scheme (e.g. +'vimRubyRegion', which should be commented as ruby syntax, not as vim +syntax) +- FIX: Comments in vim*Region +- TComment: The use of the type argument has slightly changed (IG -> i, +new: >) + diff --git a/vimfiles/plugin/vgrepsup.vim b/vimfiles/plugin/vgrepsup.vim new file mode 100644 index 0000000..42e230d --- /dev/null +++ b/vimfiles/plugin/vgrepsup.vim @@ -0,0 +1,76 @@ +" Author: Michael Geddes ( vimmer at frog.wheelycreek.net ) +" +" Created for zimnyx on IRC +" Version:0.2 +" +" Do a global search replace on a directory. +" +" +" Copyright: Copyright me. Feel free to use, share, modify & distribute the +" script but acknowledge me please. +" +" vim: ts=2 sw=2 et +fun! GlobSearchReplace( fileglob, sub, rep, flag) + let v:errmsg='' + exe 'vimgrep /'.escape(a:sub,'/').'/ '.a:fileglob + if v:errmsg != '' | return 0 | endif + let countup=0 + let more=1 + while 1 + silent exe 's/'.escape(a:sub, '/').'/'.escape(a:rep,'/').'/'.a:flag + let countup+=1 + try + silent cnext + catch + if v:exception !~ 'E553:' | echoerr v:exception | endif + break + endtry + endwhile + return countup +endfun +fun! s:CallGlobReplace(str) + if strlen(a:str) == 0 + echoerr 'Usage: /sub/rep/flags files' + return 0 + endif + let firstch= a:str[0] + let argidx=0 + let arg0='' + let arg1='' + let argflags='' + let argfileglob='' + let idx=1 + let str=a:str + while idx < strlen(str) + let ch=str[idx] + if ch=='\' && idx+1 < strlen(str) && str[idx+1] == firstch + let str=str[0:idx].str[idx+1:] + elseif ch==firstch + let arg{argidx}=str[1:idx-1] + let argidx+=1 + let str=str[idx : ] + let idx=0 + if argidx==2 + break + endif + endif + let idx+=1 + endwhile + if argidx == 2 + echo ' argidx=2' + let idx+=1 + while idx < strlen(str) + if str[idx]=~'\s' + let idx+=1 + break + endif + let argflags=argflags.str[idx] + let idx+=1 + endwhile + let argfileglob=str[idx : ] + endif + call GlobSearchReplace( argfileglob, arg0, arg1, argflags) +endfun + +com! -nargs=1 Gsub :call s:CallGlobReplace() + diff --git a/vimfiles/syntax/netrw.vim b/vimfiles/syntax/netrw.vim index 6415c46..87a55e6 100644 --- a/vimfiles/syntax/netrw.vim +++ b/vimfiles/syntax/netrw.vim @@ -1,71 +1,73 @@ -" Language : Netrw Remote-Directory Listing Syntax -" Maintainer : Charles E. Campbell, Jr. -" Last change: Nov 27, 2006 -" Version : 9 -" --------------------------------------------------------------------- - -" Syntax Clearing: {{{1 -if version < 600 - syntax clear -elseif exists("b:current_syntax") - finish -endif - -" --------------------------------------------------------------------- -" Directory List Syntax Highlighting: {{{1 -syn cluster NetrwGroup contains=netrwHide,netrwSortBy,netrwSortSeq,netrwQuickHelp,netrwVersion - -syn match netrwSpecial "\%(\S\+ \)*\S\+[*|=]\ze\%(\s\{2,}\|$\)" contains=netrwClassify -syn match netrwDir "\.\{1,2}/" contains=netrwClassify -syn match netrwDir "\%(\S\+ \)*\S\+/" contains=netrwClassify -syn match netrwDir "^\S*/" contains=netrwClassify -syn match netrwSizeDate "\<\d\+\s\d\{1,2}/\d\{1,2}/\d\{4}\s" contains=netrwDateSep skipwhite nextgroup=netrwTime -syn match netrwSymLink "\%(\S\+ \)*\S\+@\ze\%(\s\{2,}\|$\)" contains=netrwClassify -syn match netrwExe "\%(\S\+ \)*\S\+\*\ze\%(\s\{2,}\|$\)" contains=netrwClassify,netrwTreeIgnore -syn match netrwTreeIgnore contained "^\%(| \)*" - -syn match netrwClassify "[*=|@/]\ze\%(\s\{2,}\|$\)" contained -syn match netrwDateSep "/" contained -syn match netrwTime "\d\{1,2}:\d\{2}:\d\{2}" contained contains=netrwTimeSep -syn match netrwTimeSep ":" - -syn match netrwComment '".*\%(\t\|$\)' contains=@NetrwGroup -syn match netrwHide '^"\s*\(Hid\|Show\)ing:' skipwhite nextgroup=netrwHidePat -syn match netrwSlash "/" contained -syn match netrwHidePat "[^,]\+" contained skipwhite nextgroup=netrwHideSep -syn match netrwHideSep "," contained transparent skipwhite nextgroup=netrwHidePat -syn match netrwSortBy "Sorted by" contained transparent skipwhite nextgroup=netrwList -syn match netrwSortSeq "Sort sequence:" contained transparent skipwhite nextgroup=netrwList -syn match netrwList ".*$" contained contains=netrwComma -syn match netrwComma "," contained -syn region netrwQuickHelp matchgroup=Comment start="Quick Help:\s\+" end="$" contains=netrwHelpCmd keepend contained -syn match netrwHelpCmd "\S\ze:" contained skipwhite nextgroup=netrwCmdSep -syn match netrwCmdSep ":" contained nextgroup=netrwCmdNote -syn match netrwCmdNote ".\{-}\ze " contained -syn match netrwVersion "(netrw.*)" contained - -" --------------------------------------------------------------------- -" Highlighting Links: {{{1 -if !exists("did_drchip_dbg_syntax") - let did_drchip_netrwlist_syntax= 1 - hi link netrwClassify Function - hi link netrwCmdSep Delimiter - hi link netrwComment Comment - hi link netrwDir Directory - hi link netrwHelpCmd Function - hi link netrwHidePat Statement - hi link netrwList Statement - hi link netrwVersion Identifier - hi link netrwSymLink Special - hi link netrwExe PreProc - hi link netrwDateSep Delimiter - - hi link netrwTimeSep netrwDateSep - hi link netrwComma netrwComment - hi link netrwHide netrwComment -endif - -" Current Syntax: {{{1 -let b:current_syntax = "netrwlist" -" --------------------------------------------------------------------- -" vim: ts=8 fdm=marker +" Language : Netrw Remote-Directory Listing Syntax +" Maintainer : Charles E. Campbell, Jr. +" Last change: Aug 08, 2007 +" Version : 10 +" --------------------------------------------------------------------- + +" Syntax Clearing: {{{1 +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +" --------------------------------------------------------------------- +" Directory List Syntax Highlighting: {{{1 +syn cluster NetrwGroup contains=netrwHide,netrwSortBy,netrwSortSeq,netrwQuickHelp,netrwVersion,netrwCopyTgt + +syn match netrwSpecial "\%(\S\+ \)*\S\+[*|=]\ze\%(\s\{2,}\|$\)" contains=netrwClassify +syn match netrwDir "\.\{1,2}/" contains=netrwClassify +syn match netrwDir "\%(\S\+ \)*\S\+/" contains=netrwClassify +syn match netrwDir "^\S*/" contains=netrwClassify +syn match netrwSizeDate "\<\d\+\s\d\{1,2}/\d\{1,2}/\d\{4}\s" contains=netrwDateSep skipwhite nextgroup=netrwTime +syn match netrwSymLink "\%(\S\+ \)*\S\+@\ze\%(\s\{2,}\|$\)" contains=netrwClassify +syn match netrwExe "\%(\S\+ \)*\S\+\*\ze\%(\s\{2,}\|$\)" contains=netrwClassify,netrwTreeIgnore +syn match netrwTreeIgnore contained "^\%(| \)*" + +syn match netrwClassify "[*=|@/]\ze\%(\s\{2,}\|$\)" contained +syn match netrwDateSep "/" contained +syn match netrwTime "\d\{1,2}:\d\{2}:\d\{2}" contained contains=netrwTimeSep +syn match netrwTimeSep ":" + +syn match netrwComment '".*\%(\t\|$\)' contains=@NetrwGroup +syn match netrwHide '^"\s*\(Hid\|Show\)ing:' skipwhite nextgroup=netrwHidePat +syn match netrwSlash "/" contained +syn match netrwHidePat "[^,]\+" contained skipwhite nextgroup=netrwHideSep +syn match netrwHideSep "," contained transparent skipwhite nextgroup=netrwHidePat +syn match netrwSortBy "Sorted by" contained transparent skipwhite nextgroup=netrwList +syn match netrwSortSeq "Sort sequence:" contained transparent skipwhite nextgroup=netrwList +syn match netrwCopyTgt "Copy/Move Tgt:" contained transparent skipwhite nextgroup=netrwList +syn match netrwList ".*$" contained contains=netrwComma +syn match netrwComma "," contained +syn region netrwQuickHelp matchgroup=Comment start="Quick Help:\s\+" end="$" contains=netrwHelpCmd keepend contained +syn match netrwHelpCmd "\S\ze:" contained skipwhite nextgroup=netrwCmdSep +syn match netrwCmdSep ":" contained nextgroup=netrwCmdNote +syn match netrwCmdNote ".\{-}\ze " contained +syn match netrwVersion "(netrw.*)" contained + +" --------------------------------------------------------------------- +" Highlighting Links: {{{1 +if !exists("did_drchip_dbg_syntax") + let did_drchip_netrwlist_syntax= 1 + hi link netrwClassify Function + hi link netrwCmdSep Delimiter + hi link netrwComment Comment + hi link netrwDir Directory + hi link netrwHelpCmd Function + hi link netrwHidePat Statement + hi link netrwList Statement + hi link netrwVersion Identifier + hi link netrwSymLink Special + hi link netrwExe PreProc + hi link netrwDateSep Delimiter + + hi link netrwTimeSep netrwDateSep + hi link netrwComma netrwComment + hi link netrwHide netrwComment + hi link netrwMarkFile Identifier +endif + +" Current Syntax: {{{1 +let b:current_syntax = "netrwlist" +" --------------------------------------------------------------------- +" vim: ts=8 fdm=marker