" netrw.vim: Handles file transfer and remote directory listing across
" AUTOLOAD SECTION
-" Date: Apr 20, 2016
-" Version: 156
+" Date: Nov 03, 2017
+" Version: 162
" Maintainer: Charles E Campbell <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
" Copyright: Copyright (C) 2016 Charles E. Campbell {{{1
if &cp || exists("g:loaded_netrw")
finish
endif
-" netrw requires vim having patch 7.4.213; netrw will benefit from vim's having patch#656, too
-if v:version < 704 || (v:version == 704 && !has("patch213"))
- if !exists("s:needpatch213")
- unsilent echomsg "***sorry*** this version of netrw requires vim v7.4 with patch 213"
- endif
- let s:needpatch213= 1
- finish
+
+" Check that vim has patches that netrw requires.
+" Patches needed: 1557, and 213.
+" (netrw will benefit from vim's having patch#656, too)
+let s:needspatches=[1557,213]
+if exists("s:needspatches")
+ for ptch in s:needspatches
+ if v:version < 704 || (v:version == 704 && !has("patch".ptch))
+ if !exists("s:needpatch{ptch}")
+ unsilent echomsg "***sorry*** this version of netrw requires vim v7.4 with patch#".ptch
+ endif
+ let s:needpatch{ptch}= 1
+ finish
+ endif
+ endfor
endif
-let g:loaded_netrw = "v156"
+
+let g:loaded_netrw = "v162"
if !exists("s:NOTE")
let s:NOTE = 0
let s:WARNING = 1
" Usage: netrw#ErrorMsg(s:NOTE | s:WARNING | s:ERROR,"some message",error-number)
" netrw#ErrorMsg(s:NOTE | s:WARNING | s:ERROR,["message1","message2",...],error-number)
" (this function can optionally take a list of messages)
-" Jan 19, 2016 : max errnum currently is 103
+" Mar 21, 2017 : max errnum currently is 105
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)
call s:NetrwInit("s:MAXLIST" ,4)
endif
+" ---------------------------------------------------------------------
+" Default option values: {{{2
+let g:netrw_localcopycmdopt = ""
+let g:netrw_localcopydircmdopt = ""
+let g:netrw_localmkdiropt = ""
+let g:netrw_localmovecmdopt = ""
+let g:netrw_localrmdiropt = ""
+
" ---------------------------------------------------------------------
" Default values for netrw's global protocol variables {{{2
call s:NetrwInit("g:netrw_use_errorwindow",1)
let g:netrw_ftp_options= "-i -n"
endif
if !exists("g:netrw_http_cmd")
- if executable("elinks")
- let g:netrw_http_cmd = "elinks"
- call s:NetrwInit("g:netrw_http_xcmd","-source >")
- elseif executable("links")
- let g:netrw_http_cmd = "links"
- call s:NetrwInit("g:netrw_http_xcmd","-source >")
- elseif executable("curl")
+ if executable("curl")
let g:netrw_http_cmd = "curl"
- call s:NetrwInit("g:netrw_http_xcmd","-o")
+ call s:NetrwInit("g:netrw_http_xcmd","-L -o")
elseif executable("wget")
let g:netrw_http_cmd = "wget"
call s:NetrwInit("g:netrw_http_xcmd","-q -O")
+ elseif executable("elinks")
+ let g:netrw_http_cmd = "elinks"
+ call s:NetrwInit("g:netrw_http_xcmd","-source >")
elseif executable("fetch")
let g:netrw_http_cmd = "fetch"
call s:NetrwInit("g:netrw_http_xcmd","-o")
+ elseif executable("links")
+ let g:netrw_http_cmd = "links"
+ call s:NetrwInit("g:netrw_http_xcmd","-http.extra-header ".shellescape("Accept-Encoding: identity", 1)." -source >")
else
let g:netrw_http_cmd = ""
endif
call s:NetrwInit("g:netrw_keepj","keepj")
call s:NetrwInit("g:netrw_rcp_cmd" , "rcp")
call s:NetrwInit("g:netrw_rsync_cmd", "rsync")
+call s:NetrwInit("g:netrw_rsync_sep", "/")
if !exists("g:netrw_scp_cmd")
if executable("scp")
call s:NetrwInit("g:netrw_scp_cmd" , "scp -q")
if g:netrw_cygwin
let g:netrw_localcopycmd= "cp"
else
- let g:netrw_localcopycmd= expand("$COMSPEC")." /c copy"
+ let g:netrw_localcopycmd = expand("$COMSPEC")
+ let g:netrw_localcopycmdopt= " /c copy"
endif
elseif has("unix") || has("macunix")
let g:netrw_localcopycmd= "cp"
if !exists("g:netrw_localcopydircmd")
if has("win32") || has("win95") || has("win64") || has("win16")
if g:netrw_cygwin
- let g:netrw_localcopydircmd= "cp -R"
+ let g:netrw_localcopydircmd = "cp"
+ let g:netrw_localcopydircmdopt= " -R"
else
- let g:netrw_localcopycmd= expand("$COMSPEC")." /c xcopy /e /c /h /i /k"
- endif
- elseif has("unix") || has("macunix")
- let g:netrw_localcopydircmd= "cp -R"
+ let g:netrw_localcopydircmd = expand("$COMSPEC")
+ let g:netrw_localcopydircmdopt= " /c xcopy /e /c /h /i /k"
+ endif
+ elseif has("unix")
+ let g:netrw_localcopydircmd = "cp"
+ let g:netrw_localcopydircmdopt= " -R"
+ elseif has("macunix")
+ let g:netrw_localcopydircmd = "cp"
+ let g:netrw_localcopydircmdopt= " -R"
else
- let g:netrw_localcopycmd= ""
+ let g:netrw_localcopydircmd= ""
endif
endif
if exists("g:netrw_local_mkdir")
if g:netrw_cygwin
call s:NetrwInit("g:netrw_localmkdir","mkdir")
else
- let g:netrw_localmkdir= expand("$COMSPEC")." /c mkdir"
+ let g:netrw_localmkdir = expand("$COMSPEC")
+ let g:netrw_localmkdiropt= " /c mkdir"
endif
else
call s:NetrwInit("g:netrw_localmkdir","mkdir")
if g:netrw_cygwin
let g:netrw_localmovecmd= "mv"
else
- let g:netrw_localmovecmd= expand("$COMSPEC")." /c move"
+ let g:netrw_localmovecmd = expand("$COMSPEC")
+ let g:netrw_localmovecmdopt= " /c move"
endif
elseif has("unix") || has("macunix")
let g:netrw_localmovecmd= "mv"
let g:netrw_localmovecmd= ""
endif
endif
-if v:version < 704 || !has("patch1109")
+if v:version < 704 || (v:version == 704 && !has("patch1107"))
+ " 1109 provides for delete(tmpdir,"d") which is what will be used
if exists("g:netrw_local_rmdir")
let g:netrw_localrmdir= g:netrw_local_rmdir
call netrw#ErrorMsg(s:NOTE,"g:netrw_local_rmdir is deprecated in favor of g:netrw_localrmdir",86)
if g:netrw_cygwin
call s:NetrwInit("g:netrw_localrmdir","rmdir")
else
- let g:netrw_localrmdir= expand("$COMSPEC")." /c rmdir"
+ let g:netrw_localrmdir = expand("$COMSPEC")
+ let g:netrw_localrmdiropt= " /c rmdir"
endif
else
call s:NetrwInit("g:netrw_localrmdir","rmdir")
else
let s:treedepthstring= "| "
endif
-call s:NetrwInit("s:netrw_nbcd",'{}')
+call s:NetrwInit("s:netrw_posn",'{}')
" BufEnter event ignored by decho when following variable is true
" Has a side effect that doau BufReadPost doesn't work, so
NetrwKeepj call netrw#ErrorMsg(s:WARNING,"using Nexplore or <s-down> improperly; see help for netrw-starstar",40)
if has("clipboard")
sil! let @* = keepregstar
- sil! let @+ = keepregstar
+ sil! let @+ = keepregplus
endif
sil! let @/ = keepregslash
" call Dret("netrw#Explore")
NetrwKeepj call netrw#ErrorMsg(s:WARNING,"using Pexplore or <s-up> improperly; see help for netrw-starstar",41)
if has("clipboard")
sil! let @* = keepregstar
- sil! let @+ = keepregstar
+ sil! let @+ = keepregplus
endif
sil! let @/ = keepregslash
" call Dret("netrw#Explore")
keepalt call netrw#ErrorMsg(s:WARNING,'no files matched pattern<'.pattern.'>',45)
if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif
if has("clipboard")
- sil! let @* = keepregstar
- sil! let @+ = keepregstar
+ sil! let @* = keepregstar
+ sil! let @+ = keepregplus
endif
sil! let @/ = keepregslash
" call Dret("netrw#Explore : no files matched pattern")
keepalt NetrwKeepj call netrw#ErrorMsg(s:WARNING,"no files matched",42)
if has("clipboard")
sil! let @* = keepregstar
- sil! let @+ = keepregstar
+ sil! let @+ = keepregplus
endif
sil! let @/ = keepregslash
" call Dret("netrw#Explore : no files matched")
endif
if has("clipboard")
sil! let @* = keepregstar
- sil! let @+ = keepregstar
+ sil! let @+ = keepregplus
endif
sil! let @/ = keepregslash
" call Dret("netrw#Explore : missing +path_extra")
let prvfname= fname
endfor
" call Decho("explore_match<".s:explore_match.">",'~'.expand("<slnum>"))
- exe "2match netrwMarkFile /".s:explore_match."/"
+ if has("syntax") && exists("g:syntax_on") && g:syntax_on
+ exe "2match netrwMarkFile /".s:explore_match."/"
+ endif
endif
echo "<s-up>==Pexplore <s-down>==Nexplore"
else
let s:netrw_events= 2
if has("clipboard")
sil! let @* = keepregstar
- sil! let @+ = keepregstar
+ sil! let @+ = keepregplus
endif
sil! let @/ = keepregslash
" call Dret("netrw#Explore : @/<".@/.">")
" ---------------------------------------------------------------------
" netrw#Lexplore: toggle Explorer window, keeping it on the left of the current tab {{{2
fun! netrw#Lexplore(count,rightside,...)
-" call Dfunc("netrw#Lexplore(count=".a:count."rightside=".a:rightside.",...) a:0=".a:0." ft=".&ft)
+" call Dfunc("netrw#Lexplore(count=".a:count." rightside=".a:rightside.",...) a:0=".a:0." ft=".&ft)
let curwin= winnr()
if a:0 > 0 && a:1 != ""
" if a netrw window is already on the left-side of the tab
" and a directory has been specified, explore with that
" directory.
+" call Decho("case has input argument(s) (a:1<".a:1.">)")
let a1 = expand(a:1)
" call Decho("a:1<".a:1."> curwin#".curwin,'~'.expand("<slnum>"))
exe "1wincmd w"
exe curwin."wincmd w"
else
let a1= ""
+" call Decho("no input arguments")
endif
if exists("t:netrw_lexbufnr")
" check if t:netrw_lexbufnr refers to a netrw window
let lexwinnr = bufwinnr(t:netrw_lexbufnr)
+" call Decho("lexwinnr= bufwinnr(t:netrw_lexbufnr#".t:netrw_lexbufnr.")=".lexwinnr)
else
let lexwinnr= 0
+" call Decho("t:netrw_lexbufnr doesn't exist")
endif
+" call Decho("lexwinnr=".lexwinnr,'~'.expand("<slnum>"))
if lexwinnr > 0
" close down netrw explorer window
-" call Decho("t:netrw_lexbufnr#".t:netrw_lexbufnr.": close down netrw window",'~'.expand("<slnum>"))
+" call Decho("t:netrw_lexbufnr#".t:netrw_lexbufnr.": close down netrw window",'~'.expand("<slnum>"))
exe lexwinnr."wincmd w"
let g:netrw_winsize = -winwidth(0)
let t:netrw_lexposn = winsaveview()
if lexwinnr < curwin
let curwin= curwin - 1
endif
- exe curwin."wincmd w"
+ if lexwinnr != curwin
+ exe curwin."wincmd w"
+ endif
unlet t:netrw_lexbufnr
+" call Decho("unlet t:netrw_lexbufnr")
else
" open netrw explorer window
let curfile= expand("%")
" call Decho("curfile<".curfile.">",'~'.expand("<slnum>"))
exe (a:rightside? "botright" : "topleft")." vertical ".((g:netrw_winsize > 0)? (g:netrw_winsize*winwidth(0))/100 : -g:netrw_winsize) . " new"
+" call Decho("new buf#".bufnr("%")." win#".winnr())
if a:0 > 0 && a1 != ""
" call Decho("case 1: Explore ".a1,'~'.expand("<slnum>"))
+ call netrw#Explore(0,0,0,a1)
exe "Explore ".fnameescape(a1)
elseif curfile =~ '^\a\{3,}://'
" call Decho("case 2: Explore ".substitute(curfile,'[^/\\]*$','',''),'~'.expand("<slnum>"))
- exe "Explore ".substitute(curfile,'[^/\\]*$','','')
+ call netrw#Explore(0,0,0,substitute(curfile,'[^/\\]*$','',''))
else
" call Decho("case 3: Explore .",'~'.expand("<slnum>"))
- Explore .
+ call netrw#Explore(0,0,0,".")
endif
if a:count != 0
let g:netrw_winsize = netrw_winsize
setlocal winfixwidth
let g:netrw_altv = keep_altv
let t:netrw_lexbufnr = bufnr("%")
+" call Decho("let t:netrw_lexbufnr=".t:netrw_lexbufnr)
+" call Decho("t:netrw_lexposn".(exists("t:netrw_lexposn")? string(t:netrw_lexposn) : " n/a"))
if exists("t:netrw_lexposn")
" call Decho("restoring to t:netrw_lexposn",'~'.expand("<slnum>"))
" call Decho("restoring posn to t:netrw_lexposn<".string(t:netrw_lexposn).">",'~'.expand("<slnum>"))
else
let g:netrw_chgwin= 2
endif
+" call Decho("let g:netrw_chgwin=".g:netrw_chgwin)
endif
" call Dret("netrw#Lexplore")
" call Decho("transfer files one at a time",'~'.expand("<slnum>"))
for fname in fnamelist
" call Decho("system(".g:netrw_localcopycmd." ".s:ShellEscape(fname)." ".s:ShellEscape(topath).")",'~'.expand("<slnum>"))
- call system(g:netrw_localcopycmd." ".s:ShellEscape(fname)." ".s:ShellEscape(topath))
+ call system(g:netrw_localcopycmd.g:netrw_localcopycmdopt." ".s:ShellEscape(fname)." ".s:ShellEscape(topath))
if v:shell_error != 0
call netrw#ErrorMsg(s:WARNING,"consider setting g:netrw_localcopycmd<".g:netrw_localcopycmd."> to something that works",80)
" call Dret("s:NetrwObtain 0 : failed: ".g:netrw_localcopycmd." ".s:ShellEscape(fname)." ".s:ShellEscape(topath))
" call Decho("transfer files with one command",'~'.expand("<slnum>"))
let filelist= join(map(deepcopy(fnamelist),"s:ShellEscape(v:val)"))
" call Decho("system(".g:netrw_localcopycmd." ".filelist." ".s:ShellEscape(topath).")",'~'.expand("<slnum>"))
- call system(g:netrw_localcopycmd." ".filelist." ".s:ShellEscape(topath))
+ call system(g:netrw_localcopycmd.g:netrw_localcopycmdopt." ".filelist." ".s:ShellEscape(topath))
if v:shell_error != 0
call netrw#ErrorMsg(s:WARNING,"consider setting g:netrw_localcopycmd<".g:netrw_localcopycmd."> to something that works",80)
" call Dret("s:NetrwObtain 0 : failed: ".g:netrw_localcopycmd." ".filelist." ".s:ShellEscape(topath))
else
let path= ""
endif
- let filelist= join(map(deepcopy(fnamelist),'s:ShellEscape(g:netrw_machine.":".path.v:val,1)'))
+ let filelist= join(map(deepcopy(fnamelist),'escape(s:ShellEscape(g:netrw_machine.":".path.v:val,1)," ")'))
call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_scp_cmd.s:ShellEscape(useport,1)." ".filelist." ".s:ShellEscape(tgtdir,1))
elseif b:netrw_method == 2
" call Dfunc("s:NetrwOptionRestore(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> winnr($)=".winnr("$"))
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("<slnum>"))
if !exists("{a:vt}netrw_optionsave")
- call s:RestorePosn(s:netrw_nbcd)
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("<slnum>"))
" call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>"))
" call Dret("s:NetrwOptionRestore : ".a:vt."netrw_optionsave doesn't exist")
endif
endif
endif
- 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_blkeep") |let &l:bl = {a:vt}netrw_blkeep |unlet {a:vt}netrw_blkeep |endif
- if exists("{a:vt}netrw_btkeep") |let &l:bt = {a:vt}netrw_btkeep |unlet {a:vt}netrw_btkeep |endif
- if exists("{a:vt}netrw_bombkeep") |let &l:bomb = {a:vt}netrw_bombkeep |unlet {a:vt}netrw_bombkeep |endif
- if exists("{a:vt}netrw_cedit") |let &cedit = {a:vt}netrw_cedit |unlet {a:vt}netrw_cedit |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_diffkeep") |let &l:diff = {a:vt}netrw_diffkeep |unlet {a:vt}netrw_diffkeep |endif
- if exists("{a:vt}netrw_fenkeep") |let &l:fen = {a:vt}netrw_fenkeep |unlet {a:vt}netrw_fenkeep |endif
- if exists("g:netrw_ffkep") && g:netrw_ffkeep
- if exists("{a:vt}netrw_ffkeep") |let &l:ff = {a:vt}netrw_ffkeep |unlet {a:vt}netrw_ffkeep |endif
- endif
- if exists("{a:vt}netrw_fokeep") |let &l:fo = {a:vt}netrw_fokeep |unlet {a:vt}netrw_fokeep |endif
- if exists("{a:vt}netrw_gdkeep") |let &l:gd = {a:vt}netrw_gdkeep |unlet {a:vt}netrw_gdkeep |endif
- if exists("{a:vt}netrw_hidkeep") |let &l:hidden = {a:vt}netrw_hidkeep |unlet {a:vt}netrw_hidkeep |endif
- if exists("{a:vt}netrw_imkeep") |let &l:im = {a:vt}netrw_imkeep |unlet {a:vt}netrw_imkeep |endif
- if exists("{a:vt}netrw_iskkeep") |let &l:isk = {a:vt}netrw_iskkeep |unlet {a:vt}netrw_iskkeep |endif
- if exists("{a:vt}netrw_lskeep") |let &l:ls = {a:vt}netrw_lskeep |unlet {a:vt}netrw_lskeep |endif
- if exists("{a:vt}netrw_makeep") |let &l:ma = {a:vt}netrw_makeep |unlet {a:vt}netrw_makeep |endif
- if exists("{a:vt}netrw_magickeep")|let &l:magic = {a:vt}netrw_magickeep |unlet {a:vt}netrw_magickeep|endif
- if exists("{a:vt}netrw_modkeep") |let &l:mod = {a:vt}netrw_modkeep |unlet {a:vt}netrw_modkeep |endif
- if exists("{a:vt}netrw_nukeep") |let &l:nu = {a:vt}netrw_nukeep |unlet {a:vt}netrw_nukeep |endif
- if exists("{a:vt}netrw_rnukeep") |let &l:rnu = {a:vt}netrw_rnukeep |unlet {a:vt}netrw_rnukeep |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_rokeep") |let &l:ro = {a:vt}netrw_rokeep |unlet {a:vt}netrw_rokeep |endif
- if exists("{a:vt}netrw_selkeep") |let &l:sel = {a:vt}netrw_selkeep |unlet {a:vt}netrw_selkeep |endif
- if exists("{a:vt}netrw_spellkeep")|let &l:spell = {a:vt}netrw_spellkeep |unlet {a:vt}netrw_spellkeep|endif
- if has("clipboard")
- if exists("{a:vt}netrw_starkeep") |let @* = {a:vt}netrw_starkeep |unlet {a:vt}netrw_starkeep |endif
- endif
+ call s:NetrwRestoreSetting(a:vt."netrw_aikeep","&l:ai")
+ call s:NetrwRestoreSetting(a:vt."netrw_awkeep","&l:aw")
+ call s:NetrwRestoreSetting(a:vt."netrw_blkeep","&l:bl")
+ call s:NetrwRestoreSetting(a:vt."netrw_btkeep","&l:bt")
+ call s:NetrwRestoreSetting(a:vt."netrw_bombkeep","&l:bomb")
+ call s:NetrwRestoreSetting(a:vt."netrw_cedit","&cedit")
+ call s:NetrwRestoreSetting(a:vt."netrw_cikeep","&l:ci")
+ call s:NetrwRestoreSetting(a:vt."netrw_cinkeep","&l:cin")
+ call s:NetrwRestoreSetting(a:vt."netrw_cinokeep","&l:cino")
+ call s:NetrwRestoreSetting(a:vt."netrw_comkeep","&l:com")
+ call s:NetrwRestoreSetting(a:vt."netrw_cpokeep","&l:cpo")
+ call s:NetrwRestoreSetting(a:vt."netrw_diffkeep","&l:diff")
+ call s:NetrwRestoreSetting(a:vt."netrw_fenkeep","&l:fen")
+ if exists("g:netrw_ffkeep") && g:netrw_ffkeep
+ call s:NetrwRestoreSetting(a:vt."netrw_ffkeep")","&l:ff")
+ endif
+ call s:NetrwRestoreSetting(a:vt."netrw_fokeep","&l:fo")
+ call s:NetrwRestoreSetting(a:vt."netrw_gdkeep","&l:gd")
+ call s:NetrwRestoreSetting(a:vt."netrw_hidkeep","&l:hidden")
+ call s:NetrwRestoreSetting(a:vt."netrw_imkeep","&l:im")
+ call s:NetrwRestoreSetting(a:vt."netrw_iskkeep","&l:isk")
+ call s:NetrwRestoreSetting(a:vt."netrw_lskeep","&l:ls")
+ call s:NetrwRestoreSetting(a:vt."netrw_makeep","&l:ma")
+ call s:NetrwRestoreSetting(a:vt."netrw_magickeep","&l:magic")
+ call s:NetrwRestoreSetting(a:vt."netrw_modkeep","&l:mod")
+ call s:NetrwRestoreSetting(a:vt."netrw_nukeep","&l:nu")
+ call s:NetrwRestoreSetting(a:vt."netrw_rnukeep","&l:rnu")
+ call s:NetrwRestoreSetting(a:vt."netrw_repkeep","&l:report")
+ call s:NetrwRestoreSetting(a:vt."netrw_rokeep","&l:ro")
+ call s:NetrwRestoreSetting(a:vt."netrw_selkeep","&l:sel")
+ call s:NetrwRestoreSetting(a:vt."netrw_spellkeep","&l:spell")
+ call s:NetrwRestoreSetting(a:vt."netrw_twkeep","&l:tw")
+ call s:NetrwRestoreSetting(a:vt."netrw_wigkeep","&l:wig")
+ call s:NetrwRestoreSetting(a:vt."netrw_wrapkeep","&l:wrap")
+ call s:NetrwRestoreSetting(a:vt."netrw_writekeep","&l:write")
+ call s:NetrwRestoreSetting("s:yykeep","@@")
" Problem: start with liststyle=0; press <i> : result, following line resets l:ts.
-" if exists("{a:vt}netrw_tskeep") |let &l:ts = {a:vt}netrw_tskeep |unlet {a:vt}netrw_tskeep |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("{a:vt}netrw_wrapkeep") |let &l:wrap = {a:vt}netrw_wrapkeep |unlet {a:vt}netrw_wrapkeep |endif
- if exists("{a:vt}netrw_writekeep")|let &l:write = {a:vt}netrw_writekeep |unlet {a:vt}netrw_writekeep|endif
- if exists("s:yykeep") |let @@ = s:yykeep |unlet s:yykeep |endif
+ call s:NetrwRestoreSetting(a:vt."netrw_tskeep","&l:ts")
+
if exists("{a:vt}netrw_swfkeep")
if &directory == ""
" user hasn't specified a swapfile directory;
endif
endif
if has("clipboard")
- if exists("{a:vt}netrw_regstar") |sil! let @*= {a:vt}netrw_regstar |unlet {a:vt}netrw_regstar |endif
+ call s:NetrwRestoreSetting(a:vt."netrw_starkeep","@*")
+ call s:NetrwRestoreSetting(a:vt."netrw_pluskeep","@+")
endif
- if exists("{a:vt}netrw_regslash")|sil! let @/= {a:vt}netrw_regslash|unlet {a:vt}netrw_regslash|endif
- call s:RestorePosn(s:netrw_nbcd)
+ call s:NetrwRestoreSetting(a:vt."netrw_slashkeep","@/")
" call Decho("g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd,'~'.expand("<slnum>"))
" call Decho("fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist"),'~'.expand("<slnum>"))
if !g:netrw_use_noswf
let {a:vt}netrw_swfkeep = &l:swf
endif
- if has("clipboard")
- let {a:vt}netrw_starkeep = @*
- endif
let {a:vt}netrw_tskeep = &l:ts
let {a:vt}netrw_twkeep = &l:tw " textwidth
let {a:vt}netrw_wigkeep = &l:wig " wildignore
let {a:vt}netrw_dirkeep = getcwd()
endif
if has("clipboard")
- if &go =~# 'a' | sil! let {a:vt}netrw_regstar = @* | endif
+ sil! let {a:vt}netrw_starkeep = @*
+ sil! let {a:vt}netrw_pluskeep = @+
endif
- sil! let {a:vt}netrw_regslash= @/
+ sil! let {a:vt}netrw_slashkeep= @/
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("<slnum>"))
" call Dret("s:NetrwOptionSave : tab#".tabpagenr()." win#".winnr())
endfun
" ------------------------------------------------------------------------
+" s:NetrwRestoreSetting: restores specified setting using associated keepvar, {{{2
+" but only if the setting value differs from the associated keepvar.
+" Doing this means that netrw will not come up as having changed a
+" setting last when it really didn't actually change it.
+" Used by s:NetrwOptionRestore() to restore each netrw-senstive setting
+" and by s:NetrwSafeOptions()
+fun! s:NetrwRestoreSetting(keepvar,setting)
+" call Dfunc("s:NetrwRestoreSetting(keepvar<".a:keepvar."> setting<".a:setting.">)")
+
+ if a:keepvar =~ '^&'
+ exe "let keepvarval= ".a:keepvar
+ if keepvarval != a:setting
+ if type(a:setting) == 0
+ exe "let ".a:keepvar."=".a:setting
+ elseif type(a:setting) == 1
+ exe "let ".a:keepvar."= '".a:setting."'"
+ else
+ call netrw#ErrorMsg(s:ERROR,"(s:NetrwRestoreSetting) doesn't know how to restore ".a:keepvar." with a setting of type#".type(a:setting),105)
+ endif
+ endif
+
+ elseif exists(a:keepvar)
+ exe "let keepvarval= '".a:keepvar."'"
+ if keepvarval != a:setting
+ if type(a:setting) == 0
+ exe "let ".a:keepvar."= ".a:setting
+ elseif type(a:setting) == 1
+ exe "let ".a:keepvar."= '".a:setting."'"
+ else
+ call netrw#ErrorMsg(s:ERROR,"(s:NetrwRestoreSetting) doesn't know how to restore ".a:keepvar." with a setting of type#".type(a:setting),105)
+ endif
+ endif
+ exe "unlet ".a:keepvar
+ endif
+" call Dret("s:NetrwRestoreSetting")
+endfun
+
+" ---------------------------------------------------------------------
" s:NetrwSafeOptions: sets options to help netrw do its job {{{2
" Use s:NetrwSaveOptions() to save user settings
" Use s:NetrwOptionRestore() to restore user settings
" call Dfunc("s:NetrwSafeOptions() win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%"))."> winnr($)=".winnr("$"))
" call Decho("win#".winnr()."'s ft=".&ft,'~'.expand("<slnum>"))
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>"))
- if exists("+acd") | setl noacd | endif
- setl noai
- setl noaw
- setl nobl
- setl nobomb
- setl bt=nofile
- setl noci
- setl nocin
- setl bh=hide
- setl cino=
- setl com=
- setl cpo-=a
- setl cpo-=A
+ if exists("+acd") | call s:NetrwRestoreSetting("&l:acd",0)|endif
+ call s:NetrwRestoreSetting("&l:ai",0)
+ call s:NetrwRestoreSetting("&l:aw",0)
+ call s:NetrwRestoreSetting("&l:bl",0)
+ call s:NetrwRestoreSetting("&l:bomb",0)
+ call s:NetrwRestoreSetting("&l:bt","nofile")
+ call s:NetrwRestoreSetting("&l:ci",0)
+ call s:NetrwRestoreSetting("&l:cin",0)
+ call s:NetrwRestoreSetting("&l:bh","hide")
+ call s:NetrwRestoreSetting("&l:cino","")
+ call s:NetrwRestoreSetting("&l:com","")
+ if &cpo =~ 'a' | call s:NetrwRestoreSetting("&cpo",substitute(&cpo,'a','','g')) | endif
+ if &cpo =~ 'A' | call s:NetrwRestoreSetting("&cpo",substitute(&cpo,'A','','g')) | endif
setl fo=nroql2
- setl nohid
- setl noim
+ call s:NetrwRestoreSetting("&l:hid",0)
+ call s:NetrwRestoreSetting("&l:im",0)
setl isk+=@ isk+=* isk+=/
- setl magic
+ call s:NetrwRestoreSetting("&l:magic",1)
if g:netrw_use_noswf
- setl noswf
+ call s:NetrwRestoreSetting("swf",0)
endif
- setl report=10000
- setl sel=inclusive
- setl nospell
- setl tw=0
- setl wig=
+ call s:NetrwRestoreSetting("&l:report",10000)
+ call s:NetrwRestoreSetting("&l:sel","inclusive")
+ call s:NetrwRestoreSetting("&l:spell",0)
+ call s:NetrwRestoreSetting("&l:tw",0)
+ call s:NetrwRestoreSetting("&l:wig","")
setl cedit&
call s:NetrwCursor()
" call Decho("ft<".&ft."> ei=".&ei,'~'.expand("<slnum>"))
if &ft == "netrw"
" call Decho("do any netrw FileType autocmds (doau FileType netrw)",'~'.expand("<slnum>"))
- sil! keepalt NetrwKeepj doau FileType netrw
+ keepalt NetrwKeepj doau FileType netrw
endif
" call Decho("fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")." bh=".&l:bh." bt<".&bt.">",'~'.expand("<slnum>"))
endif
endfun
-" ---------------------------------------------------------------------
+" ===============================
" Netrw Transfer Functions: {{{1
" ===============================
" NetRead: Determine method of read (ftp, rcp, etc) {{{3
call s:NetrwMethod(choice)
if !exists("b:netrw_method") || b:netrw_method < 0
-" call Dfunc("netrw#NetRead : unsupported method")
+" call Dret("netrw#NetRead : unsupported method")
return
endif
let tmpfile= s:GetTempfile(b:netrw_fname) " apply correct suffix
else
let tmpfile_get = tmpfile
endif
- call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".s:ShellEscape(g:netrw_machine.":".b:netrw_fname,1)." ".s:ShellEscape(tmpfile_get,1))
+ call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".escape(s:ShellEscape(g:netrw_machine.":".b:netrw_fname,1),' ')." ".s:ShellEscape(tmpfile_get,1))
let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
let b:netrw_lastfile = choice
" NetRead: (rsync) NetRead Method #7 {{{3
elseif b:netrw_method == 7
" call Decho("read via rsync (method #7)",'~'.expand("<slnum>"))
- call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".s:ShellEscape(g:netrw_machine.":".b:netrw_fname,1)." ".s:ShellEscape(tmpfile,1))
+ call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".s:ShellEscape(g:netrw_machine.g:netrw_rsync_sep.b:netrw_fname,1)." ".s:ShellEscape(tmpfile,1))
let result = s:NetrwGetFile(readcmd,tmpfile, b:netrw_method)
let b:netrw_lastfile = choice
let url= g:netrw_choice
call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_http_put_cmd." ".s:ShellEscape(tmpfile,1)." ".s:ShellEscape(url,1) )
elseif !exists("g:netrw_quiet")
- call netrw#ErrorMsg(s:ERROR,"can't write to http using <".g:netrw_http_put_cmd".">".",16)
+ call netrw#ErrorMsg(s:ERROR,"can't write to http using <".g:netrw_http_put_cmd.">".",16)
endif
".........................................
" NetWrite: (rsync) NetWrite Method #7 {{{3
elseif b:netrw_method == 7
" call Decho("write via rsync (method #7)",'~'.expand("<slnum>"))
- call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".s:ShellEscape(tmpfile,1)." ".s:ShellEscape(g:netrw_machine.":".b:netrw_fname,1))
+ call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".s:ShellEscape(tmpfile,1)." ".s:ShellEscape(g:netrw_machine.g:netrw_rsync_sep.b:netrw_fname,1))
let b:netrw_lastfile = choice
".........................................
" ---------------------------------------------------------------------
" netrw#SetTreetop: resets the tree top to the current directory/specified directory {{{2
" (implements the :Ntree command)
-fun! netrw#SetTreetop(...)
-" call Dfunc("netrw#SetTreetop(".((a:0 > 0)? a:1 : "").") a:0=".a:0)
+fun! netrw#SetTreetop(iscmd,...)
+" call Dfunc("netrw#SetTreetop(iscmd=".a:iscmd." ".((a:0 > 0)? a:1 : "").") a:0=".a:0)
+" call Decho("w:netrw_treetop<".w:netrw_treetop.">")
+ " iscmd==0: netrw#SetTreetop called using gn mapping
+ " iscmd==1: netrw#SetTreetop called using :Ntree from the command line
+" call Decho("(iscmd=".a:iscmd.": called using :Ntree from command line",'~'.expand("<slnum>"))
" clear out the current tree
if exists("w:netrw_treetop")
" call Decho("clearing out current tree",'~'.expand("<slnum>"))
" call Decho("freeing w:netrw_treedict",'~'.expand("<slnum>"))
unlet w:netrw_treedict
endif
+" call Decho("inittreetop<".(exists("inittreetop")? inittreetop : "n/a").">")
- if a:1 == "" && exists("inittreetop")
+ if (a:iscmd == 0 || a:1 == "") && exists("inittreetop")
let treedir= s:NetrwTreePath(inittreetop)
" call Decho("treedir<".treedir.">",'~'.expand("<slnum>"))
else
let treedir= a:1
elseif exists("b:netrw_curdir") && (isdirectory(s:NetrwFile(b:netrw_curdir."/".a:1)) || a:1 =~ '^\a\{3,}://')
let treedir= b:netrw_curdir."/".a:1
-" call Decho("a:1<".a:1."> is NOT a directory, trying treedir<".treedir.">",'~'.expand("<slnum>"))
+" call Decho("a:1<".a:1."> is NOT a directory, using treedir<".treedir.">",'~'.expand("<slnum>"))
else
" normally the cursor is left in the message window.
" However, here this results in the directory being listed in the message window, which is not wanted.
endif
endif
" call Decho("treedir<".treedir.">",'~'.expand("<slnum>"))
+
+ " determine if treedir is remote or local
let islocal= expand("%") !~ '^\a\{3,}://'
" call Decho("islocal=".islocal,'~'.expand("<slnum>"))
+
+ " browse the resulting directory
if islocal
call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(islocal,treedir))
else
call s:NetrwBrowse(islocal,s:NetrwBrowseChgDir(islocal,treedir))
endif
+
" call Dret("netrw#SetTreetop")
endfun
else
let tfile= a:tfile
endif
-" call Decho("exe sil! keepalt file ".fnameescape(tfile),'~'.expand("<slnum>"))
- exe "sil! keepalt file ".fnameescape(tfile)
+ call s:NetrwBufRename(tfile)
" edit temporary file (ie. read the temporary file in)
if rfile =~ '\.zip$'
endif
" rename buffer back to remote filename
-" call Decho("exe sil! keepalt file ".fnameescape(rfile),'~'.expand("<slnum>"))
- exe "sil! NetrwKeepj keepalt file ".fnameescape(rfile)
+ call s:NetrwBufRename(rfile)
" Detect filetype of local version of remote file.
" Note that isk must not include a "/" for scripts.vim
let iskkeep= &l:isk
setl isk-=/
let &l:isk= iskkeep
-" call Dredir("renamed buffer back to remote filename<".rfile."> : expand(%)<".expand("%").">","ls!")
+" call Dredir("ls!","NetrwGetFile (renamed buffer back to remote filename<".rfile."> : expand(%)<".expand("%").">)")
let line1 = 1
let line2 = line("$")
" g:netrw_port = optional port number (for ftp)
" g:netrw_choice = copy of input url (choice)
fun! s:NetrwMethod(choice)
-" call Dfunc("NetrwMethod(a:choice<".a:choice.">)")
+" call Dfunc("s:NetrwMethod(a:choice<".a:choice.">)")
" sanity check: choice should have at least three slashes in it
if strlen(substitute(a:choice,'[^/]','','g')) < 3
call netrw#ErrorMsg(s:ERROR,"not a netrw-style url; netrw uses protocol://[user@]hostname[:port]/[path])",78)
let b:netrw_method = -1
-" call Dret("NetrwMethod : incorrect url format<".a:choice.">")
+" call Dret("s:NetrwMethod : incorrect url format<".a:choice.">")
return
endif
endif
if curmachine != g:netrw_machine
- if exists("s:netwr_hup[".g:netrw_machine."]")
+ if exists("s:netrw_hup[".g:netrw_machine."]")
call NetUserPass("ftp:".g:netrw_machine)
elseif exists("s:netrw_passwd")
" if there's a change in hostname, require password re-entry
" call Decho("s:netrw_passwd <".s:netrw_passwd.">",'~'.expand("<slnum>"))
" endif "Decho
" call Decho("b:netrw_fname <".b:netrw_fname.">",'~'.expand("<slnum>"))
-" call Dret("NetrwMethod : b:netrw_method=".b:netrw_method." g:netrw_port=".g:netrw_port)
+" call Dret("s:NetrwMethod : b:netrw_method=".b:netrw_method." g:netrw_port=".g:netrw_port)
endfun
" ------------------------------------------------------------------------
" call Dret("NetUserPass : uid<".g:netrw_uid."> passwd<".s:netrw_passwd.">")
endfun
-" ===========================================
+" =================================
" Shared Browsing Support: {{{1
-" ===========================================
+" =================================
" ---------------------------------------------------------------------
" s:ExplorePatHls: converts an Explore pattern into a regular expression search pattern {{{2
" call Dfunc("s:NetrwBrowse(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".w:netrw_liststyle." ".g:loaded_netrw." buf#".bufnr("%")."<".bufname("%")."> win#".winnr())
" call Decho("modified=".&modified." modifiable=".&modifiable." readonly=".&readonly,'~'.expand("<slnum>"))
" call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>"))
-" call Dredir("ls!")
+" call Dredir("ls!","s:NetrwBrowse")
" save alternate-file's filename if w:netrw_rexlocal doesn't exist
" This is useful when one edits a local file, then :e ., then :Rex
let dirname= a:dirname
endif
+ " repoint t:netrw_lexbufnr if appropriate
+ if exists("t:netrw_lexbufnr") && bufnr("%") == t:netrw_lexbufnr
+" call Decho("set repointlexbufnr to true!")
+ let repointlexbufnr= 1
+ endif
+
if exists("s:netrw_skipbrowse")
unlet s:netrw_skipbrowse
" call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." filename<".expand("%")."> win#".winnr()." ft<".&ft.">",'~'.expand("<slnum>"))
call s:NetrwOptionSave("w:")
" s:NetrwBrowse : re-instate any marked files {{{3
- if exists("s:netrwmarkfilelist_{bufnr('%')}")
-" call Decho("clearing marked files",'~'.expand("<slnum>"))
- exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/"
+ if has("syntax") && exists("g:syntax_on") && g:syntax_on
+ if exists("s:netrwmarkfilelist_{bufnr('%')}")
+" call Decho("clearing marked files",'~'.expand("<slnum>"))
+ exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/"
+ endif
endif
if a:islocal && exists("w:netrw_acdkeep") && w:netrw_acdkeep
" s:NetrwBrowse : set up "safe" options for local directory/file {{{3
" call Decho("handle w:netrw_acdkeep:",'~'.expand("<slnum>"))
" call Decho("NetrwKeepj lcd ".fnameescape(dirname)." (due to w:netrw_acdkeep=".w:netrw_acdkeep." - acd=".&acd.")",'~'.expand("<slnum>"))
- call s:NetrwLcd(dirname)
- call s:NetrwSafeOptions()
+ if s:NetrwLcd(dirname)
+" call Dret("s:NetrwBrowse : lcd failure")
+ return
+ endif
+ " call s:NetrwSafeOptions() " tst953 failed with this enabled.
" call Decho("getcwd<".getcwd().">",'~'.expand("<slnum>"))
elseif !a:islocal && dirname !~ '[\/]$' && dirname !~ '^"'
" call Decho("setl ma noro",'~'.expand("<slnum>"))
let b:netrw_curdir = dirname
let url = s:method."://".((s:user == "")? "" : s:user."@").s:machine.(s:port ? ":".s:port : "")."/".s:path
-" call Decho("exe sil! keepalt file ".fnameescape(url)." (bt=".&bt.")",'~'.expand("<slnum>"))
- exe "sil! NetrwKeepj keepalt file ".fnameescape(url)
+ call s:NetrwBufRename(url)
exe "sil! NetrwKeepj keepalt doau BufReadPre ".fnameescape(s:fname)
sil call netrw#NetRead(2,url)
" netrw.vim and tar.vim have already handled decompression of the tarball; avoiding gzip.vim error
let reusing= s:NetrwGetBuffer(a:islocal,dirname)
" maintain markfile highlighting
- if exists("s:netrwmarkfilemtch_{bufnr('%')}") && s:netrwmarkfilemtch_{bufnr("%")} != ""
-" call Decho("bufnr(%)=".bufnr('%'),'~'.expand("<slnum>"))
-" call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/",'~'.expand("<slnum>"))
- exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/"
- else
-" call Decho("2match none",'~'.expand("<slnum>"))
- 2match none
+ if has("syntax") && exists("g:syntax_on") && g:syntax_on
+ if exists("s:netrwmarkfilemtch_{bufnr('%')}") && s:netrwmarkfilemtch_{bufnr("%")} != ""
+" " call Decho("bufnr(%)=".bufnr('%'),'~'.expand("<slnum>"))
+" " call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/",'~'.expand("<slnum>"))
+ exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/"
+ else
+" " call Decho("2match none",'~'.expand("<slnum>"))
+ 2match none
+ endif
endif
if reusing && line("$") > 1
call s:NetrwOptionRestore("w:")
" call Decho("handle g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd,'~'.expand("<slnum>"))
" call Decho("l:acd".(exists("&l:acd")? "=".&l:acd : " doesn't exist"),'~'.expand("<slnum>"))
if !exists("&l:acd") || !&l:acd
- call s:NetrwLcd(b:netrw_curdir)
+ if s:NetrwLcd(b:netrw_curdir)
+" call Dret("s:NetrwBrowse : lcd failure")
+ return
+ endif
endif
endif
setl beval
endif
+ " repoint t:netrw_lexbufnr if appropriate
+ if exists("repointlexbufnr")
+ let t:netrw_lexbufnr= bufnr("%")
+" call Decho("repoint t:netrw_lexbufnr to #".t:netrw_lexbufnr)
+ endif
+
" restore position
if reusing
" call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
endfun
" ---------------------------------------------------------------------
-" s:NetrwGetBuffer: {{{2
+" s:NetrwGetBuffer: [get a new|find an old netrw] buffer for a netrw listing {{{2
" returns 0=cleared buffer
" 1=re-used buffer (buffer not cleared)
fun! s:NetrwGetBuffer(islocal,dirname)
" call Dfunc("s:NetrwGetBuffer(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".g:netrw_liststyle)
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>"))
-" call Decho("netrwbuf dictionary=".string(s:netrwbuf),'~'.expand("<slnum>"))
+" call Decho("netrwbuf dictionary=".(exists("s:netrwbuf")? string(s:netrwbuf) : 'n/a'),'~'.expand("<slnum>"))
let dirname= a:dirname
" re-use buffer if possible {{{3
" call Decho("--re-use a buffer if possible--",'~'.expand("<slnum>"))
if !exists("s:netrwbuf")
+" call Decho(" s:netrwbuf initialized to {}",'~'.expand("<slnum>"))
let s:netrwbuf= {}
endif
- if has_key(s:netrwbuf,s:NetrwFullPath(dirname))
+" call Decho(" s:netrwbuf =".string(s:netrwbuf),'~'.expand("<slnum>"))
+" call Decho(" w:netrw_liststyle =".(exists("w:netrw_liststyle")? w:netrw_liststyle : "n/a"),'~'.expand("<slnum>"))
+
+ if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
+ let bufnum = -1
+
+ if !empty(s:netrwbuf) && has_key(s:netrwbuf,s:NetrwFullPath(dirname))
+ if has_key(s:netrwbuf,"NetrwTreeListing")
+ let bufnum= s:netrwbuf["NetrwTreeListing"]
+ else
+ let bufnum= s:netrwbuf[s:NetrwFullPath(dirname)]
+ endif
+" call Decho(" NetrwTreeListing: bufnum#".bufnum,'~'.expand("<slnum>"))
+ if !bufexists(bufnum)
+ call remove(s:netrwbuf,"NetrwTreeListing"])
+ let bufnum= -1
+ endif
+ elseif bufnr("NetrwTreeListing") != -1
+ let bufnum= bufnr("NetrwTreeListing")
+" call Decho(" NetrwTreeListing".": bufnum#".bufnum,'~'.expand("<slnum>"))
+ else
+" call Decho(" did not find a NetrwTreeListing buffer",'~'.expand("<slnum>"))
+ let bufnum= -1
+ endif
+
+ elseif has_key(s:netrwbuf,s:NetrwFullPath(dirname))
let bufnum= s:netrwbuf[s:NetrwFullPath(dirname)]
-" call Decho("lookup netrwbuf dictionary: s:netrwbuf[".s:NetrwFullPath(dirname)."]=".bufnum)
+" call Decho(" lookup netrwbuf dictionary: s:netrwbuf[".s:NetrwFullPath(dirname)."]=".bufnum,'~'.expand("<slnum>"))
if !bufexists(bufnum)
call remove(s:netrwbuf,s:NetrwFullPath(dirname))
let bufnum= -1
endif
+
else
-" call Decho("lookup netrwbuf dictionary: s:netrwbuf[".s:NetrwFullPath(dirname)."] not a key")
+" call Decho(" lookup netrwbuf dictionary: s:netrwbuf[".s:NetrwFullPath(dirname)."] not a key",'~'.expand("<slnum>"))
let bufnum= -1
endif
+" call Decho(" bufnum#".bufnum,'~'.expand("<slnum>"))
" get enew buffer and name it -or- re-use buffer {{{3
if bufnum < 0 " get enew buffer and name it
if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
" Got enew buffer; transform into a NetrwTreeListing
" call Decho("--transform enew buffer#".bufnr("%")." into a NetrwTreeListing --",'~'.expand("<slnum>"))
- if !exists("s:netrw_treelistnum")
- let s:netrw_treelistnum= 1
- else
- let s:netrw_treelistnum= s:netrw_treelistnum + 1
- endif
- let w:netrw_treebufnr= bufnr("%")
-" call Decho(" exe sil! keepalt file NetrwTreeListing ".fnameescape(s:netrw_treelistnum),'~'.expand("<slnum>"))
- exe 'sil! keepalt file NetrwTreeListing\ '.fnameescape(s:netrw_treelistnum)
+ let w:netrw_treebufnr = bufnr("%")
+ call s:NetrwBufRename("NetrwTreeListing")
if g:netrw_use_noswf
setl nobl bt=nofile noswf
else
nnoremap <silent> <buffer> ]] :sil call <SID>TreeListMove(']]')<cr>
nnoremap <silent> <buffer> [] :sil call <SID>TreeListMove('[]')<cr>
nnoremap <silent> <buffer> ][ :sil call <SID>TreeListMove('][')<cr>
-" call Decho(" tree listing#".s:netrw_treelistnum." bufnr=".w:netrw_treebufnr,'~'.expand("<slnum>"))
- else
-" let v:errmsg = "" " Decho
- let escdirname = fnameescape(dirname)
-" call Decho(" errmsg<".v:errmsg."> bufnr(escdirname<".escdirname.">)=".bufnr(escdirname)." bufname()<".bufname(bufnr(escdirname)).">",'~'.expand("<slnum>"))
-" call Decho(' exe sil! keepalt file '.escdirname,'~'.expand("<slnum>"))
-" let v:errmsg= "" " Decho
- exe 'sil! keepj keepalt file '.escdirname
-" call Decho(" errmsg<".v:errmsg."> bufnr(".escdirname.")=".bufnr(escdirname)."<".bufname(bufnr(escdirname)).">",'~'.expand("<slnum>"))
+" call Decho(" tree listing bufnr=".w:netrw_treebufnr,'~'.expand("<slnum>"))
+ else
+ call s:NetrwBufRename(dirname)
" enter the new buffer into the s:netrwbuf dictionary
let s:netrwbuf[s:NetrwFullPath(dirname)]= bufnr("%")
" call Decho("update netrwbuf dictionary: s:netrwbuf[".s:NetrwFullPath(dirname)."]=".bufnr("%"),'~'.expand("<slnum>"))
endif
" call Decho(" line($)=".line("$"),'~'.expand("<slnum>"))
if bufname("%") == '.'
-" call Decho("exe sil! keepalt file ".fnameescape(getcwd()),'~'.expand("<slnum>"))
- exe "sil! NetrwKeepj keepalt file ".fnameescape(getcwd())
+ call s:NetrwBufRename(getcwd())
endif
let &ei= eikeep
elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
" call Decho("--re-use tree listing--",'~'.expand("<slnum>"))
" call Decho(" clear buffer<".expand("%")."> with :%d",'~'.expand("<slnum>"))
+ setl ma
sil NetrwKeepj %d _
NetrwKeepj call s:NetrwListSettings(a:islocal)
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>"))
" call Decho("--do netrw settings: make this buffer#".bufnr("%")." not-a-file, modifiable, not line-numbered, etc--",'~'.expand("<slnum>"))
let fname= expand("%")
NetrwKeepj call s:NetrwListSettings(a:islocal)
-" call Decho("exe sil! keepalt file ".fnameescape(fname),'~'.expand("<slnum>"))
- exe "sil! NetrwKeepj keepalt file ".fnameescape(fname)
+ call s:NetrwBufRename(fname)
" delete all lines from buffer {{{3
" call Decho("--delete all lines from buffer--",'~'.expand("<slnum>"))
endfun
" ---------------------------------------------------------------------
-" s:NetrwListSettings: make standard settings for a netrw listing {{{2
+" s:NetrwListSettings: make standard settings for making a netrw listing {{{2
+" g:netrw_bufsettings will be used after the listing is produced.
+" Called by s:NetrwGetBuffer()
fun! s:NetrwListSettings(islocal)
" call Dfunc("s:NetrwListSettings(islocal=".a:islocal.")")
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>"))
let fname= bufname("%")
" " call Decho("(NetrwListSettings) setl bt=nofile nobl ma nonu nowrap noro nornu",'~'.expand("<slnum>"))
- setl bt=nofile nobl ma nonu nowrap noro nornu
-" call Decho("(NetrwListSettings) exe sil! keepalt file ".fnameescape(fname),'~'.expand("<slnum>"))
- exe "sil! keepalt file ".fnameescape(fname)
+ " nobl noma nomod nonu noma nowrap ro nornu (std g:netrw_bufsettings)
+ setl bt=nofile nobl ma nonu nowrap noro nornu
+ call s:NetrwBufRename(fname)
if g:netrw_use_noswf
setl noswf
endif
-" call Dredir("ls!")
+" call Dredir("ls!","s:NetrwListSettings")
" call Decho("(NetrwListSettings) exe setl ts=".(g:netrw_maxfilenamelen+1),'~'.expand("<slnum>"))
exe "setl ts=".(g:netrw_maxfilenamelen+1)
setl isk+=.,~,-
endfun
" ---------------------------------------------------------------------
-" s:NetrwListStyle: {{{2
+" s:NetrwListStyle: change list style (thin - long - wide - tree) {{{2
" islocal=0: remote browsing
" =1: local browsing
fun! s:NetrwListStyle(islocal)
" call Decho("chgd w:netrw_liststyle to ".w:netrw_liststyle,'~'.expand("<slnum>"))
" call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "doesn't exist").">",'~'.expand("<slnum>"))
+ " repoint t:netrw_lexbufnr if appropriate
+ if exists("t:netrw_lexbufnr") && bufnr("%") == t:netrw_lexbufnr
+" call Decho("set repointlexbufnr to true!")
+ let repointlexbufnr= 1
+ endif
+
if w:netrw_liststyle == s:THINLIST
" use one column listing
" call Decho("use one column list",'~'.expand("<slnum>"))
NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
NetrwKeepj call s:NetrwCursor()
+ " repoint t:netrw_lexbufnr if appropriate
+ if exists("repointlexbufnr")
+ let t:netrw_lexbufnr= bufnr("%")
+" call Decho("repoint t:netrw_lexbufnr to #".t:netrw_lexbufnr)
+ endif
+
" restore position; keep cursor on the filename
" call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
NetrwKeepj call winrestview(svpos)
call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
" keep cursor on the filename
- let fname= s:NetrwGetWord()
- sil NetrwKeepj $
- 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'),'~'.expand("<slnum>"))
- if result <= 0 && exists("w:netrw_bannercnt")
- exe "NetrwKeepj ".w:netrw_bannercnt
+ if g:netrw_banner && exists("w:netrw_bannercnt") && line(".") >= w:netrw_bannercnt
+ let fname= s:NetrwGetWord()
+ sil NetrwKeepj $
+ 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'),'~'.expand("<slnum>"))
+ if result <= 0 && exists("w:netrw_bannercnt")
+ exe "NetrwKeepj ".w:netrw_bannercnt
+ endif
endif
let @@= ykeep
" call Dret("s:NetrwBannerCtrl : g:netrw_banner=".g:netrw_banner)
let @@= ykeep
" call Decho("b:netrw_curdir doesn't exist!",'~'.expand("<slnum>"))
" call Decho("getcwd<".getcwd().">",'~'.expand("<slnum>"))
-" call Dredir("ls!")
+" call Dredir("ls!","s:NetrwBrowseChgDir")
" call Dret("s:NetrwBrowseChgDir")
return
endif
" NetrwBrowseChgDir: save options and initialize {{{3
" call Decho("saving options",'~'.expand("<slnum>"))
- call s:SavePosn(s:netrw_nbcd)
+ call s:SavePosn(s:netrw_posn)
NetrwKeepj call s:NetrwOptionSave("s:")
NetrwKeepj call s:NetrwSafeOptions()
if (has("win32") || has("win95") || has("win64") || has("win16"))
setl ma noro nowrap
NetrwKeepj call setline(line('.'),'" Quick Help: <F1>:help '.s:QuickHelp[g:netrw_quickhelp])
setl noma nomod nowrap
- call s:RestorePosn(s:netrw_nbcd)
NetrwKeepj call s:NetrwOptionRestore("s:")
" call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>"))
endif
" else " Decho
" call Decho("skipping option restore (dorestore==0): hidden=".&hidden." bufhidden=".&bufhidden." mod=".&mod,'~'.expand("<slnum>"))
endif
- call s:RestorePosn(s:netrw_nbcd)
if dolockout && dorestore
" call Decho("restore: filewritable(dirname<".dirname.">)=".filewritable(dirname),'~'.expand("<slnum>"))
if filewritable(dirname)
" call Decho("restore: ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>"))
endif
endif
+ call s:RestorePosn(s:netrw_posn)
let @@= ykeep
" call Dret("s:NetrwBrowseChgDir <".dirname."> : curpos<".string(getpos(".")).">")
return
endif
- if !exists("w:netrw_liststyle") || w:netrw_liststyle != s:TREELIST
- call s:SavePosn(s:netrw_nbcd)
- endif
-
norm! 0
if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict")
" call Decho("case: treestyle",'~'.expand("<slnum>"))
let swwline= winline() - 1
if exists("w:netrw_treetop")
let b:netrw_curdir= w:netrw_treetop
+ elseif exists("b:netrw_curdir")
+ let w:netrw_treetop= b:netrw_curdir
+ else
+ let w:netrw_treetop= getcwd()
+ let b:netrw_curdir = w:netrw_treetop
endif
- let curdir= b:netrw_curdir
+ let curfile = getline(".")
+ let curpath = s:NetrwTreePath(w:netrw_treetop)
if a:islocal
call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,'../'))
else
call s:NetrwBrowse(0,s:NetrwBrowseChgDir(0,'../'))
endif
- if !search('\c^'.s:treedepthstring.curline,'cw')
- if !search('\c^'.curline,'cw')
- sil! NetrwKeepj 1
- endif
+" call Decho("looking for curfile<^".s:treedepthstring.curfile.">",'~'.expand("<slnum>"))
+" call Decho("having curpath<".curpath.">",'~'.expand("<slnum>"))
+ if w:netrw_treetop == '/'
+ keepj call search('^\M'.curfile,"w")
+ elseif curfile == '../'
+ keepj call search('^\M'.curfile,"wb")
+ else
+" call Decho("search(^\\M".s:treedepthstring.curfile.") backwards"))
+ while 1
+ keepj call search('^\M'.s:treedepthstring.curfile,"wb")
+ let treepath= s:NetrwTreePath(w:netrw_treetop)
+" call Decho("..current treepath<".treepath.">",'~'.expand("<slnum>"))
+ if treepath == curpath
+ break
+ endif
+ endwhile
endif
- exe "sil! NetrwKeepj norm! z\<cr>"
- while winline() < swwline
- let curwinline= winline()
- exe "sil! NetrwKeepj norm! \<c-y>"
- if curwinline == winline()
- break
- endif
- endwhile
+
else
" call Decho("case: not treestyle",'~'.expand("<slnum>"))
+ call s:SavePosn(s:netrw_posn)
if exists("b:netrw_curdir")
let curdir= b:netrw_curdir
else
else
call s:NetrwBrowse(0,s:NetrwBrowseChgDir(0,'../'))
endif
- if has_key(s:netrw_nbcd,bufnr("%"))
- call s:RestorePosn(s:netrw_nbcd)
- elseif exists("w:netrw_bannercnt")
-" call Decho("moving to line#".w:netrw_bannercnt,'~'.expand("<slnum>"))
- exe w:netrw_bannercnt
- else
- 1
- endif
+ call s:RestorePosn(s:netrw_posn)
+ let curdir= substitute(curdir,'^.*[\/]','','')
+ call search('\<'.curdir.'/','wc')
endif
- let curdir= substitute(curdir,'^.*[\/]','','')
- call search('\<'.curdir.'\>','wc')
" call Dret("s:NetrwBrowseUpDir")
endfun
fun! netrw#BrowseX(fname,remote)
" call Dfunc("netrw#BrowseX(fname<".a:fname."> remote=".a:remote.")")
- " if its really just a directory, then do a "gf" instead
- if (a:remote == 0 && isdirectory(a:fname)) || (a:remote == 1 && fname =~ '/$' && fname !~ '^https\=:')
+ " if its really just a local directory, then do a "gf" instead
+ if (a:remote == 0 && isdirectory(a:fname)) || (a:remote == 1 && a:fname =~ '/$' && a:fname !~ '^https\=:')
norm! gf
-" call Dret("netrw#BrowseX : did gf instead")
+" call Dret("(netrw#BrowseX) did gf instead")
endif
-
let ykeep = @@
let screenposn = winsaveview()
-" call Decho("saving posn to screenposn<".string(screenposn).">",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) saving posn to screenposn<".string(screenposn).">",'~'.expand("<slnum>"))
" need to save and restore aw setting as gx can invoke this function from non-netrw buffers
let awkeep = &aw
if exists("g:Netrw_corehandler")
if type(g:Netrw_corehandler) == 2
" g:Netrw_corehandler is a function reference (see :help Funcref)
-" call Decho("g:Netrw_corehandler is a funcref",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) g:Netrw_corehandler is a funcref",'~'.expand("<slnum>"))
call g:Netrw_corehandler(s:NetrwFile(a:fname))
elseif type(g:Netrw_corehandler) == 3
" g:Netrw_corehandler is a List of function references (see :help Funcref)
-" call Decho("g:Netrw_corehandler is a List",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) g:Netrw_corehandler is a List",'~'.expand("<slnum>"))
for Fncref in g:Netrw_corehandler
if type(FncRef) == 2
call FncRef(a:fname)
endif
endfor
endif
-" call Decho("restoring posn to screenposn<".string(screenposn).">,'~'.expand("<slnum>"))"
+" call Decho("(netrw#BrowseX) restoring posn: screenposn<".string(screenposn).">,'~'.expand("<slnum>"))"
call winrestview(screenposn)
let @@= ykeep
let &aw= awkeep
if has("win32") || has("win95") || has("win64") || has("win16")
let exten= substitute(exten,'^.*$','\L&\E','')
endif
-" call Decho("exten<".exten.">",'~'.expand("<slnum>"))
+ if exten =~ "[\\/]"
+ let exten= ""
+ endif
+" call Decho("(netrw#BrowseX) exten<".exten.">",'~'.expand("<slnum>"))
if a:remote == 1
" create a local copy
-" call Decho("remote: a:remote=".a:remote.": create a local copy of <".a:fname.">",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) remote: a:remote=".a:remote.": create a local copy of <".a:fname.">",'~'.expand("<slnum>"))
setl bh=delete
call netrw#NetRead(3,a:fname)
" attempt to rename tempfile
let basename= substitute(a:fname,'^\(.*\)/\(.*\)\.\([^.]*\)$','\2','')
let newname = substitute(s:netrw_tmpfile,'^\(.*\)/\(.*\)\.\([^.]*\)$','\1/'.basename.'.\3','')
-" call Decho("basename<".basename.">",'~'.expand("<slnum>"))
-" call Decho("newname <".newname.">",'~'.expand("<slnum>"))
- if rename(s:netrw_tmpfile,newname) == 0
- " renaming succeeded
- let fname= newname
+" call Decho("(netrw#BrowseX) basename<".basename.">",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) newname <".newname.">",'~'.expand("<slnum>"))
+ if s:netrw_tmpfile != newname && newname != ""
+ if rename(s:netrw_tmpfile,newname) == 0
+ " renaming succeeded
+" call Decho("(netrw#BrowseX) renaming succeeded (tmpfile<".s:netrw_tmpfile."> to <".newname.">)")
+ let fname= newname
+ else
+ " renaming failed
+" call Decho("(netrw#BrowseX) renaming failed (tmpfile<".s:netrw_tmpfile."> to <".newname.">)")
+ let fname= s:netrw_tmpfile
+ endif
else
- " renaming failed
let fname= s:netrw_tmpfile
endif
else
-" call Decho("local: a:remote=".a:remote.": handling local copy of <".a:fname.">",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) local: a:remote=".a:remote.": handling local copy of <".a:fname.">",'~'.expand("<slnum>"))
let fname= a:fname
" special ~ handler for local
if fname =~ '^\~' && expand("$HOME") != ""
let fname= s:NetrwFile(substitute(fname,'^\~',expand("$HOME"),''))
endif
endif
-" call Decho("fname<".fname.">",'~'.expand("<slnum>"))
-" call Decho("exten<".exten."> "."netrwFileHandlers#NFH_".exten."():exists=".exists("*netrwFileHandlers#NFH_".exten),'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) fname<".fname.">",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) exten<".exten."> "."netrwFileHandlers#NFH_".exten."():exists=".exists("*netrwFileHandlers#NFH_".exten),'~'.expand("<slnum>"))
" set up redirection (avoids browser messages)
" by default, g:netrw_suppress_gx_mesg is true
let redir= &srr . "/dev/null"
endif
endif
-" call Decho("set up redirection: redir{".redir."} srr{".&srr."}",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) set up redirection: redir{".redir."} srr{".&srr."}",'~'.expand("<slnum>"))
" extract any viewing options. Assumes that they're set apart by quotes.
-" call Decho("extract any viewing options",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) extract any viewing options",'~'.expand("<slnum>"))
if exists("g:netrw_browsex_viewer")
-" call Decho("g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">",'~'.expand("<slnum>"))
if g:netrw_browsex_viewer =~ '\s'
let viewer = substitute(g:netrw_browsex_viewer,'\s.*$','','')
let viewopt = substitute(g:netrw_browsex_viewer,'^\S\+\s*','','')." "
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.">",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) !exe: viewer<".viewer."> viewopt<".viewopt.">",'~'.expand("<slnum>"))
endwhile
else
let viewer = g:netrw_browsex_viewer
let viewopt = ""
endif
-" call Decho("viewer<".viewer."> viewopt<".viewopt.">",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) viewer<".viewer."> viewopt<".viewopt.">",'~'.expand("<slnum>"))
endif
" execute the file handler
-" call Decho("execute the file handler (if any)",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) execute the file handler (if any)",'~'.expand("<slnum>"))
if exists("g:netrw_browsex_viewer") && g:netrw_browsex_viewer == '-'
-" call Decho("g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">",'~'.expand("<slnum>"))
let ret= netrwFileHandlers#Invoke(exten,fname)
elseif exists("g:netrw_browsex_viewer") && executable(viewer)
-" call Decho("g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">",'~'.expand("<slnum>"))
call s:NetrwExe("sil !".viewer." ".viewopt.s:ShellEscape(fname,1).redir)
let ret= v:shell_error
elseif has("win32") || has("win64")
-" call Decho("windows",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) win".(has("win32")? "32" : "64")",'~'.expand("<slnum>"))
if executable("start")
call s:NetrwExe('sil! !start rundll32 url.dll,FileProtocolHandler '.s:ShellEscape(fname,1))
elseif executable("rundll32")
else
call netrw#ErrorMsg(s:WARNING,"rundll32 not on path",74)
endif
- call inputsave()|call input("Press <cr> to continue")|call inputrestore()
+ " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
let ret= v:shell_error
elseif has("win32unix")
let winfname= 'c:\cygwin'.substitute(fname,'/','\\','g')
-" call Decho("cygwin: winfname<".s:ShellEscape(winfname,1).">",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) cygwin: winfname<".s:ShellEscape(winfname,1).">",'~'.expand("<slnum>"))
if executable("start")
call s:NetrwExe('sil !start rundll32 url.dll,FileProtocolHandler '.s:ShellEscape(winfname,1))
elseif executable("rundll32")
else
call netrw#ErrorMsg(s:WARNING,"rundll32 not on path",74)
endif
- call inputsave()|call input("Press <cr> to continue")|call inputrestore()
+ " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
let ret= v:shell_error
elseif has("unix") && executable("kfmclient") && s:CheckIfKde()
-" call Decho("unix and kfmclient",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) unix and kfmclient",'~'.expand("<slnum>"))
call s:NetrwExe("sil !kfmclient exec ".s:ShellEscape(fname,1)." ".redir)
let ret= v:shell_error
elseif has("unix") && executable("exo-open") && executable("xdg-open") && executable("setsid")
-" call Decho("unix, exo-open, xdg-open",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) unix, exo-open, xdg-open",'~'.expand("<slnum>"))
call s:NetrwExe("sil !setsid xdg-open ".s:ShellEscape(fname,1).redir)
let ret= v:shell_error
+ elseif has("unix") && $DESKTOP_SESSION == "mate" && executable("atril")
+" call Decho("(netrw#BrowseX) unix and atril",'~'.expand("<slnum>"))
+ call s:NetrwExe("sil !atril ".s:ShellEscape(fname,1).redir)
+ let ret= v:shell_error
+
elseif has("unix") && executable("xdg-open")
-" call Decho("unix and xdg-open",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) unix and xdg-open",'~'.expand("<slnum>"))
call s:NetrwExe("sil !xdg-open ".s:ShellEscape(fname,1).redir)
let ret= v:shell_error
elseif has("macunix") && executable("open")
-" call Decho("macunix and open",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) macunix and open",'~'.expand("<slnum>"))
call s:NetrwExe("sil !open ".s:ShellEscape(fname,1)." ".redir)
let ret= v:shell_error
exe "sil! NetrwKeepj norm! \<c-o>"
" redraw!
endif
-" call Decho("restoring posn to screenposn<".string(screenposn).">",'~'.expand("<slnum>"))
+" call Decho("(netrw#BrowseX) restoring posn to screenposn<".string(screenposn).">",'~'.expand("<slnum>"))
call winrestview(screenposn)
let @@ = ykeep
let &aw= awkeep
" call Dret("netrw#BrowseX")
endfun
+" ---------------------------------------------------------------------
+" netrw#GX: gets word under cursor for gx support {{{2
+" See also: netrw#BrowseXVis
+" netrw#BrowseX
+fun! netrw#GX()
+" call Dfunc("netrw#GX()")
+ if &ft == "netrw"
+ let fname= s:NetrwGetWord()
+ else
+ let fname= expand((exists("g:netrw_gx")? g:netrw_gx : '<cfile>'))
+ endif
+" call Dret("netrw#GX <".fname.">")
+ return fname
+endfun
+
" ---------------------------------------------------------------------
" netrw#BrowseXVis: used by gx in visual mode to select a file for browsing {{{2
fun! netrw#BrowseXVis()
let atkeep = @@
norm! gvy
" call Decho("@@<".@@.">",'~'.expand("<slnum>"))
- call netrw#BrowseX(@@,netrw#CheckIfRemote())
+ call netrw#BrowseX(@@,netrw#CheckIfRemote(@@))
let @@ = atkeep
" call Dret("netrw#BrowseXVis")
endfun
+" ---------------------------------------------------------------------
+" s:NetrwBufRename: renames a buffer without the side effect of retaining an unlisted buffer having the old name {{{2
+" Using the file command on a "[No Name]" buffer does not seem to cause the old "[No Name]" buffer
+" to become an unlisted buffer, so in that case don't bwipe it.
+fun! s:NetrwBufRename(newname)
+" call Dfunc("s:NetrwBufRename(newname<".a:newname.">) buf(%)#".bufnr("%")."<".bufname(bufnr("%")).">")
+" call Dredir("ls!","s:NetrwBufRename (before rename)")
+ let oldbufname= bufname(bufnr("%"))
+" call Decho("buf#".bufnr("%").": oldbufname<".oldbufname.">",'~'.expand("<slnum>"))
+ if oldbufname != a:newname
+" call Decho("do renaming (oldbufname != a:newname)",'~'.expand("<slnum>"))
+ exe 'sil! keepj keepalt file '.fnameescape(a:newname)
+ let oldbufnr= bufnr(oldbufname)
+ if oldbufname != "" && oldbufnr != -1
+ exe "bwipe! ".oldbufnr
+ endif
+ endif
+" call Dredir("ls!","s:NetrwBufRename (after rename)")
+" call Dret("s:NetrwBufRename : buf#".bufnr("%").": oldname<".oldbufname."> newname<".a:newname."> expand(%)<".expand("%").">")
+endfun
+
" ---------------------------------------------------------------------
" netrw#CheckIfRemote: returns 1 if current file looks like an url, 0 else {{{2
-fun! netrw#CheckIfRemote()
-" call Dfunc("netrw#CheckIfRemote()")
- if expand("%") =~ '^\a\{3,}://'
+fun! netrw#CheckIfRemote(...)
+" call Dfunc("netrw#CheckIfRemote() a:0=".a:0)
+ if a:0 > 0
+ let curfile= a:1
+ else
+ let curfile= expand("%")
+ endif
+" call Decho("curfile<".curfile.">")
+ if curfile =~ '^\a\{3,}://'
" call Dret("netrw#CheckIfRemote 1")
return 1
else
" call Dfunc("s:NetrwHidden()")
let ykeep= @@
" save current position
- let svpos= winsaveview()
+ let svpos = winsaveview()
" call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
if g:netrw_list_hide =~ '\(^\|,\)\\(^\\|\\s\\s\\)\\zs\\.\\S\\+'
- " remove pattern from hiding list
+ " remove .file pattern from hiding list
+" call Decho("remove .file pattern from hiding list",'~'.expand("<slnum>"))
let g:netrw_list_hide= substitute(g:netrw_list_hide,'\(^\|,\)\\(^\\|\\s\\s\\)\\zs\\.\\S\\+','','')
elseif s:Strlen(g:netrw_list_hide) >= 1
+" call Decho("add .file pattern from hiding list",'~'.expand("<slnum>"))
let g:netrw_list_hide= g:netrw_list_hide . ',\(^\|\s\s\)\zs\.\S\+'
else
+" call Decho("set .file pattern as hiding list",'~'.expand("<slnum>"))
let g:netrw_list_hide= '\(^\|\s\s\)\zs\.\S\+'
endif
+ if g:netrw_list_hide =~ '^,'
+ let g:netrw_list_hide= strpart(g:netrw_list_hide,1)
+ endif
" refresh screen and return to saved position
NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
" s:NetrwHome: this function determines a "home" for saving bookmarks and history {{{2
fun! s:NetrwHome()
if exists("g:netrw_home")
- let home= g:netrw_home
+ let home= expand(g:netrw_home)
else
" go to vim plugin home
for home in split(&rtp,',') + ['']
endif
" insure that the home directory exists
if g:netrw_dirhistmax > 0 && !isdirectory(s:NetrwFile(home))
+" call Decho("insure that the home<".home."> directory exists")
if exists("g:netrw_mkdir")
+" call Decho("call system(".g:netrw_mkdir." ".s:ShellEscape(s:NetrwFile(home)).")")
call system(g:netrw_mkdir." ".s:ShellEscape(s:NetrwFile(home)))
else
+" call Decho("mkdir(".home.")")
call mkdir(home)
endif
endif
if exists("s:netrwdrag")
return
endif
+ if &ft != "netrw"
+ return
+ endif
" call Dfunc("s:NetrwLeftmouse(islocal=".a:islocal.")")
let ykeep= @@
" ---------------------------------------------------------------------
" s:NetrwCLeftmouse: used to select a file/directory for a target {{{2
fun! s:NetrwCLeftmouse(islocal)
+ if &ft != "netrw"
+ return
+ endif
" call Dfunc("s:NetrwCLeftmouse(islocal=".a:islocal.")")
call s:NetrwMarkFileTgt(a:islocal)
" call Dret("s:NetrwCLeftmouse")
" ---------------------------------------------------------------------
" s:NetrwServerEdit: edit file in a server gvim, usually NETRWSERVER (implements <c-r>){{{2
" a:islocal=0 : <c-r> not used, remote
-" a:islocal=1 : <c-r> no used, local
+" a:islocal=1 : <c-r> not used, local
" a:islocal=2 : <c-r> used, remote
" a:islocal=3 : <c-r> used, local
fun! s:NetrwServerEdit(islocal,fname)
" ---------------------------------------------------------------------
" s:NetrwSLeftmouse: marks the file under the cursor. May be dragged to select additional files {{{2
fun! s:NetrwSLeftmouse(islocal)
+ if &ft != "netrw"
+ return
+ endif
" call Dfunc("s:NetrwSLeftmouse(islocal=".a:islocal.")")
let s:ngw= s:NetrwGetWord()
" separated patterns given in g:netrw_list_hide
fun! s:NetrwListHide()
" call Dfunc("s:NetrwListHide() g:netrw_hide=".g:netrw_hide." g:netrw_list_hide<".g:netrw_list_hide.">")
+" call Decho("initial: ".string(getline(w:netrw_bannercnt,'$')))
let ykeep= @@
" find a character not in the "hide" string to use as a separator for :g and :v commands
let hide = listhide
let listhide = ""
endif
+" call Decho("hide<".hide."> listhide<".listhide.'>','~'.expand("<slnum>"))
" Prune the list by hiding any files which match
if g:netrw_hide == 1
-" call Decho("hiding<".hide."> listhide<".listhide.">",'~'.expand("<slnum>"))
+" call Decho("..hiding<".hide.">",'~'.expand("<slnum>"))
exe 'sil! NetrwKeepj '.w:netrw_bannercnt.',$g'.sep.hide.sep.'d'
elseif g:netrw_hide == 2
-" call Decho("showing<".hide."> listhide<".listhide.">",'~'.expand("<slnum>"))
+" call Decho("..showing<".hide.">",'~'.expand("<slnum>"))
exe 'sil! NetrwKeepj '.w:netrw_bannercnt.',$g'.sep.hide.sep.'s@^@ /-KEEP-/ @'
endif
+" call Decho("..result: ".string(getline(w:netrw_bannercnt,'$')),'~'.expand("<slnum>"))
endwhile
if g:netrw_hide == 2
exe 'sil! NetrwKeepj '.w:netrw_bannercnt.',$v@^ /-KEEP-/ @d'
+" call Decho("..v KEEP: ".string(getline(w:netrw_bannercnt,'$')),'~'.expand("<slnum>"))
exe 'sil! NetrwKeepj '.w:netrw_bannercnt.',$s@^\%( /-KEEP-/ \)\+@@e'
+" call Decho("..g KEEP: ".string(getline(w:netrw_bannercnt,'$')),'~'.expand("<slnum>"))
endif
" remove any blank lines that have somehow remained.
endif
else
let netrw_origdir= s:NetrwGetcwd(1)
- call s:NetrwLcd(b:netrw_curdir)
+ if s:NetrwLcd(b:netrw_curdir)
+" call Dret("s:NetrwMakeDir : lcd failure")
+ return
+ endif
" call Decho("netrw_origdir<".netrw_origdir.">: lcd b:netrw_curdir<".fnameescape(b:netrw_curdir).">",'~'.expand("<slnum>"))
- call s:NetrwExe("sil! !".g:netrw_localmkdir.' '.s:ShellEscape(newdirname,1))
+ call s:NetrwExe("sil! !".g:netrw_localmkdir.g:netrw_localmkdiropt.' '.s:ShellEscape(newdirname,1))
if v:shell_error != 0
let @@= ykeep
call netrw#ErrorMsg(s:ERROR,"consider setting g:netrw_localmkdir<".g:netrw_localmkdir."> to something that works",80)
endif
if !g:netrw_keepdir
" call Decho("restoring netrw_origdir since g:netrw_keepdir=".g:netrw_keepdir,'~'.expand("<slnum>"))
- call s:NetrwLcd(netrw_origdir)
+ if s:NetrwLcd(netrw_origdir)
+" call Dret("s:NetrwBrowse : lcd failure")
+ return
+ endif
endif
endif
fun! s:NetrwMaps(islocal)
" call Dfunc("s:NetrwMaps(islocal=".a:islocal.") b:netrw_curdir<".b:netrw_curdir.">")
+ " mouse <Plug> maps: {{{3
if g:netrw_mousemaps && g:netrw_retmap
" call Decho("set up Rexplore 2-leftmouse",'~'.expand("<slnum>"))
if !hasmapto("<Plug>NetrwReturn")
" call Decho("made <Plug>NetrwReturn map",'~'.expand("<slnum>"))
endif
+ " generate default <Plug> maps {{{3
+ if !hasmapto('<Plug>NetrwHide') |nmap <buffer> <silent> <nowait> a <Plug>NetrwHide_a|endif
+ if !hasmapto('<Plug>NetrwBrowseUpDir') |nmap <buffer> <silent> <nowait> - <Plug>NetrwBrowseUpDir |endif
+ if !hasmapto('<Plug>NetrwOpenFile') |nmap <buffer> <silent> <nowait> % <Plug>NetrwOpenFile|endif
+ if !hasmapto('<Plug>NetrwBadd_cb') |nmap <buffer> <silent> <nowait> cb <Plug>NetrwBadd_cb|endif
+ if !hasmapto('<Plug>NetrwBadd_cB') |nmap <buffer> <silent> <nowait> cB <Plug>NetrwBadd_cB|endif
+ if !hasmapto('<Plug>NetrwLcd') |nmap <buffer> <silent> <nowait> cd <Plug>NetrwLcd|endif
+ if !hasmapto('<Plug>NetrwSetChgwin') |nmap <buffer> <silent> <nowait> C <Plug>NetrwSetChgwin|endif
+ if !hasmapto('<Plug>NetrwRefresh') |nmap <buffer> <silent> <nowait> <c-l> <Plug>NetrwRefresh|endif
+ if !hasmapto('<Plug>NetrwLocalBrowseCheck') |nmap <buffer> <silent> <nowait> <cr> <Plug>NetrwLocalBrowseCheck|endif
+ if !hasmapto('<Plug>NetrwServerEdit') |nmap <buffer> <silent> <nowait> <c-r> <Plug>NetrwServerEdit|endif
+ if !hasmapto('<Plug>NetrwMakeDir') |nmap <buffer> <silent> <nowait> d <Plug>NetrwMakeDir|endif
+ if !hasmapto('<Plug>NetrwBookHistHandler_gb')|nmap <buffer> <silent> <nowait> gb <Plug>NetrwBookHistHandler_gb|endif
+" ---------------------------------------------------------------------
+" if !hasmapto('<Plug>NetrwForceChgDir') |nmap <buffer> <silent> <nowait> gd <Plug>NetrwForceChgDir|endif
+" if !hasmapto('<Plug>NetrwForceFile') |nmap <buffer> <silent> <nowait> gf <Plug>NetrwForceFile|endif
+" if !hasmapto('<Plug>NetrwHidden') |nmap <buffer> <silent> <nowait> gh <Plug>NetrwHidden|endif
+" if !hasmapto('<Plug>NetrwSetTreetop') |nmap <buffer> <silent> <nowait> gn <Plug>NetrwSetTreetop|endif
+" if !hasmapto('<Plug>NetrwChgPerm') |nmap <buffer> <silent> <nowait> gp <Plug>NetrwChgPerm|endif
+" if !hasmapto('<Plug>NetrwBannerCtrl') |nmap <buffer> <silent> <nowait> I <Plug>NetrwBannerCtrl|endif
+" if !hasmapto('<Plug>NetrwListStyle') |nmap <buffer> <silent> <nowait> i <Plug>NetrwListStyle|endif
+" if !hasmapto('<Plug>NetrwMarkMoveMF2Arglist')|nmap <buffer> <silent> <nowait> ma <Plug>NetrwMarkMoveMF2Arglist|endif
+" if !hasmapto('<Plug>NetrwMarkMoveArglist2MF')|nmap <buffer> <silent> <nowait> mA <Plug>NetrwMarkMoveArglist2MF|endif
+" if !hasmapto('<Plug>NetrwBookHistHandler_mA')|nmap <buffer> <silent> <nowait> mb <Plug>NetrwBookHistHandler_mA|endif
+" if !hasmapto('<Plug>NetrwBookHistHandler_mB')|nmap <buffer> <silent> <nowait> mB <Plug>NetrwBookHistHandler_mB|endif
+" if !hasmapto('<Plug>NetrwMarkFileCopy') |nmap <buffer> <silent> <nowait> mc <Plug>NetrwMarkFileCopy|endif
+" if !hasmapto('<Plug>NetrwMarkFileDiff') |nmap <buffer> <silent> <nowait> md <Plug>NetrwMarkFileDiff|endif
+" if !hasmapto('<Plug>NetrwMarkFileEdit') |nmap <buffer> <silent> <nowait> me <Plug>NetrwMarkFileEdit|endif
+" if !hasmapto('<Plug>NetrwMarkFile') |nmap <buffer> <silent> <nowait> mf <Plug>NetrwMarkFile|endif
+" if !hasmapto('<Plug>NetrwUnmarkList') |nmap <buffer> <silent> <nowait> mF <Plug>NetrwUnmarkList|endif
+" if !hasmapto('<Plug>NetrwMarkFileGrep') |nmap <buffer> <silent> <nowait> mg <Plug>NetrwMarkFileGrep|endif
+" if !hasmapto('<Plug>NetrwMarkHideSfx') |nmap <buffer> <silent> <nowait> mh <Plug>NetrwMarkHideSfx|endif
+" if !hasmapto('<Plug>NetrwMarkFileMove') |nmap <buffer> <silent> <nowait> mm <Plug>NetrwMarkFileMove|endif
+" if !hasmapto('<Plug>NetrwMarkFilePrint') |nmap <buffer> <silent> <nowait> mp <Plug>NetrwMarkFilePrint|endif
+" if !hasmapto('<Plug>NetrwMarkFileRegexp') |nmap <buffer> <silent> <nowait> mr <Plug>NetrwMarkFileRegexp|endif
+" if !hasmapto('<Plug>NetrwMarkFileSource') |nmap <buffer> <silent> <nowait> ms <Plug>NetrwMarkFileSource|endif
+" if !hasmapto('<Plug>NetrwMarkFileTag') |nmap <buffer> <silent> <nowait> mT <Plug>NetrwMarkFileTag|endif
+" if !hasmapto('<Plug>NetrwMarkFileTgt') |nmap <buffer> <silent> <nowait> mt <Plug>NetrwMarkFileTgt|endif
+" if !hasmapto('<Plug>NetrwUnMarkFile') |nmap <buffer> <silent> <nowait> mu <Plug>NetrwUnMarkFile|endif
+" if !hasmapto('<Plug>NetrwMarkFileVimCmd') |nmap <buffer> <silent> <nowait> mv <Plug>NetrwMarkFileVimCmd|endif
+" if !hasmapto('<Plug>NetrwMarkFileExe_mx') |nmap <buffer> <silent> <nowait> mx <Plug>NetrwMarkFileExe_mx|endif
+" if !hasmapto('<Plug>NetrwMarkFileExe_mX') |nmap <buffer> <silent> <nowait> mX <Plug>NetrwMarkFileExe_mX|endif
+" if !hasmapto('<Plug>NetrwMarkFileCompress') |nmap <buffer> <silent> <nowait> mz <Plug>NetrwMarkFileCompress|endif
+" if !hasmapto('<Plug>NetrwObtain') |nmap <buffer> <silent> <nowait> O <Plug>NetrwObtain|endif
+" if !hasmapto('<Plug>NetrwSplit_o') |nmap <buffer> <silent> <nowait> o <Plug>NetrwSplit_o|endif
+" if !hasmapto('<Plug>NetrwPreview') |nmap <buffer> <silent> <nowait> p <Plug>NetrwPreview|endif
+" if !hasmapto('<Plug>NetrwPrevWinOpen') |nmap <buffer> <silent> <nowait> P <Plug>NetrwPrevWinOpen|endif
+" if !hasmapto('<Plug>NetrwBookHistHandler_qb')|nmap <buffer> <silent> <nowait> qb <Plug>NetrwBookHistHandler_qb|endif
+" if !hasmapto('<Plug>NetrwFileInfo') |nmap <buffer> <silent> <nowait> qf <Plug>NetrwFileInfo|endif
+" if !hasmapto('<Plug>NetrwMarkFileQFEL_qF') |nmap <buffer> <silent> <nowait> qF <Plug>NetrwMarkFileQFEL_qF|endif
+" if !hasmapto('<Plug>NetrwMarkFileQFEL_qL') |nmap <buffer> <silent> <nowait> qL <Plug>NetrwMarkFileQFEL_qL|endif
+" if !hasmapto('<Plug>NetrwSortStyle') |nmap <buffer> <silent> <nowait> s <Plug>NetrwSortStyle|endif
+" if !hasmapto('<Plug>NetSortSequence') |nmap <buffer> <silent> <nowait> S <Plug>NetSortSequence|endif
+" if !hasmapto('<Plug>NetrwSetTgt_Tb') |nmap <buffer> <silent> <nowait> Tb <Plug>NetrwSetTgt_Tb|endif
+" if !hasmapto('<Plug>NetrwSetTgt_Th') |nmap <buffer> <silent> <nowait> Th <Plug>NetrwSetTgt_Th|endif
+" if !hasmapto('<Plug>NetrwSplit_t') |nmap <buffer> <silent> <nowait> t <Plug>NetrwSplit_t|endif
+" if !hasmapto('<Plug>NetrwBookHistHandler_u') |nmap <buffer> <silent> <nowait> u <Plug>NetrwBookHistHandler_u|endif
+" if !hasmapto('<Plug>NetrwBookHistHandler_U') |nmap <buffer> <silent> <nowait> U <Plug>NetrwBookHistHandler_U|endif
+" if !hasmapto('<Plug>NetrwSplit_v') |nmap <buffer> <silent> <nowait> v <Plug>NetrwSplit_v|endif
+" if !hasmapto('<Plug>NetrwBrowseX') |nmap <buffer> <silent> <nowait> x <Plug>NetrwBrowseX|endif
+" if !hasmapto('<Plug>NetrwLocalExecute') |nmap <buffer> <silent> <nowait> X <Plug>NetrwLocalExecute|endif
+
if a:islocal
" call Decho("make local maps",'~'.expand("<slnum>"))
- " local normal-mode maps
- nnoremap <buffer> <silent> <nowait> a :<c-u>call <SID>NetrwHide(1)<cr>
- nnoremap <buffer> <silent> <nowait> - :<c-u>call <SID>NetrwBrowseUpDir(1)<cr>
- nnoremap <buffer> <silent> <nowait> % :<c-u>call <SID>NetrwOpenFile(1)<cr>
- nnoremap <buffer> <silent> <nowait> c :<c-u>call <SID>NetrwLcd(b:netrw_curdir)<cr>
- nnoremap <buffer> <silent> <nowait> C :<c-u>call <SID>NetrwSetChgwin()<cr>
- nnoremap <buffer> <silent> <nowait> <cr> :<c-u>call netrw#LocalBrowseCheck(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord()))<cr>
- nnoremap <buffer> <silent> <nowait> <c-r> :<c-u>call <SID>NetrwServerEdit(3,<SID>NetrwGetWord())<cr>
- nnoremap <buffer> <silent> <nowait> d :<c-u>call <SID>NetrwMakeDir("")<cr>
- nnoremap <buffer> <silent> <nowait> gb :<c-u>call <SID>NetrwBookHistHandler(1,b:netrw_curdir)<cr>
+ " local normal-mode maps {{{3
+ nnoremap <buffer> <silent> <Plug>NetrwHide_a :<c-u>call <SID>NetrwHide(1)<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwBrowseUpDir :<c-u>call <SID>NetrwBrowseUpDir(1)<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwOpenFile :<c-u>call <SID>NetrwOpenFile(1)<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwBadd_cb :<c-u>call <SID>NetrwBadd(1,0)<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwBadd_cB :<c-u>call <SID>NetrwBadd(1,1)<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwLcd :<c-u>call <SID>NetrwLcd(b:netrw_curdir)<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwSetChgwin :<c-u>call <SID>NetrwSetChgwin()<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwLocalBrowseCheck :<c-u>call netrw#LocalBrowseCheck(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord()))<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwServerEdit :<c-u>call <SID>NetrwServerEdit(3,<SID>NetrwGetWord())<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwMakeDir :<c-u>call <SID>NetrwMakeDir("")<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwBookHistHandler_gb :<c-u>call <SID>NetrwBookHistHandler(1,b:netrw_curdir)<cr>
+" ---------------------------------------------------------------------
nnoremap <buffer> <silent> <nowait> gd :<c-u>call <SID>NetrwForceChgDir(1,<SID>NetrwGetWord())<cr>
nnoremap <buffer> <silent> <nowait> gf :<c-u>call <SID>NetrwForceFile(1,<SID>NetrwGetWord())<cr>
nnoremap <buffer> <silent> <nowait> gh :<c-u>call <SID>NetrwHidden(1)<cr>
- nnoremap <buffer> <silent> <nowait> gn :<c-u>call netrw#SetTreetop(<SID>NetrwGetWord())<cr>
+ nnoremap <buffer> <silent> <nowait> gn :<c-u>call netrw#SetTreetop(0,<SID>NetrwGetWord())<cr>
nnoremap <buffer> <silent> <nowait> gp :<c-u>call <SID>NetrwChgPerm(1,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> <nowait> I :<c-u>call <SID>NetrwBannerCtrl(1)<cr>
nnoremap <buffer> <silent> <nowait> i :<c-u>call <SID>NetrwListStyle(1)<cr>
nnoremap <buffer> <silent> <nowait> qf :<c-u>call <SID>NetrwFileInfo(1,<SID>NetrwGetWord())<cr>
nnoremap <buffer> <silent> <nowait> qF :<c-u>call <SID>NetrwMarkFileQFEL(1,getqflist())<cr>
nnoremap <buffer> <silent> <nowait> qL :<c-u>call <SID>NetrwMarkFileQFEL(1,getloclist(v:count))<cr>
- nnoremap <buffer> <silent> <nowait> r :<c-u>let g:netrw_sort_direction= (g:netrw_sort_direction =~# 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetrwRefresh(1,<SID>NetrwBrowseChgDir(1,'./'))<cr>
nnoremap <buffer> <silent> <nowait> s :call <SID>NetrwSortStyle(1)<cr>
nnoremap <buffer> <silent> <nowait> S :<c-u>call <SID>NetSortSequence(1)<cr>
nnoremap <buffer> <silent> <nowait> Tb :<c-u>call <SID>NetrwSetTgt(1,'b',v:count1)<cr>
nnoremap <buffer> <silent> <nowait> v :call <SID>NetrwSplit(5)<cr>
nnoremap <buffer> <silent> <nowait> x :<c-u>call netrw#BrowseX(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),0),0)"<cr>
nnoremap <buffer> <silent> <nowait> X :<c-u>call <SID>NetrwLocalExecute(expand("<cword>"))"<cr>
-" " local insert-mode maps
-" inoremap <buffer> <silent> <nowait> a <c-o>:call <SID>NetrwHide(1)<cr>
-" inoremap <buffer> <silent> <nowait> c <c-o>:exe "NetrwKeepj lcd ".fnameescape(b:netrw_curdir)<cr>
-" inoremap <buffer> <silent> <nowait> c <c-o>:call <SID>NetrwLcd(b:netrw_curdir)<cr>
-" inoremap <buffer> <silent> <nowait> C <c-o>:call <SID>NetrwSetChgwin()<cr>
-" inoremap <buffer> <silent> <nowait> % <c-o>:call <SID>NetrwOpenFile(1)<cr>
-" inoremap <buffer> <silent> <nowait> - <c-o>:call <SID>NetrwBrowseUpDir(1)<cr>
-" inoremap <buffer> <silent> <nowait> <cr> <c-o>:call netrw#LocalBrowseCheck(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord()))<cr>
-" inoremap <buffer> <silent> <nowait> d <c-o>:call <SID>NetrwMakeDir("")<cr>
-" inoremap <buffer> <silent> <nowait> gb <c-o>:<c-u>call <SID>NetrwBookHistHandler(1,b:netrw_curdir)<cr>
-" inoremap <buffer> <silent> <nowait> gh <c-o>:<c-u>call <SID>NetrwHidden(1)<cr>
-" nnoremap <buffer> <silent> <nowait> gn :<c-u>call netrw#SetTreetop(<SID>NetrwGetWord())<cr>
-" inoremap <buffer> <silent> <nowait> gp <c-o>:<c-u>call <SID>NetrwChgPerm(1,b:netrw_curdir)<cr>
-" inoremap <buffer> <silent> <nowait> I <c-o>:call <SID>NetrwBannerCtrl(1)<cr>
-" inoremap <buffer> <silent> <nowait> i <c-o>:call <SID>NetrwListStyle(1)<cr>
-" inoremap <buffer> <silent> <nowait> mb <c-o>:<c-u>call <SID>NetrwBookHistHandler(0,b:netrw_curdir)<cr>
-" inoremap <buffer> <silent> <nowait> mB <c-o>:<c-u>call <SID>NetrwBookHistHandler(6,b:netrw_curdir)<cr>
-" inoremap <buffer> <silent> <nowait> mc <c-o>:<c-u>call <SID>NetrwMarkFileCopy(1)<cr>
-" inoremap <buffer> <silent> <nowait> md <c-o>:<c-u>call <SID>NetrwMarkFileDiff(1)<cr>
-" inoremap <buffer> <silent> <nowait> me <c-o>:<c-u>call <SID>NetrwMarkFileEdit(1)<cr>
-" inoremap <buffer> <silent> <nowait> mf <c-o>:<c-u>call <SID>NetrwMarkFile(1,<SID>NetrwGetWord())<cr>
-" inoremap <buffer> <silent> <nowait> mg <c-o>:<c-u>call <SID>NetrwMarkFileGrep(1)<cr>
-" inoremap <buffer> <silent> <nowait> mh <c-o>:<c-u>call <SID>NetrwMarkHideSfx(1)<cr>
-" inoremap <buffer> <silent> <nowait> mm <c-o>:<c-u>call <SID>NetrwMarkFileMove(1)<cr>
-" inoremap <buffer> <silent> <nowait> mp <c-o>:<c-u>call <SID>NetrwMarkFilePrint(1)<cr>
-" inoremap <buffer> <silent> <nowait> mr <c-o>:<c-u>call <SID>NetrwMarkFileRegexp(1)<cr>
-" inoremap <buffer> <silent> <nowait> ms <c-o>:<c-u>call <SID>NetrwMarkFileSource(1)<cr>
-" inoremap <buffer> <silent> <nowait> mT <c-o>:<c-u>call <SID>NetrwMarkFileTag(1)<cr>
-" inoremap <buffer> <silent> <nowait> mt <c-o>:<c-u>call <SID>NetrwMarkFileTgt(1)<cr>
-" inoremap <buffer> <silent> <nowait> mu <c-o>:<c-u>call <SID>NetrwUnMarkFile(1)<cr>
-" inoremap <buffer> <silent> <nowait> mv <c-o>:<c-u>call <SID>NetrwMarkFileVimCmd(1)<cr>
-" inoremap <buffer> <silent> <nowait> mx <c-o>:<c-u>call <SID>NetrwMarkFileExe(1,0)<cr>
-" inoremap <buffer> <silent> <nowait> mX <c-o>:<c-u>call <SID>NetrwMarkFileExe(1,1)<cr>
-" inoremap <buffer> <silent> <nowait> mz <c-o>:<c-u>call <SID>NetrwMarkFileCompress(1)<cr>
-" inoremap <buffer> <silent> <nowait> O <c-o>:call <SID>NetrwObtain(1)<cr>
-" inoremap <buffer> <silent> <nowait> o <c-o>:call <SID>NetrwSplit(3)<cr>
-" inoremap <buffer> <silent> <nowait> p <c-o>:call <SID>NetrwPreview(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),1))<cr>
-" inoremap <buffer> <silent> <nowait> P <c-o>:call <SID>NetrwPrevWinOpen(1)<cr>
-" inoremap <buffer> <silent> <nowait> qb <c-o>:<c-u>call <SID>NetrwBookHistHandler(2,b:netrw_curdir)<cr>
-" inoremap <buffer> <silent> <nowait> qf <c-o>:<c-u>call <SID>NetrwFileInfo(1,<SID>NetrwGetWord())<cr>
-" inoremap <buffer> <silent> <nowait> qF :<c-u>call <SID>NetrwMarkFileQFEL(1,getqflist())<cr>
-" inoremap <buffer> <silent> <nowait> qL :<c-u>call <SID>NetrwMarkFileQFEL(1,getloclist(v:count))<cr>
-" inoremap <buffer> <silent> <nowait> r <c-o>:let g:netrw_sort_direction= (g:netrw_sort_direction =~# 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetrwRefresh(1,<SID>NetrwBrowseChgDir(1,'./'))<cr>
-" inoremap <buffer> <silent> <nowait> s <c-o>:call <SID>NetrwSortStyle(1)<cr>
-" inoremap <buffer> <silent> <nowait> S <c-o>:call <SID>NetSortSequence(1)<cr>
-" inoremap <buffer> <silent> <nowait> t <c-o>:call <SID>NetrwSplit(4)<cr>
-" inoremap <buffer> <silent> <nowait> Tb <c-o>:<c-u>call <SID>NetrwSetTgt(1,'b',v:count1)<cr>
-" inoremap <buffer> <silent> <nowait> Th <c-o>:<c-u>call <SID>NetrwSetTgt(1,'h',v:count)<cr>
-" inoremap <buffer> <silent> <nowait> u <c-o>:<c-u>call <SID>NetrwBookHistHandler(4,expand("%"))<cr>
-" inoremap <buffer> <silent> <nowait> U <c-o>:<c-u>call <SID>NetrwBookHistHandler(5,expand("%"))<cr>
-" inoremap <buffer> <silent> <nowait> v <c-o>:call <SID>NetrwSplit(5)<cr>
-" inoremap <buffer> <silent> <nowait> x <c-o>:call netrw#BrowseX(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),0),0)"<cr>
+
+ nnoremap <buffer> <silent> <nowait> r :<c-u>let g:netrw_sort_direction= (g:netrw_sort_direction =~# 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetrwRefresh(1,<SID>NetrwBrowseChgDir(1,'./'))<cr>
if !hasmapto('<Plug>NetrwHideEdit')
nmap <buffer> <unique> <c-h> <Plug>NetrwHideEdit
-" imap <buffer> <unique> <c-h> <c-o><Plug>NetrwHideEdit
endif
nnoremap <buffer> <silent> <Plug>NetrwHideEdit :call <SID>NetrwHideEdit(1)<cr>
if !hasmapto('<Plug>NetrwRefresh')
nmap <buffer> <unique> <c-l> <Plug>NetrwRefresh
-" imap <buffer> <unique> <c-l> <c-o><Plug>NetrwRefresh
endif
nnoremap <buffer> <silent> <Plug>NetrwRefresh <c-l>:call <SID>NetrwRefresh(1,<SID>NetrwBrowseChgDir(1,(w:netrw_liststyle == 3)? w:netrw_treetop : './'))<cr>
if s:didstarstar || !mapcheck("<s-down>","n")
nnoremap <buffer> <silent> <s-down> :Nexplore<cr>
-" inoremap <buffer> <silent> <s-down> <c-o>:Nexplore<cr>
endif
if s:didstarstar || !mapcheck("<s-up>","n")
nnoremap <buffer> <silent> <s-up> :Pexplore<cr>
-" inoremap <buffer> <silent> <s-up> <c-o>:Pexplore<cr>
endif
if !hasmapto('<Plug>NetrwTreeSqueeze')
nmap <buffer> <silent> <nowait> <s-cr> <Plug>NetrwTreeSqueeze
-" imap <buffer> <silent> <nowait> <s-cr> <c-o><Plug>NetrwTreeSqueeze
endif
nnoremap <buffer> <silent> <Plug>NetrwTreeSqueeze :call <SID>TreeSqueezeDir(1)<cr>
let mapsafecurdir = escape(b:netrw_curdir, s:netrw_map_escape)
if g:netrw_mousemaps == 1
- nmap <buffer> <leftmouse> <Plug>NetrwLeftmouse
+ nmap <buffer> <leftmouse> <Plug>NetrwLeftmouse
+ nmap <buffer> <c-leftmouse> <Plug>NetrwCLeftmouse
+ nmap <buffer> <middlemouse> <Plug>NetrwMiddlemouse
+ nmap <buffer> <s-leftmouse> <Plug>NetrwSLeftmouse
+ nmap <buffer> <s-leftdrag> <Plug>NetrwSLeftdrag
+ nmap <buffer> <2-leftmouse> <Plug>Netrw2Leftmouse
+ imap <buffer> <leftmouse> <Plug>ILeftmouse
+ imap <buffer> <middlemouse> <Plug>IMiddlemouse
nno <buffer> <silent> <Plug>NetrwLeftmouse <leftmouse>:call <SID>NetrwLeftmouse(1)<cr>
- nmap <buffer> <c-leftmouse> <Plug>NetrwCLeftmouse
nno <buffer> <silent> <Plug>NetrwCLeftmouse <leftmouse>:call <SID>NetrwCLeftmouse(1)<cr>
- nmap <buffer> <middlemouse> <Plug>NetrwMiddlemouse
nno <buffer> <silent> <Plug>NetrwMiddlemouse <leftmouse>:call <SID>NetrwPrevWinOpen(1)<cr>
- nmap <buffer> <s-leftmouse> <Plug>NetrwSLeftmouse
nno <buffer> <silent> <Plug>NetrwSLeftmouse <leftmouse>:call <SID>NetrwSLeftmouse(1)<cr>
- nmap <buffer> <s-leftdrag> <Plug>NetrwSLeftdrag
nno <buffer> <silent> <Plug>NetrwSLeftdrag <leftmouse>:call <SID>NetrwSLeftdrag(1)<cr>
- nmap <buffer> <2-leftmouse> <Plug>Netrw2Leftmouse
nmap <buffer> <silent> <Plug>Netrw2Leftmouse -
- imap <buffer> <leftmouse> <Plug>ILeftmouse
-" ino <buffer> <silent> <Plug>ILeftmouse <c-o><leftmouse><c-o>:call <SID>NetrwLeftmouse(1)<cr>
- imap <buffer> <middlemouse> <Plug>IMiddlemouse
-" ino <buffer> <silent> <Plug>IMiddlemouse <c-o><leftmouse><c-o>:call <SID>NetrwPrevWinOpen(1)<cr>
-" imap <buffer> <s-leftmouse> <Plug>ISLeftmouse
-" ino <buffer> <silent> <Plug>ISLeftmouse <c-o><leftmouse><c-o>:call <SID>NetrwMarkFile(1,<SID>NetrwGetWord())<cr>
exe 'nnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
exe 'vnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
-" exe 'inoremap <buffer> <silent> <rightmouse> <c-o><leftmouse><c-o>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
endif
exe 'nnoremap <buffer> <silent> <nowait> <del> :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
exe 'nnoremap <buffer> <silent> <nowait> D :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
exe 'vnoremap <buffer> <silent> <nowait> <del> :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
exe 'vnoremap <buffer> <silent> <nowait> D :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
exe 'vnoremap <buffer> <silent> <nowait> R :call <SID>NetrwLocalRename("'.mapsafecurdir.'")<cr>'
-" exe 'inoremap <buffer> <silent> <nowait> <del> <c-o>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
-" exe 'inoremap <buffer> <silent> <nowait> D <c-o>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
-" exe 'inoremap <buffer> <silent> <nowait> R <c-o>:call <SID>NetrwLocalRename("'.mapsafecurdir.'")<cr>'
-" exe 'inoremap <buffer> <silent> <nowait> d <c-o>:call <SID>NetrwMakeDir("")<cr>'
nnoremap <buffer> <F1> :he netrw-quickhelp<cr>
" support user-specified maps
call netrw#UserMaps(1)
- else " remote
+ else
+ " remote normal-mode maps {{{3
" call Decho("make remote maps",'~'.expand("<slnum>"))
call s:RemotePathAnalysis(b:netrw_curdir)
- " remote normal-mode maps
- nnoremap <buffer> <silent> <nowait> a :<c-u>call <SID>NetrwHide(0)<cr>
- nnoremap <buffer> <silent> <nowait> - :<c-u>call <SID>NetrwBrowseUpDir(0)<cr>
- nnoremap <buffer> <silent> <nowait> % :<c-u>call <SID>NetrwOpenFile(0)<cr>
- nnoremap <buffer> <silent> <nowait> C :<c-u>call <SID>NetrwSetChgwin()<cr>
- nnoremap <buffer> <silent> <nowait> <c-l> :<c-u>call <SID>NetrwRefresh(0,<SID>NetrwBrowseChgDir(0,'./'))<cr>
- nnoremap <buffer> <silent> <nowait> <cr> :<c-u>call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,<SID>NetrwGetWord()))<cr>
- nnoremap <buffer> <silent> <nowait> <c-r> :<c-u>call <SID>NetrwServerEdit(2,<SID>NetrwGetWord())<cr>
- nnoremap <buffer> <silent> <nowait> gb :<c-u>call <SID>NetrwBookHistHandler(1,b:netrw_curdir)<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwHide_a :<c-u>call <SID>NetrwHide(0)<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwBrowseUpDir :<c-u>call <SID>NetrwBrowseUpDir(0)<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwOpenFile :<c-u>call <SID>NetrwOpenFile(0)<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwBadd_cb :<c-u>call <SID>NetrwBadd(0,0)<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwBadd_cB :<c-u>call <SID>NetrwBadd(0,1)<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwLcd :<c-u>call <SID>NetrwLcd(b:netrw_curdir)<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwSetChgwin :<c-u>call <SID>NetrwSetChgwin()<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwRefresh :<c-u>call <SID>NetrwRefresh(0,<SID>NetrwBrowseChgDir(0,'./'))<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwLocalBrowseCheck :<c-u>call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,<SID>NetrwGetWord()))<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwServerEdit :<c-u>call <SID>NetrwServerEdit(2,<SID>NetrwGetWord())<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwBookHistHandler_gb :<c-u>call <SID>NetrwBookHistHandler(1,b:netrw_curdir)<cr>
+" ---------------------------------------------------------------------
nnoremap <buffer> <silent> <nowait> gd :<c-u>call <SID>NetrwForceChgDir(0,<SID>NetrwGetWord())<cr>
nnoremap <buffer> <silent> <nowait> gf :<c-u>call <SID>NetrwForceFile(0,<SID>NetrwGetWord())<cr>
nnoremap <buffer> <silent> <nowait> gh :<c-u>call <SID>NetrwHidden(0)<cr>
nnoremap <buffer> <silent> <nowait> U :<c-u>call <SID>NetrwBookHistHandler(5,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> <nowait> v :call <SID>NetrwSplit(2)<cr>
nnoremap <buffer> <silent> <nowait> x :<c-u>call netrw#BrowseX(<SID>NetrwBrowseChgDir(0,<SID>NetrwGetWord()),1)<cr>
-" " remote insert-mode maps
-" inoremap <buffer> <silent> <nowait> <cr> <c-o>:call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,<SID>NetrwGetWord()))<cr>
-" inoremap <buffer> <silent> <nowait> <c-l> <c-o>:call <SID>NetrwRefresh(0,<SID>NetrwBrowseChgDir(0,'./'))<cr>
-" inoremap <buffer> <silent> <nowait> <s-cr> <c-o>:call <SID>TreeSqueezeDir(0)<cr>
-" inoremap <buffer> <silent> <nowait> - <c-o>:call <SID>NetrwBrowseUpDir(0)<cr>
-" inoremap <buffer> <silent> <nowait> a <c-o>:call <SID>NetrwHide(0)<cr>
-" inoremap <buffer> <silent> <nowait> mb <c-o>:<c-u>call <SID>NetrwBookHistHandler(0,b:netrw_curdir)<cr>
-" inoremap <buffer> <silent> <nowait> mc <c-o>:<c-u>call <SID>NetrwMarkFileCopy(0)<cr>
-" inoremap <buffer> <silent> <nowait> md <c-o>:<c-u>call <SID>NetrwMarkFileDiff(0)<cr>
-" inoremap <buffer> <silent> <nowait> me <c-o>:<c-u>call <SID>NetrwMarkFileEdit(0)<cr>
-" inoremap <buffer> <silent> <nowait> mf <c-o>:<c-u>call <SID>NetrwMarkFile(0,<SID>NetrwGetWord())<cr>
-" inoremap <buffer> <silent> <nowait> mg <c-o>:<c-u>call <SID>NetrwMarkFileGrep(0)<cr>
-" inoremap <buffer> <silent> <nowait> mh <c-o>:<c-u>call <SID>NetrwMarkHideSfx(0)<cr>
-" inoremap <buffer> <silent> <nowait> mm <c-o>:<c-u>call <SID>NetrwMarkFileMove(0)<cr>
-" inoremap <buffer> <silent> <nowait> mp <c-o>:<c-u>call <SID>NetrwMarkFilePrint(0)<cr>
-" inoremap <buffer> <silent> <nowait> mr <c-o>:<c-u>call <SID>NetrwMarkFileRegexp(0)<cr>
-" inoremap <buffer> <silent> <nowait> ms <c-o>:<c-u>call <SID>NetrwMarkFileSource(0)<cr>
-" inoremap <buffer> <silent> <nowait> mt <c-o>:<c-u>call <SID>NetrwMarkFileTgt(0)<cr>
-" inoremap <buffer> <silent> <nowait> mT <c-o>:<c-u>call <SID>NetrwMarkFileTag(0)<cr>
-" inoremap <buffer> <silent> <nowait> mu <c-o>:<c-u>call <SID>NetrwUnMarkFile(0)<cr>
-" nnoremap <buffer> <silent> <nowait> mv :<c-u>call <SID>NetrwMarkFileVimCmd(1)<cr>
-" inoremap <buffer> <silent> <nowait> mx <c-o>:<c-u>call <SID>NetrwMarkFileExe(0,0)<cr>
-" inoremap <buffer> <silent> <nowait> mX <c-o>:<c-u>call <SID>NetrwMarkFileExe(0,1)<cr>
-" inoremap <buffer> <silent> <nowait> mv <c-o>:<c-u>call <SID>NetrwMarkFileVimCmd(0)<cr>
-" inoremap <buffer> <silent> <nowait> mz <c-o>:<c-u>call <SID>NetrwMarkFileCompress(0)<cr>
-" inoremap <buffer> <silent> <nowait> gb <c-o>:<c-u>call <SID>NetrwBookHistHandler(1,b:netrw_curdir)<cr>
-" inoremap <buffer> <silent> <nowait> gh <c-o>:<c-u>call <SID>NetrwHidden(0)<cr>
-" inoremap <buffer> <silent> <nowait> gp <c-o>:<c-u>call <SID>NetrwChgPerm(0,b:netrw_curdir)<cr>
-" inoremap <buffer> <silent> <nowait> C <c-o>:call <SID>NetrwSetChgwin()<cr>
-" inoremap <buffer> <silent> <nowait> i <c-o>:call <SID>NetrwListStyle(0)<cr>
-" inoremap <buffer> <silent> <nowait> I <c-o>:call <SID>NetrwBannerCtrl(1)<cr>
-" inoremap <buffer> <silent> <nowait> o <c-o>:call <SID>NetrwSplit(0)<cr>
-" inoremap <buffer> <silent> <nowait> O <c-o>:call <SID>NetrwObtain(0)<cr>
-" inoremap <buffer> <silent> <nowait> p <c-o>:call <SID>NetrwPreview(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),1))<cr>
-" inoremap <buffer> <silent> <nowait> P <c-o>:call <SID>NetrwPrevWinOpen(0)<cr>
-" inoremap <buffer> <silent> <nowait> qb <c-o>:<c-u>call <SID>NetrwBookHistHandler(2,b:netrw_curdir)<cr>
-" inoremap <buffer> <silent> <nowait> mB <c-o>:<c-u>call <SID>NetrwBookHistHandler(6,b:netrw_curdir)<cr>
-" inoremap <buffer> <silent> <nowait> qf <c-o>:<c-u>call <SID>NetrwFileInfo(0,<SID>NetrwGetWord())<cr>
-" inoremap <buffer> <silent> <nowait> qF :<c-u>call <SID>NetrwMarkFileQFEL(0,getqflist())<cr>
-" inoremap <buffer> <silent> <nowait> qL :<c-u>call <SID>NetrwMarkFileQFEL(0,getloclist(v:count))<cr>
-" inoremap <buffer> <silent> <nowait> r <c-o>:let g:netrw_sort_direction= (g:netrw_sort_direction =~# 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,'./'))<cr>
-" inoremap <buffer> <silent> <nowait> s <c-o>:call <SID>NetrwSortStyle(0)<cr>
-" inoremap <buffer> <silent> <nowait> S <c-o>:call <SID>NetSortSequence(0)<cr>
-" inoremap <buffer> <silent> <nowait> t <c-o>:call <SID>NetrwSplit(1)<cr>
-" inoremap <buffer> <silent> <nowait> Tb <c-o>:<c-u>call <SID>NetrwSetTgt('b',v:count1)<cr>
-" inoremap <buffer> <silent> <nowait> Th <c-o>:<c-u>call <SID>NetrwSetTgt('h',v:count)<cr>
-" inoremap <buffer> <silent> <nowait> u <c-o>:<c-u>call <SID>NetrwBookHistHandler(4,b:netrw_curdir)<cr>
-" inoremap <buffer> <silent> <nowait> U <c-o>:<c-u>call <SID>NetrwBookHistHandler(5,b:netrw_curdir)<cr>
-" inoremap <buffer> <silent> <nowait> v <c-o>:call <SID>NetrwSplit(2)<cr>
-" inoremap <buffer> <silent> <nowait> x <c-o>:call netrw#BrowseX(<SID>NetrwBrowseChgDir(0,<SID>NetrwGetWord()),1)<cr>
-" inoremap <buffer> <silent> <nowait> % <c-o>:call <SID>NetrwOpenFile(0)<cr>
if !hasmapto('<Plug>NetrwHideEdit')
nmap <buffer> <c-h> <Plug>NetrwHideEdit
-" imap <buffer> <c-h> <Plug>NetrwHideEdit
endif
nnoremap <buffer> <silent> <Plug>NetrwHideEdit :call <SID>NetrwHideEdit(0)<cr>
if !hasmapto('<Plug>NetrwRefresh')
nmap <buffer> <c-l> <Plug>NetrwRefresh
-" imap <buffer> <c-l> <Plug>NetrwRefresh
endif
if !hasmapto('<Plug>NetrwTreeSqueeze')
nmap <buffer> <silent> <nowait> <s-cr> <Plug>NetrwTreeSqueeze
-" imap <buffer> <silent> <nowait> <s-cr> <c-o><Plug>NetrwTreeSqueeze
endif
nnoremap <buffer> <silent> <Plug>NetrwTreeSqueeze :call <SID>TreeSqueezeDir(0)<cr>
nmap <buffer> <2-leftmouse> <Plug>Netrw2Leftmouse
nmap <buffer> <silent> <Plug>Netrw2Leftmouse -
imap <buffer> <leftmouse> <Plug>ILeftmouse
-" ino <buffer> <silent> <Plug>ILeftmouse <c-o><leftmouse><c-o>:call <SID>NetrwLeftmouse(0)<cr>
imap <buffer> <middlemouse> <Plug>IMiddlemouse
-" ino <buffer> <silent> <Plug>IMiddlemouse <c-o><leftmouse><c-o>:call <SID>NetrwPrevWinOpen(0)<cr>
imap <buffer> <s-leftmouse> <Plug>ISLeftmouse
-" ino <buffer> <silent> <Plug>ISLeftmouse <c-o><leftmouse><c-o>:call <SID>NetrwMarkFile(0,<SID>NetrwGetWord())<cr>
exe 'nnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
exe 'vnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
-" exe 'inoremap <buffer> <silent> <rightmouse> <c-o><leftmouse><c-o>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
endif
exe 'nnoremap <buffer> <silent> <nowait> <del> :call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
exe 'nnoremap <buffer> <silent> <nowait> d :call <SID>NetrwMakeDir("'.mapsafeusermach.'")<cr>'
exe 'vnoremap <buffer> <silent> <nowait> <del> :call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
exe 'vnoremap <buffer> <silent> <nowait> D :call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
exe 'vnoremap <buffer> <silent> <nowait> R :call <SID>NetrwRemoteRename("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
-" exe 'inoremap <buffer> <silent> <nowait> <del> <c-o>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
-" exe 'inoremap <buffer> <silent> <nowait> d <c-o>:call <SID>NetrwMakeDir("'.mapsafeusermach.'")<cr>'
-" exe 'inoremap <buffer> <silent> <nowait> D <c-o>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
-" exe 'inoremap <buffer> <silent> <nowait> R <c-o>:call <SID>NetrwRemoteRename("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
nnoremap <buffer> <F1> :he netrw-quickhelp<cr>
-" inoremap <buffer> <F1> <c-o>:he netrw-quickhelp<cr>
" support user-specified maps
call netrw#UserMaps(0)
- endif
+ endif " }}}3
" call Dret("s:NetrwMaps")
endfun
endif
" set up 2match'ing to netrwmarkfilemtch_# list
- if exists("s:netrwmarkfilemtch_{curbufnr}") && s:netrwmarkfilemtch_{curbufnr} != ""
-" call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{curbufnr}."/",'~'.expand("<slnum>"))
- if exists("g:did_drchip_netrwlist_syntax")
- exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{curbufnr}."/"
+ if has("syntax") && exists("g:syntax_on") && g:syntax_on
+ if exists("s:netrwmarkfilemtch_{curbufnr}") && s:netrwmarkfilemtch_{curbufnr} != ""
+" " call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{curbufnr}."/",'~'.expand("<slnum>"))
+ if exists("g:did_drchip_netrwlist_syntax")
+ exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{curbufnr}."/"
+ endif
+ else
+" " call Decho("2match none",'~'.expand("<slnum>"))
+ 2match none
endif
- else
-" call Decho("2match none",'~'.expand("<slnum>"))
- 2match none
endif
let @@= ykeep
" call Dret("s:NetrwMarkFile : s:netrwmarkfilelist_".curbufnr."<".(exists("s:netrwmarkfilelist_{curbufnr}")? string(s:netrwmarkfilelist_{curbufnr}) : " doesn't exist").">")
if g:netrw_keepdir
let fname= s:ShellEscape(s:ComposePath(curdir,fname))
endif
- else
- let fname= s:ShellEscape(b:netrw_curdir.fname,1)
- endif
- if executable(exe)
- if a:islocal
- call system(exe." ".fname)
- else
- NetrwKeepj call s:RemoteSystem(exe." ".fname)
+ call system(exe." ".fname)
+ if v:shell_error
+ NetrwKeepj call netrw#ErrorMsg(s:WARNING,"unable to apply<".exe."> to file<".fname.">",50)
endif
else
- NetrwKeepj call netrw#ErrorMsg(s:WARNING,"unable to apply<".exe."> to file<".fname.">",50)
+ let fname= s:ShellEscape(b:netrw_curdir.fname,1)
+ NetrwKeepj call s:RemoteSystem(exe." ".fname)
endif
+
endif
unlet sfx
elseif a:islocal
" fname not a compressed file, so compress it
call system(netrw#WinPath(g:netrw_compress)." ".s:ShellEscape(s:ComposePath(b:netrw_curdir,fname)))
+ if v:shell_error
+ call netrw#ErrorMsg(s:WARNING,"consider setting g:netrw_compress<".g:netrw_compress."> to something that works",104)
+ endif
else
" fname not a compressed file, so compress it
NetrwKeepj call s:RemoteSystem(netrw#WinPath(g:netrw_compress)." ".s:ShellEscape(fname))
if a:islocal && s:netrwmftgt_islocal
" Copy marked files, local directory to local directory
" call Decho("copy from local to local",'~'.expand("<slnum>"))
- if !executable(g:netrw_localcopycmd) && g:netrw_localcopycmd !~ '^'.expand("$COMSPEC").'\s'
+ if !executable(g:netrw_localcopycmd)
call netrw#ErrorMsg(s:ERROR,"g:netrw_localcopycmd<".g:netrw_localcopycmd."> not executable on your system, aborting",91)
" call Dfunc("s:NetrwMarkFileMove : g:netrw_localcopycmd<".g:netrw_localcopycmd."> n/a!")
return
" call Decho("tgt <".tgt.">",'~'.expand("<slnum>"))
" call Decho("copycmd<".copycmd.">",'~'.expand("<slnum>"))
" call Decho("system(".copycmd." '".args."' '".tgt."')",'~'.expand("<slnum>"))
- call system(copycmd." '".args."' '".tgt."'")
+ call system(copycmd.g:netrw_localcopycmdopt." '".args."' '".tgt."'")
if v:shell_error != 0
if exists("b:netrw_curdir") && b:netrw_curdir != getcwd() && !g:netrw_keepdir
call netrw#ErrorMsg(s:ERROR,"copy failed; perhaps due to vim's current directory<".getcwd()."> not matching netrw's (".b:netrw_curdir.") (see :help netrw-c)",101)
if exists("*mkdir")
call mkdir(tmpdir)
else
- call s:NetrwExe("sil! !".g:netrw_localmkdir.' '.s:ShellEscape(tmpdir,1))
+ call s:NetrwExe("sil! !".g:netrw_localmkdir.g:netrw_localmkdiropt.' '.s:ShellEscape(tmpdir,1))
if v:shell_error != 0
call netrw#ErrorMsg(s:WARNING,"consider setting g:netrw_localmkdir<".g:netrw_localmkdir."> to something that works",80)
" call Dret("s:NetrwMarkFileCopy : failed: sil! !".g:netrw_localmkdir.' '.s:ShellEscape(tmpdir,1) )
endif
endif
if isdirectory(s:NetrwFile(tmpdir))
- call s:NetrwLcd(tmpdir)
+ if s:NetrwLcd(tmpdir)
+" call Dret("s:NetrwMarkFileCopy : lcd failure")
+ return
+ endif
NetrwKeepj call netrw#Obtain(a:islocal,s:netrwmarkfilelist_{bufnr('%')},tmpdir)
let localfiles= map(deepcopy(s:netrwmarkfilelist_{bufnr('%')}),'substitute(v:val,"^.*/","","")')
NetrwKeepj call s:NetrwUpload(localfiles,s:netrwmftgt)
for fname in s:netrwmarkfilelist_{bufnr('%')}
NetrwKeepj call s:NetrwDelete(fname)
endfor
- call s:NetrwLcd(curdir)
- if v:version < 704 || !has("patch1109")
- call s:NetrwExe("sil !".g:netrw_localrmdir." ".s:ShellEscape(tmpdir,1))
+ if s:NetrwLcd(curdir)
+" call Dret("s:NetrwMarkFileCopy : lcd failure")
+ return
+ endif
+ if v:version < 704 || (v:version == 704 && !has("patch1107"))
+ call s:NetrwExe("sil !".g:netrw_localrmdir.g:netrw_localrmdiropt." ".s:ShellEscape(tmpdir,1))
if v:shell_error != 0
call netrw#ErrorMsg(s:WARNING,"consider setting g:netrw_localrmdir<".g:netrw_localrmdir."> to something that works",80)
" " call Dret("s:NetrwMarkFileCopy : failed: sil !".g:netrw_localrmdir." ".s:ShellEscape(tmpdir,1) )
endif
endif
else
- call s:NetrwLcd(curdir)
+ if s:NetrwLcd(curdir)
+" call Dret("s:NetrwMarkFileCopy : lcd failure")
+ return
+ endif
endif
endif
endif
" move: local -> local
" call Decho("move from local to local",'~'.expand("<slnum>"))
" call Decho("local to local move",'~'.expand("<slnum>"))
- if !executable(g:netrw_localmovecmd) && g:netrw_localmovecmd !~ '^'.expand("$COMSPEC").'\s'
+ if !executable(g:netrw_localmovecmd)
call netrw#ErrorMsg(s:ERROR,"g:netrw_localmovecmd<".g:netrw_localmovecmd."> not executable on your system, aborting",90)
" call Dfunc("s:NetrwMarkFileMove : g:netrw_localmovecmd<".g:netrw_localmovecmd."> n/a!")
return
endif
- let tgt = s:ShellEscape(s:netrwmftgt)
+ let tgt = s:ShellEscape(s:netrwmftgt)
" call Decho("tgt<".tgt.">",'~'.expand("<slnum>"))
if !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16"))
- let tgt = substitute(tgt, '/','\\','g')
+ let tgt= substitute(tgt, '/','\\','g')
" call Decho("windows exception: tgt<".tgt.">",'~'.expand("<slnum>"))
if g:netrw_localmovecmd =~ '\s'
let movecmd = substitute(g:netrw_localmovecmd,'\s.*$','','')
let fname= substitute(fname,'/','\\','g')
endif
" call Decho("system(".movecmd." ".s:ShellEscape(fname)." ".tgt.")",'~'.expand("<slnum>"))
- let ret= system(movecmd." ".s:ShellEscape(fname)." ".tgt)
+ let ret= system(movecmd.g:netrw_localmovecmdopt." ".s:ShellEscape(fname)." ".tgt)
if v:shell_error != 0
if exists("b:netrw_curdir") && b:netrw_curdir != getcwd() && !g:netrw_keepdir
call netrw#ErrorMsg(s:ERROR,"move failed; perhaps due to vim's current directory<".getcwd()."> not matching netrw's (".b:netrw_curdir.") (see :help netrw-c)",100)
call s:NetrwUnmarkAll()
if a:islocal
- if executable(g:netrw_ctags)
-" call Decho("call system(".g:netrw_ctags." ".netrwmarkfilelist.")",'~'.expand("<slnum>"))
- call system(g:netrw_ctags." ".netrwmarkfilelist)
- else
+
+" call Decho("call system(".g:netrw_ctags." ".netrwmarkfilelist.")",'~'.expand("<slnum>"))
+ call system(g:netrw_ctags." ".netrwmarkfilelist)
+ if v:shell_error
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#Obtain(a:islocal,"tags")
call netrw#Obtain(islocal,s:netrwmarkfilelist_{bufnr('%')})
call s:NetrwUnmarkList(bufnr('%'),b:netrw_curdir)
else
- call netrw#Obtain(a:islocal,expand("<cWORD>"))
+ call netrw#Obtain(a:islocal,s:NetrwGetWord())
endif
let @@= ykeep
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.")",'~'.expand("<slnum>"))
+ " g:netrw_preview=0: preview window shown in a horizontally split window
+ " g:netrw_preview=1: preview window shown in a vertically split window
if g:netrw_preview
" vertically split preview window
- let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winheight(0))/100 : -g:netrw_winsize
+ let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winwidth(0))/100 : -g:netrw_winsize
" call Decho("exe ".(g:netrw_alto? "top " : "bot ")."vert ".winsz."wincmd s",'~'.expand("<slnum>"))
exe (g:netrw_alto? "top " : "bot ")."vert ".winsz."wincmd s"
else
" horizontally split preview window
- let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winwidth(0))/100 : -g:netrw_winsize
+ let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winheight(0))/100 : -g:netrw_winsize
" call Decho("exe ".(g:netrw_alto? "bel " : "abo ").winsz."wincmd s",'~'.expand("<slnum>"))
exe (g:netrw_alto? "bel " : "abo ").winsz."wincmd s"
endif
" call Decho("handle uploading a list of files via scp",'~'.expand("<slnum>"))
let curdir= getcwd()
if a:tgt =~ '^scp:'
- call s:NetrwLcd(fromdir)
+ if s:NetrwLcd(fromdir)
+" call Dret("s:NetrwUpload : lcd failure")
+ return
+ endif
let filelist= deepcopy(s:netrwmarkfilelist_{bufnr('%')})
let args = join(map(filelist,"s:ShellEscape(v:val, 1)"))
if exists("g:netrw_port") && g:netrw_port != ""
let machine = substitute(a:tgt,'^scp://\([^/:]\+\).*$','\1','')
let tgt = substitute(a:tgt,'^scp://[^/]\+/\(.*\)$','\1','')
call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_scp_cmd.s:ShellEscape(useport,1)." ".args." ".s:ShellEscape(machine.":".tgt,1))
- call s:NetrwLcd(curdir)
+ if s:NetrwLcd(curdir)
+" call Dret("s:NetrwUpload : lcd failure")
+ return
+ endif
elseif a:tgt =~ '^ftp:'
call s:NetrwMethod(a:tgt)
bw!|q
endif
elseif !exists("b:netrw_method") || b:netrw_method < 0
-" call Dfunc("netrw#NetrwUpload : unsupported method")
+" call Dret("s:#NetrwUpload : unsupported method")
return
endif
else
" call Decho("setl ma noro",'~'.expand("<slnum>"))
" call Decho("clear buffer<".expand("%")."> with :%d",'~'.expand("<slnum>"))
let ykeep = @@
+ if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
+ if !exists("w:netrw_treetop")
+ if exists("b:netrw_curdir")
+ let w:netrw_treetop= b:netrw_curdir
+ else
+ let w:netrw_treetop= getcwd()
+ endif
+ endif
+ NetrwKeepj call s:NetrwRefreshTreeDict(w:netrw_treetop)
+ endif
" save the cursor position before refresh.
let screenposn = winsaveview()
NetrwKeepj call winrestview(screenposn)
" restore file marks
- if exists("s:netrwmarkfilemtch_{bufnr('%')}") && s:netrwmarkfilemtch_{bufnr("%")} != ""
-" call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/",'~'.expand("<slnum>"))
- exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/"
- else
-" call Decho("2match none (bufnr(%)=".bufnr("%")."<".bufname("%").">)",'~'.expand("<slnum>"))
- 2match none
- endif
+ if has("syntax") && exists("g:syntax_on") && g:syntax_on
+ if exists("s:netrwmarkfilemtch_{bufnr('%')}") && s:netrwmarkfilemtch_{bufnr("%")} != ""
+" " call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/",'~'.expand("<slnum>"))
+ exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/"
+ else
+" " call Decho("2match none (bufnr(%)=".bufnr("%")."<".bufname("%").">)",'~'.expand("<slnum>"))
+ 2match none
+ endif
+ endif
" restore
let @@= ykeep
let depth= s:treedepthstring.a:depth
" call Decho("display subtrees with depth<".depth."> and current leaves",'~'.expand("<slnum>"))
+ " implement g:netrw_hide for tree listings (uses g:netrw_list_hide)
+ if g:netrw_hide == 1
+ " hide given patterns
+ let listhide= split(g:netrw_list_hide,',')
+" call Decho("listhide=".string(listhide))
+ for pat in listhide
+ call filter(w:netrw_treedict[dir],'v:val !~ "'.pat.'"')
+ endfor
+
+ elseif g:netrw_hide == 2
+ " show given patterns (only)
+ let listhide= split(g:netrw_list_hide,',')
+" call Decho("listhide=".string(listhide))
+ let entries=[]
+ for entry in w:netrw_treedict[dir]
+ for pat in listhide
+ if entry =~ pat
+ call add(entries,entry)
+ break
+ endif
+ endfor
+ endfor
+ let w:netrw_treedict[dir]= entries
+ endif
+ if depth != ""
+ " always remove "." and ".." entries when there's depth
+ call filter(w:netrw_treedict[dir],'v:val !~ "\\.\\.$"')
+ call filter(w:netrw_treedict[dir],'v:val !~ "\\.$"')
+ endif
+
" call Decho("for every entry in w:netrw_treedict[".dir."]=".string(w:netrw_treedict[dir]),'~'.expand("<slnum>"))
for entry in w:netrw_treedict[dir]
if dir =~ '/$'
sil! NetrwKeepj call setline(line("$")+1,depth.entry)
endif
endfor
+" call Decho("displaying: ".string(getline(w:netrw_bannercnt,'$')))
" call Dret("NetrwTreeDisplay")
endfun
" s:NetrwRefreshTreeDict: updates the contents information for a tree (w:netrw_treedict) {{{2
fun! s:NetrwRefreshTreeDict(dir)
" call Dfunc("s:NetrwRefreshTreeDict(dir<".a:dir.">)")
+ if !exists("w:netrw_treedict")
+" call Dret("s:NetrwRefreshTreeDict : w:netrw_treedict doesn't exist")
+ return
+ endif
+
for entry in w:netrw_treedict[a:dir]
let direntry= substitute(a:dir.'/'.entry,'[@/]$','','e')
" call Decho("a:dir<".a:dir."> entry<".entry."> direntry<".direntry.">",'~'.expand("<slnum>"))
" call Decho("updating w:netrw_treedict[".direntry.']='.string(w:netrw_treedict[direntry]),'~'.expand("<slnum>"))
else
-" call Decho('not updating w:netrw_treedict['.direntry.'] with entry<'.entry.'> (no subtree)',,'~'.expand("<slnum>"))
+" call Decho('not updating w:netrw_treedict['.string(direntry).'] with entry<'.string(entry).'> (no subtree)','~'.expand("<slnum>"))
endif
endfor
" call Dret("s:NetrwRefreshTreeDict")
endfun
" ---------------------------------------------------------------------
-" s:NetrwTreePath: returns path to current file in tree listing {{{2
+" s:NetrwTreePath: returns path to current file/directory in tree listing {{{2
" Normally, treetop is w:netrw_treetop, but a
" user of the function ( netrw#SetTreetop() )
" wipes that out prior to calling this function
fun! s:NetrwTreePath(treetop)
-" call Dfunc("s:NetrwTreePath() line#".line(".")."<".getline(".").">")
+" call Dfunc("s:NetrwTreePath(treetop<".a:treetop.">) line#".line(".")."<".getline(".").">")
+ if line(".") < w:netrw_bannercnt + 2
+ let treedir= a:treetop
+ if treedir !~ '/$'
+ let treedir= treedir.'/'
+ endif
+" call Dret("s:NetrwTreePath ".treedir." : line#".line(".")." ≤ ".(w:netrw_bannercnt+2))
+ return treedir
+ endif
+
let svpos = winsaveview()
" call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
let depth = substitute(getline('.'),'^\(\%('.s:treedepthstring.'\)*\)[^'.s:treedepthstring.'].\{-}$','\1','e')
let depth = substitute(depth,'^'.s:treedepthstring,'','')
" call Decho("constructing treedir<".treedir.">: dirname<".dirname."> while depth<".depth.">",'~'.expand("<slnum>"))
endwhile
+" call Decho("treedir#1<".treedir.">",'~'.expand("<slnum>"))
if a:treetop =~ '/$'
let treedir= a:treetop.treedir
else
let treedir= a:treetop.'/'.treedir
endif
+" call Decho("treedir#2<".treedir.">",'~'.expand("<slnum>"))
let treedir= substitute(treedir,'//$','/','')
+" call Decho("treedir#3<".treedir.">",'~'.expand("<slnum>"))
" call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))"
call winrestview(svpos)
" call Dret("s:NetrwTreePath <".treedir.">")
fun! s:PerformListing(islocal)
" call Dfunc("s:PerformListing(islocal=".a:islocal.")")
" call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol()." line($)=".line("$"),'~'.expand("<slnum>"))
-" call Decho("settings: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (enter)",'~'.expand("<slnum>"))
+" call Decho("settings: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (enter)"." ei<".&ei.">",'~'.expand("<slnum>"))
" set up syntax highlighting {{{3
" call Decho("--set up syntax highlighting (ie. setl ft=netrw)",'~'.expand("<slnum>"))
" call Decho("g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")",'~'.expand("<slnum>"))
endif
- " show copy/move target, if any
+ " show copy/move target, if any {{{3
if g:netrw_banner
if exists("s:netrwmftgt") && exists("s:netrwmftgt_islocal")
" call Decho("--show copy/move target<".s:netrwmftgt.">",'~'.expand("<slnum>"))
" resolve symbolic links if local and (thin or tree)
if a:islocal && (w:netrw_liststyle == s:THINLIST || (exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST))
" call Decho("--resolve symbolic links if local and thin|tree",'~'.expand("<slnum>"))
- g/@$/call s:ShowLink()
+ sil! g/@$/call s:ShowLink()
endif
if exists("w:netrw_bannercnt") && (line("$") >= w:netrw_bannercnt || !g:netrw_banner)
" call Dret("SetupNetrwStatusLine : stl=".&stl)
endfun
-" ---------------------------------------------------------------------
-" Remote Directory Browsing Support: {{{1
-" ===========================================
+" =========================================
+" Remote Directory Browsing Support: {{{1
+" =========================================
" ---------------------------------------------------------------------
" s:NetrwRemoteFtpCmd: unfortunately, not all ftp servers honor options for ls {{{2
" call Dret("NetrwRemoteRename")
endfun
-" ---------------------------------------------------------------------
+" ==========================================
" Local Directory Browsing Support: {{{1
" ==========================================
" ---------------------------------------------------------------------
-" netrw#FileUrlRead: handles reading file://* files {{{2
+" netrw#FileUrlEdit: handles editing file://* files {{{2
" Should accept: file://localhost/etc/fstab
" file:///etc/fstab
" file:///c:/WINDOWS/clock.avi
" file://c:/foo.txt
" file:///c:/foo.txt
" and %XX (where X is [0-9a-fA-F] is converted into a character with the given hexadecimal value
-fun! netrw#FileUrlRead(fname)
-" call Dfunc("netrw#FileUrlRead(fname<".a:fname.">)")
+fun! netrw#FileUrlEdit(fname)
+" call Dfunc("netrw#FileUrlEdit(fname<".a:fname.">)")
let fname = a:fname
if fname =~ '^file://localhost/'
" call Decho('converting file://localhost/ -to- file:///','~'.expand("<slnum>"))
let plainfname= substitute(plainfname,'^/\+\(\a:\)','\1','')
endif
endif
+
" call Decho("fname2396<".fname2396.">",'~'.expand("<slnum>"))
" call Decho("plainfname<".plainfname.">",'~'.expand("<slnum>"))
exe "sil doau BufReadPre ".fname2396e
- exe 'NetrwKeepj r '.plainfname
- exe 'sil! bdelete '.plainfname
- exe 'keepalt file! '.plainfname
- NetrwKeepj 1d
-" call Decho("setl nomod",'~'.expand("<slnum>"))
- setl nomod
+ exe 'NetrwKeepj keepalt edit '.plainfname
+ exe 'sil! NetrwKeepj keepalt bdelete '.fnameescape(a:fname)
+
" call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>"))
-" call Dret("netrw#FileUrlRead")
+" call Dret("netrw#FileUrlEdit")
exe "sil doau BufReadPost ".fname2396e
endfun
" call Dfunc("netrw#LocalBrowseCheck(dirname<".a:dirname.">")
" call Decho("isdir<".a:dirname."> =".isdirectory(s:NetrwFile(a:dirname)).((exists("s:treeforceredraw")? " treeforceredraw" : "")).'~'.expand("<slnum>"))
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>"))
-" call Dredir("ls!","ls!")
+" call Dredir("ls!","netrw#LocalBrowseCheck")
" call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>"))
" call Decho("current buffer#".bufnr("%")."<".bufname("%")."> ft=".&ft,'~'.expand("<slnum>"))
while itab <= tabpagenr("$")
let buftablist = buftablist + tabpagebuflist()
let itab = itab + 1
- tabn
+ sil! tabn
endwhile
" call Decho("buftablist".string(buftablist),'~'.expand("<slnum>"))
" call Decho("s:netrw_browselist<".(exists("s:netrw_browselist")? string(s:netrw_browselist) : "").">",'~'.expand("<slnum>"))
" GO through all buffers on netrw_browselist (ie. just local-netrw buffers):
" | refresh any netrw window
" | wipe out any non-displaying netrw buffer
- let curwin = winnr()
+ let curwinid = win_getid(winnr())
let ibl = 0
for ibuf in s:netrw_browselist
" call Decho("bufwinnr(".ibuf.") index(buftablist,".ibuf.")=".index(buftablist,ibuf),'~'.expand("<slnum>"))
if bufwinnr(ibuf) == -1 && index(buftablist,ibuf) == -1
" wipe out any non-displaying netrw buffer
+ " (ibuf not shown in a current window AND
+ " ibuf not in any tab)
" call Decho("wiping buf#".ibuf,"<".bufname(ibuf).">",'~'.expand("<slnum>"))
exe "sil! keepj bd ".fnameescape(ibuf)
call remove(s:netrw_browselist,ibl)
let ibl= ibl + 1
" call Decho("bottom of s:netrw_browselist for loop: ibl=".ibl,'~'.expand("<slnum>"))
endfor
-" call Decho("restore window: exe ".curwin."wincmd w",'~'.expand("<slnum>"))
- exe curwin."wincmd w"
+" call Decho("restore window: win_gotoid(".curwinid.")")
+ call win_gotoid(curwinid)
let @@= ykeep
" call Dret("s:LocalBrowseRefresh")
let rmfile= substitute(rmfile,'[\/]$','','e')
if all || ok =~# 'y\%[es]' || ok == ""
- if v:version < 704 || !has("patch1109")
+ if v:version < 704 || (v:version == 704 && !has("patch1107"))
" " call Decho("1st attempt: system(netrw#WinPath(".g:netrw_localrmdir.') '.s:ShellEscape(rmfile).')','~'.expand("<slnum>"))
call system(netrw#WinPath(g:netrw_localrmdir).' '.s:ShellEscape(rmfile))
" " call Decho("v:shell_error=".v:shell_error,'~'.expand("<slnum>"))
return ok
endfun
-" ---------------------------------------------------------------------
+" =====================================================================
" Support Functions: {{{1
-" ---------------------------------------------------------------------
-" s:WinNames: COMBAK {{{2
-fun! s:WinNames(id)
- let curwin= winnr()
- 1wincmd w
-" call Decho("--- Windows By Name --- #".a:id)
-" windo call Decho("win#".winnr()."<".expand("%").">")
-" call Decho("--- --- --- --- --- ---")
- exe curwin."wincmd w"
-endfun
-
" ---------------------------------------------------------------------
" netrw#Access: intended to provide access to variable values for netrw's test suite {{{2
" 0: marked file list of current buffer
endif
elseif a:ilist == 1
return s:netrwmftgt
+ endif
endfun
" ---------------------------------------------------------------------
" netrw#Call: allows user-specified mappings to call internal netrw functions {{{2
fun! netrw#Call(funcname,...)
-" call Dfunc("netrw#Call(funcname<".a:funcname.">,".string(a:000).")")
- if a:0 > 0
- exe "call s:".a:funcname."(".string(a:000).")"
- else
- exe "call s:".a:funcname."()"
- endif
-" call Dret("netrw#Call")
+ return call("s:".a:funcname,a:000)
endfun
" ---------------------------------------------------------------------
return path
endfun
+" ---------------------------------------------------------------------
+" s:NetrwBadd: adds marked files to buffer list or vice versa {{{2
+" cb : bl2mf=0 add marked files to buffer list
+" cB : bl2mf=1 use bufferlist to mark files
+" (mnemonic: cb = copy (marked files) to buffer list)
+fun! s:NetrwBadd(islocal,bl2mf)
+" " call Dfunc("s:NetrwBadd(islocal=".a:islocal." mf2bl=".mf2bl.")")
+ if a:bl2mf
+ " cB: add buffer list to marked files
+ redir => bufl
+ ls
+ redir END
+ let bufl = map(split(bufl,"\n"),'substitute(v:val,''^.\{-}"\(.*\)".\{-}$'',''\1'','''')')
+ for fname in bufl
+ call s:NetrwMarkFile(a:islocal,fname)
+ endfor
+ else
+ " cb: add marked files to buffer list
+ for fname in s:netrwmarkfilelist_{bufnr("%")}
+" " call Decho("badd ".fname,'~'.expand("<slnum>"))
+ exe "badd ".fnameescape(fname)
+ endfor
+ let curbufnr = bufnr("%")
+ let curdir = s:NetrwGetCurdir(a:islocal)
+ call s:NetrwUnmarkList(curbufnr,curdir) " remove markings from local buffer
+ endif
+" call Dret("s:NetrwBadd")
+endfun
+
" ---------------------------------------------------------------------
" s:ComposePath: Appends a new part to a path taking different systems into consideration {{{2
fun! s:ComposePath(base,subdir)
let ret = a:base.a:subdir
endif
- elseif a:subdir =~ '^\a:[/\\][^/\\]' && (has("win32") || has("win95") || has("win64") || has("win16"))
+ " COMBAK: test on windows with changing to root directory: :e C:/
+ elseif a:subdir =~ '^\a:[/\\]\([^/\\]\|$\)' && (has("win32") || has("win95") || has("win64") || has("win16"))
" call Decho("windows",'~'.expand("<slnum>"))
let ret= a:subdir
- elseif a:base =~ '^\a:[/\\][^/\\]' && (has("win32") || has("win95") || has("win64") || has("win16"))
+ elseif a:base =~ '^\a:[/\\]\([^/\\]\|$\)' && (has("win32") || has("win95") || has("win64") || has("win16"))
" call Decho("windows",'~'.expand("<slnum>"))
if a:base =~ '[/\\]$'
let ret= a:base.a:subdir
" ---------------------------------------------------------------------
" s:NetrwEnew: opens a new buffer, passes netrw buffer variables through {{{2
fun! s:NetrwEnew(...)
-" call Dfunc("s:NetrwEnew() a:0=".a:0." bufnr($)=".bufnr("$"))
+" call Dfunc("s:NetrwEnew() a:0=".a:0." bufnr($)=".bufnr("$")." expand(%)<".expand("%").">")
" call Decho("curdir<".((a:0>0)? a:1 : "")."> buf#".bufnr("%")."<".bufname("%").">",'~'.expand("<slnum>"))
" grab a function-local-variable copy of buffer variables
nno <silent> <buffer> [ :sil call <SID>TreeListMove('[')<cr>
nno <silent> <buffer> ] :sil call <SID>TreeListMove(']')<cr>
else
- exe "sil! keepalt file ".fnameescape(b:netrw_curdir)
+ call s:NetrwBufRename(b:netrw_curdir)
endif
endif
endif
" ---------------------------------------------------------------------
" s:NetrwExe: executes a string using "!" {{{2
fun! s:NetrwExe(cmd)
-" call Dfunc("s:NetrwExe(a:cmd)")
+" call Dfunc("s:NetrwExe(a:cmd<".a:cmd.">)")
if has("win32") && &shell !~? 'cmd' && !g:netrw_cygwin
+" call Decho("using win32:",expand("<slnum>"))
let savedShell=[&shell,&shellcmdflag,&shellxquote,&shellxescape,&shellquote,&shellpipe,&shellredir,&shellslash]
set shell& shellcmdflag& shellxquote& shellxescape&
set shellquote& shellpipe& shellredir& shellslash&
exe a:cmd
let [&shell,&shellcmdflag,&shellxquote,&shellxescape,&shellquote,&shellpipe,&shellredir,&shellslash] = savedShell
else
+" call Decho("exe ".a:cmd,'~'.expand("<slnum>"))
exe a:cmd
endif
-" call Dret("s:NetrwExe")
+" call Dret("s:NetrwExe : v:shell_error=".v:shell_error)
endfun
" ---------------------------------------------------------------------
" ---------------------------------------------------------------------
" s:NetrwLcd: handles changing the (local) directory {{{2
+" Returns: 0=success
+" -1=failed
fun! s:NetrwLcd(newdir)
" call Dfunc("s:NetrwLcd(newdir<".a:newdir.">)")
+ let err472= 0
try
exe 'NetrwKeepj sil lcd '.fnameescape(a:newdir)
catch /^Vim\%((\a\+)\)\=:E344/
endif
endif
catch /^Vim\%((\a\+)\)\=:E472/
+ let err472= 1
+ endtry
+
+ if err472
call netrw#ErrorMsg(s:ERROR,"unable to change directory to <".a:newdir."> (permissions?)",61)
if exists("w:netrw_prvdir")
let a:newdir= w:netrw_prvdir
exe "setl ".g:netrw_bufsettings
" call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>"))
let a:newdir= dirname
-" call Dret("s:NetrwBrowse : reusing buffer#".(exists("bufnum")? bufnum : 'N/A')."<".dirname."> getcwd<".getcwd().">")
- return
endif
- endtry
+" call Dret("s:NetrwBrowse -1 : reusing buffer#".(exists("bufnum")? bufnum : 'N/A')."<".dirname."> getcwd<".getcwd().">")
+ return -1
+ endif
-" call Dret("s:NetrwLcd")
+" call Dret("s:NetrwLcd 0")
+ return 0
endfun
" ------------------------------------------------------------------------
" s:SetRexDir() sets up <2-leftmouse> maps (if g:netrw_retmap
" is true) and a command, :Rexplore, which call this function.
"
-" s:netrw_nbcd is set up by s:NetrwBrowseChgDir()
+" s:netrw_posn is set up by s:NetrwBrowseChgDir()
"
" s:rexposn_BUFNR used to save/restore cursor position
fun! s:NetrwRexplore(islocal,dirname)
" call Decho("s:rexposn_".bufnr('%')."<".bufname("%")."> doesn't exist",'~'.expand("<slnum>"))
endif
- if exists("s:explore_match")
- exe "2match netrwMarkFile /".s:explore_match."/"
+ if has("syntax") && exists("g:syntax_on") && g:syntax_on
+ if exists("s:explore_match")
+ exe "2match netrwMarkFile /".s:explore_match."/"
+ endif
endif
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>"))
fun! s:SavePosn(posndict)
" call Dfunc("s:SavePosn(posndict) curbuf#".bufnr("%")."<".bufname("%").">")
- let a:posndict[bufnr("%")]= winsaveview()
-" call Decho("saving posn: posndict[".bufnr("%")."]=".string(winsaveview()),'~'.expand("<slnum>"))
+ if !exists("a:posndict[bufnr('%')]")
+ let a:posndict[bufnr("%")]= []
+ endif
+" call Decho("before push: a:posndict[buf#".bufnr("%")."]=".string(a:posndict[bufnr('%')]))
+ call add(a:posndict[bufnr("%")],winsaveview())
+" call Decho("after push: a:posndict[buf#".bufnr("%")."]=".string(a:posndict[bufnr('%')]))
" call Dret("s:SavePosn posndict")
return a:posndict
" s:RestorePosn: restores position associated with current buffer using dictionary {{{2
fun! s:RestorePosn(posndict)
" call Dfunc("s:RestorePosn(posndict) curbuf#".bufnr("%")."<".bufname("%").">")
- if has_key(a:posndict,bufnr("%"))
- call winrestview(a:posndict[bufnr("%")])
-" call Decho("restoring posn: posndict[".bufnr("%")."]=".string(a:posndict[bufnr("%")]),'~'.expand("<slnum>"))
+ if exists("a:posndict")
+ if has_key(a:posndict,bufnr("%"))
+" call Decho("before pop: a:posndict[buf#".bufnr("%")."]=".string(a:posndict[bufnr('%')]))
+ let posnlen= len(a:posndict[bufnr("%")])
+ if posnlen > 0
+ let posnlen= posnlen - 1
+" call Decho("restoring posn posndict[".bufnr("%")."][".posnlen."]=".string(a:posndict[bufnr("%")][posnlen]),'~'.expand("<slnum>"))
+ call winrestview(a:posndict[bufnr("%")][posnlen])
+ call remove(a:posndict[bufnr("%")],posnlen)
+" call Decho("after pop: a:posndict[buf#".bufnr("%")."]=".string(a:posndict[bufnr('%')]))
+ endif
+ endif
endif
" call Dret("s:RestorePosn")
endfun
" call Dret("s:UserMaps")
endfun
-" ---------------------------------------------------------------------
+" ==========================
" Settings Restoration: {{{1
+" ==========================
let &cpo= s:keepcpo
unlet s:keepcpo
-" ------------------------------------------------------------------------
+" ===============
" Modelines: {{{1
+" ===============
" vim:ts=8 fdm=marker
*expr9*
number
------
-number number constant *expr-number*
+number number constant *expr-number*
*hex-number* *octal-number* *binary-number*
Decimal, Hexadecimal (starting with 0x or 0X), Binary (starting with 0b or 0B)
Read-only in the |sandbox|. |fold-foldtext|
*v:hlsearch* *hlsearch-variable*
-v:hlsearch Variable that indicates whether search highlighting is on.
+v:hlsearch Variable that indicates whether search highlighting is on.
Setting it makes sense only if 'hlsearch' is enabled which
requires |+extra_search|. Setting this variable to zero acts
like the |:nohlsearch| command, setting it to one acts like >
v:servername The resulting registered |client-server-name| if any.
Read-only.
-
+
v:searchforward *v:searchforward* *searchforward-variable*
Search direction: 1 after a forward search, 0 after a
backward search. It is reset to forward when directly setting
*v:testing* *testing-variable*
v:testing Must be set before using `test_garbagecollect_now()`.
Also, when set certain error messages won't be shown for 2
- seconds. (e.g. "'dictionary' option is empty")
+ seconds. (e.g. "'dictionary' option is empty")
*v:this_session* *this_session-variable*
v:this_session Full filename of the last loaded or saved session file. See
ch_status({handle} [, {options}])
String status of channel {handle}
changenr() Number current change number
-char2nr({expr}[, {utf8}]) Number ASCII/UTF8 value of first char in {expr}
+char2nr({expr} [, {utf8}]) Number ASCII/UTF8 value of first char in {expr}
cindent({lnum}) Number C indent for line {lnum}
clearmatches() none clear all matches
col({expr}) Number column nr of cursor or mark
filewritable({file}) Number |TRUE| if {file} is a writable file
filter({expr1}, {expr2}) List/Dict remove items from {expr1} where
{expr2} is 0
-finddir({name}[, {path}[, {count}]])
+finddir({name} [, {path} [, {count}]])
String find directory {name} in {path}
-findfile({name}[, {path}[, {count}]])
+findfile({name} [, {path} [, {count}]])
String find file {name} in {path}
float2nr({expr}) Number convert Float {expr} to a Number
floor({expr}) Float round {expr} down
getftype({fname}) String description of type of file {fname}
getline({lnum}) String line {lnum} of current buffer
getline({lnum}, {end}) List lines {lnum} to {end} of current buffer
-getloclist({nr}[, {what}]) List list of location list items
+getloclist({nr} [, {what}]) List list of location list items
getmatches() List list of current matches
getpid() Number process ID of Vim
getpos({expr}) List position of cursor, mark, etc.
localtime() Number current time
log({expr}) Float natural logarithm (base e) of {expr}
log10({expr}) Float logarithm of Float {expr} to base 10
-luaeval({expr}[, {expr}]) any evaluate |Lua| expression
+luaeval({expr} [, {expr}]) any evaluate |Lua| expression
map({expr1}, {expr2}) List/Dict change each item in {expr1} to {expr}
-maparg({name}[, {mode} [, {abbr} [, {dict}]]])
+maparg({name} [, {mode} [, {abbr} [, {dict}]]])
String or Dict
rhs of mapping {name} in mode {mode}
-mapcheck({name}[, {mode} [, {abbr}]])
+mapcheck({name} [, {mode} [, {abbr}]])
String check for mappings matching {name}
-match({expr}, {pat}[, {start}[, {count}]])
+match({expr}, {pat} [, {start} [, {count}]])
Number position where {pat} matches in {expr}
-matchadd({group}, {pattern}[, {priority}[, {id} [, {dict}]]])
+matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])
Number highlight {pattern} with {group}
-matchaddpos({group}, {pos}[, {priority}[, {id}[, {dict}]]])
+matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]])
Number highlight positions with {group}
matcharg({nr}) List arguments of |:match|
matchdelete({id}) Number delete match identified by {id}
-matchend({expr}, {pat}[, {start}[, {count}]])
+matchend({expr}, {pat} [, {start} [, {count}]])
Number position where {pat} ends in {expr}
-matchlist({expr}, {pat}[, {start}[, {count}]])
+matchlist({expr}, {pat} [, {start} [, {count}]])
List match and submatches of {pat} in {expr}
-matchstr({expr}, {pat}[, {start}[, {count}]])
+matchstr({expr}, {pat} [, {start} [, {count}]])
String {count}'th match of {pat} in {expr}
-matchstrpos({expr}, {pat}[, {start}[, {count}]])
+matchstrpos({expr}, {pat} [, {start} [, {count}]])
List {count}'th match of {pat} in {expr}
max({expr}) Number maximum value of items in {expr}
min({expr}) Number minimum value of items in {expr}
mode([expr]) String current editing mode
mzeval({expr}) any evaluate |MzScheme| expression
nextnonblank({lnum}) Number line nr of non-blank line >= {lnum}
-nr2char({expr}[, {utf8}]) String single char with ASCII/UTF8 value {expr}
+nr2char({expr} [, {utf8}]) String single char with ASCII/UTF8 value {expr}
or({expr}, {expr}) Number bitwise OR
pathshorten({expr}) String shorten directory names in a path
perleval({expr}) any evaluate |Perl| expression
setcmdpos({pos}) Number set cursor position in command-line
setfperm({fname}, {mode}) Number set {fname} file permissions to {mode}
setline({lnum}, {line}) Number set line {lnum} to {line}
-setloclist({nr}, {list}[, {action}[, {what}]])
+setloclist({nr}, {list} [, {action} [, {what}]])
Number modify location list using {list}
setmatches({list}) Number restore a list of matches
setpos({expr}, {list}) Number set the {expr} position to {list}
-setqflist({list}[, {action}[, {what}]])
+setqflist({list} [, {action} [, {what}]])
Number modify quickfix list using {list}
-setreg({n}, {v}[, {opt}]) Number set register to value and type
+setreg({n}, {v} [, {opt}]) Number set register to value and type
settabvar({nr}, {varname}, {val}) none set {varname} in tab page {nr} to {val}
settabwinvar({tabnr}, {winnr}, {varname}, {val})
none set {varname} in window {winnr} in tab
str2float({expr}) Float convert String to Float
str2nr({expr} [, {base}]) Number convert String to Number
strchars({expr} [, {skipcc}]) Number character length of the String {expr}
-strcharpart({str}, {start}[, {len}])
+strcharpart({str}, {start} [, {len}])
String {len} characters of {str} at {start}
strdisplaywidth({expr} [, {col}]) Number display length of the String {expr}
-strftime({format}[, {time}]) String time in specified format
+strftime({format} [, {time}]) String time in specified format
strgetchar({str}, {index}) Number get char {index} from {str}
-stridx({haystack}, {needle}[, {start}])
+stridx({haystack}, {needle} [, {start}])
Number index of {needle} in {haystack}
string({expr}) String String representation of {expr} value
strlen({expr}) Number length of the String {expr}
-strpart({str}, {start}[, {len}])
+strpart({str}, {start} [, {len}])
String {len} characters of {str} at {start}
strridx({haystack}, {needle} [, {start}])
Number last index of {needle} in {haystack}
strtrans({expr}) String translate string to make it printable
strwidth({expr}) Number display cell length of the String {expr}
-submatch({nr}[, {list}]) String or List
+submatch({nr} [, {list}]) String or List
specific match in ":s" or substitute()
substitute({expr}, {pat}, {sub}, {flags})
String all {pat} in {expr} replaced with {sub}
systemlist({expr} [, {input}]) List output of shell command/filter {expr}
tabpagebuflist([{arg}]) List list of buffer numbers in tab page
tabpagenr([{arg}]) Number number of current or last tab page
-tabpagewinnr({tabarg}[, {arg}]) Number number of current window in tab page
-taglist({expr}[, {filename}]) List list of tags matching {expr}
+tabpagewinnr({tabarg} [, {arg}]) Number number of current window in tab page
+taglist({expr} [, {filename}]) List list of tags matching {expr}
tagfiles() List tags files used
tan({expr}) Float tangent of {expr}
tanh({expr}) Float hyperbolic tangent of {expr}
term_getsize({buf}) List get the size of a terminal
term_getstatus({buf}) String get the status of a terminal
term_gettitle({buf}) String get the title of a terminal
-term_getttty({buf}, [{input}]) String get the tty name of a terminal
+term_gettty({buf}, [{input}]) String get the tty name of a terminal
term_list() List get the list of terminal buffers
term_scrape({buf}, {row}) List get row of a terminal screen
term_sendkeys({buf}, {keys}) none send keystrokes to a terminal
in NL mode, the caller must do that. The NL in the response
is removed.
Note that Vim does not know when the text received on a raw
- channel is complete, it may only return the first part and you
+ channel is complete, it may only return the first part and you
need to use ch_readraw() to fetch the rest.
See |channel-use|.
redo it is the number of the redone change. After undo it is
one less than the number of the undone change.
-char2nr({expr}[, {utf8}]) *char2nr()*
+char2nr({expr} [, {utf8}]) *char2nr()*
Return number value of the first char in {expr}. Examples: >
char2nr(" ") returns 32
char2nr("ABC") returns 65
< -1.127626
{only available when compiled with the |+float| feature}
-
+
count({comp}, {expr} [, {ic} [, {start}]]) *count()*
Return the number of times an item with value {expr} appears
in |String|, |List| or |Dictionary| {comp}.
Returns 0 when the position could be set, -1 otherwise.
-deepcopy({expr}[, {noref}]) *deepcopy()* *E698*
+deepcopy({expr} [, {noref}]) *deepcopy()* *E698*
Make a copy of {expr}. For Numbers and Strings this isn't
different from using {expr} directly.
When {expr} is a |List| a full copy is created. This means
When {flags} is "d": Deletes the directory by the name
{fname}. This fails when directory {fname} is not empty.
-
+
When {flags} is "rf": Deletes the directory by the name
{fname} and everything in it, recursively. BE CAREFUL!
Note: on MS-Windows it is not possible to delete a directory
that is being used.
A symbolic link itself is deleted, not what it points to.
-
+
The result is a Number, which is 0 if the delete operation was
successful and -1 when the deletion failed or partly failed.
Return the Number 1 if {expr} is empty, zero otherwise.
- A |List| or |Dictionary| is empty when it does not have any
items.
+ - A String is empty when its length is zero.
- A Number and Float is empty when its value is zero.
- |v:false|, |v:none| and |v:null| are empty, |v:true| is not.
- A Job is empty when it failed to start.
For each item in {expr1} evaluate {expr2} and when the result
is zero remove the item from the |List| or |Dictionary|.
{expr2} must be a |string| or |Funcref|.
-
+
If {expr2} is a |string|, inside {expr2} |v:val| has the value
of the current item. For a |Dictionary| |v:key| has the key
of the current item and for a |List| |v:key| has the index of
defined with the "abort" flag.
-finddir({name}[, {path}[, {count}]]) *finddir()*
+finddir({name} [, {path} [, {count}]]) *finddir()*
Find directory {name} in {path}. Supports both downwards and
upwards recursive directory searches. See |file-searching|
for the syntax of {path}.
{only available when compiled with the |+file_in_path|
feature}
-findfile({name}[, {path}[, {count}]]) *findfile()*
+findfile({name} [, {path} [, {count}]]) *findfile()*
Just like |finddir()|, but find a file instead of a directory.
Uses 'suffixesadd'.
Example: >
echo floor(4.0)
< 4.0
{only available when compiled with the |+float| feature}
-
+
fmod({expr1}, {expr2}) *fmod()*
Return the remainder of {expr1} / {expr2}, even if the
When {arglist} or {dict} is present this creates a partial.
That means the argument list and/or the dictionary is stored in
the Funcref and will be used when the Funcref is called.
-
+
The arguments are passed to the function in front of other
arguments. Example: >
func Callback(arg1, arg2, name)
garbagecollect([{atexit}]) *garbagecollect()*
Cleanup unused |Lists|, |Dictionaries|, |Channels| and |Jobs|
that have circular references.
-
+
There is hardly ever a need to invoke this function, as it is
automatically done when Vim runs out of memory or is waiting
for the user to press a key after 'updatetime'. Items without
< To get lines from another buffer see |getbufline()|
-getloclist({nr}[, {what}]) *getloclist()*
+getloclist({nr} [, {what}]) *getloclist()*
Returns a list with all the entries in the location list for
window {nr}. {nr} can be the window number or the |window-ID|.
When {nr} is zero the current window is used.
"run" job is running
"fail" job failed to start
"dead" job died or was stopped after running
-
+
On Unix a non-existing command results in "dead" instead of
"fail", because a fork happens before the failure can be
detected.
This autocommand jumps to the last known position in a file
just after opening it, if the '" mark is set: >
:au BufReadPost *
- \ if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit'
+ \ if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit'
\ | exe "normal! g`\""
\ | endif
:echo log10(0.01)
< -2.0
{only available when compiled with the |+float| feature}
-
-luaeval({expr}[, {expr}]) *luaeval()*
- Evaluate Lua expression {expr} and return its result converted
- to Vim data structures. Second {expr} may hold additional
+
+luaeval({expr} [, {expr}]) *luaeval()*
+ Evaluate Lua expression {expr} and return its result converted
+ to Vim data structures. Second {expr} may hold additional
argument accessible as _A inside first {expr}.
Strings are returned as they are.
Boolean objects are converted to numbers.
- Numbers are converted to |Float| values if vim was compiled
+ Numbers are converted to |Float| values if vim was compiled
with |+float| and to numbers otherwise.
- Dictionaries and lists obtained by vim.eval() are returned
+ Dictionaries and lists obtained by vim.eval() are returned
as-is.
Other objects are returned as zero without any errors.
See |lua-luaeval| for more details.
{expr1} must be a |List| or a |Dictionary|.
Replace each item in {expr1} with the result of evaluating
{expr2}. {expr2} must be a |string| or |Funcref|.
-
+
If {expr2} is a |string|, inside {expr2} |v:val| has the value
of the current item. For a |Dictionary| |v:key| has the key
of the current item and for a |List| |v:key| has the index of
defined with the "abort" flag.
-maparg({name}[, {mode} [, {abbr} [, {dict}]]]) *maparg()*
+maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()*
When {dict} is omitted or zero: Return the rhs of mapping
{name} in mode {mode}. The returned String has special
characters translated like in the output of the ":map" command
listing.
-
+
When there is no mapping for {name}, an empty String is
returned.
exe 'nnoremap <Tab> ==' . maparg('<Tab>', 'n')
-mapcheck({name}[, {mode} [, {abbr}]]) *mapcheck()*
+mapcheck({name} [, {mode} [, {abbr}]]) *mapcheck()*
Check if there is a mapping that matches with {name} in mode
{mode}. See |maparg()| for {mode} and special names in
{name}.
< This avoids adding the "_vv" mapping when there already is a
mapping for "_v" or for "_vvv".
-match({expr}, {pat}[, {start}[, {count}]]) *match()*
+match({expr}, {pat} [, {start} [, {count}]]) *match()*
When {expr} is a |List| then this returns the index of the
first item where {pat} matches. Each item is used as a
String, |Lists| and |Dictionaries| are used as echoed.
done like 'magic' is set and 'cpoptions' is empty.
*matchadd()* *E798* *E799* *E801*
-matchadd({group}, {pattern}[, {priority}[, {id}[, {dict}]]])
+matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])
Defines a pattern to be highlighted in the current window (a
"match"). It will be highlighted with {group}. Returns an
identification number (ID), which can be used to delete the
one operation by |clearmatches()|.
*matchaddpos()*
-matchaddpos({group}, {pos}[, {priority}[, {id}[, {dict}]]])
+matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]])
Same as |matchadd()|, but requires a list of positions {pos}
instead of a pattern. This command is faster than |matchadd()|
because it does not require to handle regular expressions and
be highlighted.
- A list with three numbers, e.g., [23, 11, 3]. As above, but
the third number gives the length of the highlight in bytes.
-
+
The maximum number of positions is 8.
Example: >
otherwise -1. See example for |matchadd()|. All matches can
be deleted in one operation by |clearmatches()|.
-matchend({expr}, {pat}[, {start}[, {count}]]) *matchend()*
+matchend({expr}, {pat} [, {start} [, {count}]]) *matchend()*
Same as |match()|, but return the index of first character
after the match. Example: >
:echo matchend("testing", "ing")
< result is "-1".
When {expr} is a |List| the result is equal to |match()|.
-matchlist({expr}, {pat}[, {start}[, {count}]]) *matchlist()*
+matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()*
Same as |match()|, but return a |List|. The first item in the
list is the matched string, same as what matchstr() would
return. Following items are submatches, like "\1", "\2", etc.
< Results in: ['acd', 'a', '', 'c', 'd', '', '', '', '', '']
When there is no match an empty list is returned.
-matchstr({expr}, {pat}[, {start}[, {count}]]) *matchstr()*
+matchstr({expr}, {pat} [, {start} [, {count}]]) *matchstr()*
Same as |match()|, but return the matched string. Example: >
:echo matchstr("testing", "ing")
< results in "ing".
When {expr} is a |List| then the matching item is returned.
The type isn't changed, it's not necessarily a String.
-matchstrpos({expr}, {pat}[, {start}[, {count}]]) *matchstrpos()*
+matchstrpos({expr}, {pat} [, {start} [, {count}]]) *matchstrpos()*
Same as |matchstr()|, but return the matched string, the start
position and the end position of the match. Example: >
:echo matchstrpos("testing", "ing")
below it, zero is returned.
See also |prevnonblank()|.
-nr2char({expr}[, {utf8}]) *nr2char()*
+nr2char({expr} [, {utf8}]) *nr2char()*
Return a string with a single character, which has the number
value {expr}. Examples: >
nr2char(64) returns "@"
:echo pow(32, 0.20)
< 2.0
{only available when compiled with the |+float| feature}
-
+
prevnonblank({lnum}) *prevnonblank()*
Return the line number of the first line at or above {lnum}
that is not blank. Example: >
feature works just like 's'.
*printf-f* *E807*
- f F The Float argument is converted into a string of the
+ f F The Float argument is converted into a string of the
form 123.456. The precision specifies the number of
digits after the decimal point. When the precision is
zero the decimal point is omitted. When the precision
py3eval({expr}) *py3eval()*
Evaluate Python expression {expr} and return its result
converted to Vim data structures.
- Numbers and strings are returned as they are (strings are
- copied though, Unicode strings are additionally converted to
+ Numbers and strings are returned as they are (strings are
+ copied though, Unicode strings are additionally converted to
'encoding').
Lists are represented as Vim |List| type.
- Dictionaries are represented as Vim |Dictionary| type with
+ Dictionaries are represented as Vim |Dictionary| type with
keys converted to strings.
{only available when compiled with the |+python3| feature}
pyeval({expr}) *pyeval()*
Evaluate Python expression {expr} and return its result
converted to Vim data structures.
- Numbers and strings are returned as they are (strings are
+ Numbers and strings are returned as they are (strings are
copied though).
Lists are represented as Vim |List| type.
- Dictionaries are represented as Vim |Dictionary| type,
+ Dictionaries are represented as Vim |Dictionary| type,
non-string keys result in error.
{only available when compiled with the |+python| feature}
and the result will be the empty string.
Variables will be evaluated in the global namespace,
- independent of a function currently being activel. Except
+ independent of a function currently being active. Except
when in debug mode, then local function variables and
arguments can be evaluated.
< -5.0
{only available when compiled with the |+float| feature}
-screenattr(row, col) *screenattr()*
+screenattr({row}, {col}) *screenattr()*
Like |screenchar()|, but return the attribute. This is a rather
arbitrary number that can only be used to compare to the
attribute at other positions.
-screenchar(row, col) *screenchar()*
+screenchar({row}, {col}) *screenchar()*
The result is a Number, which is the character at position
[row, col] on the screen. This works for every possible
screen position, also status lines, window separators and the
flag.
'ignorecase', 'smartcase' and 'magic' are used.
-
+
When the 'z' flag is not given, searching always starts in
column zero and then matches before the cursor are skipped.
When the 'c' flag is present in 'cpo' the next search starts
< Note: The '[ and '] marks are not set.
-setloclist({nr}, {list}[, {action}[, {what}]]) *setloclist()*
+setloclist({nr}, {list} [, {action} [, {what}]]) *setloclist()*
Create or replace or add to the location list for window {nr}.
{nr} can be the window number or the |window-ID|.
When {nr} is zero the current window is used.
also set the preferred column. Also see the "curswant" key in
|winrestview()|.
-setqflist({list} [, {action}[, {what}]]) *setqflist()*
+setqflist({list} [, {action} [, {what}]]) *setqflist()*
Create or replace or add to the quickfix list.
-
+
When {what} is not present, use the items in {list}. Each
item must be a dictionary. Non-dictionary items in {list} are
ignored. Each dictionary item can contain the following
'a' The items from {list} are added to the existing
quickfix list. If there is no existing list, then a
new list is created.
-
+
'r' The items from the current quickfix list are replaced
with the items from {list}. This can also be used to
clear the list: >
:call setqflist([], 'r')
-<
+<
'f' All the quickfix lists in the quickfix stack are
freed.
*setreg()*
setreg({regname}, {value} [, {options}])
Set the register {regname} to {value}.
- {value} may be any value returned by |getreg()|, including
+ {value} may be any value returned by |getreg()|, including
a |List|.
If {options} contains "a" or {regname} is upper case,
then the value is appended.
in the longest line (counting a <Tab> as 1 character).
If {options} contains no register settings, then the default
- is to use character mode unless {value} ends in a <NL> for
- string {value} and linewise mode for list {value}. Blockwise
+ is to use character mode unless {value} ends in a <NL> for
+ string {value} and linewise mode for list {value}. Blockwise
mode is never selected automatically.
Returns zero for success, non-zero for failure.
*E883*
- Note: you may not use |List| containing more than one item to
- set search and expression registers. Lists containing no
+ Note: you may not use |List| containing more than one item to
+ set search and expression registers. Lists containing no
items act like empty strings.
Examples: >
:let var_amode = getregtype('a')
....
:call setreg('a', var_a, var_amode)
-< Note: you may not reliably restore register value
- without using the third argument to |getreg()| as without it
+< Note: you may not reliably restore register value
+ without using the third argument to |getreg()| as without it
newlines are represented as newlines AND Nul bytes are
represented as newlines as well, see |NL-used-for-Nul|.
:echo sin(-4.01)
< 0.763301
{only available when compiled with the |+float| feature}
-
+
sinh({expr}) *sinh()*
Return the hyperbolic sine of {expr} as a |Float| in the range
sort({list} [, {func} [, {dict}]]) *sort()* *E702*
Sort the items in {list} in-place. Returns {list}.
-
+
If you want a list to remain unmodified make a copy first: >
:let sortedlist = sort(copy(mylist))
When {func} is given and it is '1' or 'i' then case is
ignored.
-
+
When {func} is given and it is 'n' then all items will be
sorted numerical (Implementation detail: This uses the
strtod() function to parse numbers, Strings, Lists, Dicts and
< nan
"nan" may be different, it depends on system libraries.
{only available when compiled with the |+float| feature}
-
+
str2float({expr}) *str2float()*
Convert String {expr} to a Float. This mostly works the same
counted separately.
When {skipcc} set to 1, Composing characters are ignored.
Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
-
+
{skipcc} is only available after 7.4.755. For backward
compatibility, you can define a wrapper function: >
if has("patch-7.4.755")
endfunction
endif
<
-strcharpart({src}, {start}[, {len}]) *strcharpart()*
+strcharpart({src}, {start} [, {len}]) *strcharpart()*
Like |strpart()| but using character index and length instead
of byte index and length.
When a character index is used where a character does not
strcharpart('abc', -1, 2)
< results in 'a'.
-strdisplaywidth({expr}[, {col}]) *strdisplaywidth()*
+strdisplaywidth({expr} [, {col}]) *strdisplaywidth()*
The result is a Number, which is the number of display cells
String {expr} occupies on the screen when it starts at {col}.
When {col} is omitted zero is used. Otherwise it is the
|strchars()|.
Also see |len()|, |strdisplaywidth()| and |strwidth()|.
-strpart({src}, {start}[, {len}]) *strpart()*
+strpart({src}, {start} [, {len}]) *strpart()*
The result is a String, which is part of {src}, starting from
byte {start}, with the byte length {len}.
To count characters instead of bytes use |strcharpart()|.
Ambiguous, this function's return value depends on 'ambiwidth'.
Also see |strlen()|, |strdisplaywidth()| and |strchars()|.
-submatch({nr}[, {list}]) *submatch()* *E935*
+submatch({nr} [, {list}]) *submatch()* *E935*
Only for an expression in a |:substitute| command or
substitute() function.
Returns the {nr}'th submatch of the matched text. When {nr}
multi-line match or a NUL character in the text.
Also see |sub-replace-expression|.
- If {list} is present and non-zero then submatch() returns
- a list of strings, similar to |getline()| with two arguments.
+ If {list} is present and non-zero then submatch() returns
+ a list of strings, similar to |getline()| with two arguments.
NL characters in the text represent NUL characters in the
text.
Only returns more than one item for |:substitute|, inside
the first match of {pat} is replaced with {sub}.
When {flags} is "g", all matches of {pat} in {expr} are
replaced. Otherwise {flags} should be "".
-
+
This works like the ":substitute" command (without any flags).
But the matching with {pat} is always done like the 'magic'
option is set and 'cpoptions' is empty (to make scripts
Get the output of the shell command {expr} as a string. See
|systemlist()| to get the output as a List.
- When {input} is given and is a string this string is written
- to a file and passed as stdin to the command. The string is
- written as-is, you need to take care of using the correct line
+ When {input} is given and is a string this string is written
+ to a file and passed as stdin to the command. The string is
+ written as-is, you need to take care of using the correct line
separators yourself.
If {input} is given and is a |List| it is written to the file
in a way |writefile()| does with {binary} set to "b" (i.e.
up on the screen which require |CTRL-L| to remove. >
:silent let f = system('ls *.vim')
<
- Note: Use |shellescape()| or |::S| with |expand()| or
- |fnamemodify()| to escape special characters in a command
- argument. Newlines in {expr} may cause the command to fail.
- The characters in 'shellquote' and 'shellxquote' may also
+ Note: Use |shellescape()| or |::S| with |expand()| or
+ |fnamemodify()| to escape special characters in a command
+ argument. Newlines in {expr} may cause the command to fail.
+ The characters in 'shellquote' and 'shellxquote' may also
cause trouble.
This is not to be used for interactive commands.
systemlist({expr} [, {input}]) *systemlist()*
- Same as |system()|, but returns a |List| with lines (parts of
- output separated by NL) with NULs transformed into NLs. Output
- is the same as |readfile()| will output with {binary} argument
+ Same as |system()|, but returns a |List| with lines (parts of
+ output separated by NL) with NULs transformed into NLs. Output
+ is the same as |readfile()| will output with {binary} argument
set to "b". Note that on MS-Windows you may get trailing CR
characters.
for the current buffer. This is the 'tags' option expanded.
-taglist({expr}[, {filename}]) *taglist()*
+taglist({expr} [, {filename}]) *taglist()*
Returns a list of tags matching the regular expression {expr}.
If {filename} is passed it is used to prioritize the results
line is used. When {row} is invalid an empty string is
returned.
- Return a List containing a Dict for each screen cell:
+ Return a List containing a Dict for each screen cell:
"chars" character(s) at the cell
"fg" foreground color as #rrggbb
"bg" background color as #rrggbb
to run tests. Only to be used for testing Vim!
The override is enabled when {val} is non-zero and removed
when {val} is zero.
- Current supported values for name are:
+ Current supported values for name are:
name effect when {val} is non-zero ~
redraw disable the redrawing() function
echo trunc(4.0)
< 4.0
{only available when compiled with the |+float| feature}
-
+
*type()*
type({expr}) The result is a Number representing the type of {expr}.
Instead of using the number directly, it is better to use the
"save_last" Number of the last file write. Zero when no
write yet.
"save_cur" Number of the current position in the undo
- tree.
+ tree.
"synced" Non-zero when the last undo block was synced.
This happens when waiting from input from the
user. See |undo-blocks|.
appended to the file: >
:call writefile(["foo"], "event.log", "a")
:call writefile(["bar"], "event.log", "a")
->
+
< All NL characters are replaced with a NUL character.
Inserting CR characters needs to be done before passing {list}
to writefile().
Define a new function by the name {name}. The body of
the function follows in the next lines, until the
matching |:endfunction|.
-
+
The name must be made of alphanumeric characters and
'_', and must start with a capital or "s:" (see
above). Note that using "b:" or "g:" is not allowed.
redir => scriptnames_output
silent scriptnames
redir END
-
+
" Split the output into lines and parse each line. Add an entry to the
" "scripts" dictionary.
let scripts = {}
-*pi_netrw.txt* For Vim version 8.0. Last change: 2016 Apr 20
+*pi_netrw.txt* For Vim version 8.0. Last change: 2017 Nov 03
------------------------------------------------
NETRW REFERENCE MANUAL by Charles E. Campbell
Author: Charles E. Campbell <NdrOchip@ScampbellPfamily.AbizM>
(remove NOSPAM from Campbell's email first)
-Copyright: Copyright (C) 2016 Charles E Campbell *netrw-copyright*
+Copyright: Copyright (C) 2017 Charles E Campbell *netrw-copyright*
The VIM LICENSE applies to the files in this package, including
netrw.vim, pi_netrw.txt, netrwFileHandlers.vim, netrwSettings.vim, and
syntax/netrw.vim. Like anything else that's free, netrw.vim and its
holder be liable for any damages resulting from the use of this
software. Use at your own risk!
-
*netrw*
*dav* *ftp* *netrw-file* *rcp* *scp*
*davs* *http* *netrw.vim* *rsync* *sftp*
Improving Browsing..................................|netrw-ssh-hack|
Listing Bookmarks And History.......................|netrw-qb|
Making A New Directory..............................|netrw-d|
- Making The Browsing Directory The Current Directory.|netrw-c|
+ Making The Browsing Directory The Current Directory.|netrw-cd|
Marking Files.......................................|netrw-mf|
Unmarking Files.....................................|netrw-mF|
Marking Files By Location List......................|netrw-qL|
Marked Files: Arbitrary Shell Command, En Bloc......|netrw-mX|
Marked Files: Arbitrary Vim Command.................|netrw-mv|
Marked Files: Argument List.........................|netrw-ma| |netrw-mA|
+ Marked Files: Buffer List...........................|netrw-cb| |netrw-cB|
Marked Files: Compression And Decompression.........|netrw-mz|
Marked Files: Copying...............................|netrw-mc|
Marked Files: Diff..................................|netrw-md|
let g:netrw_ftp_cmd= 'c:\Windows\System32\ftp -s:C:\Users\MyUserName\MACHINE'
<
-Netrw will substitute the host's machine name for "MACHINE" from the url it is
+Netrw will substitute the host's machine name for "MACHINE" from the URL it is
attempting to open, and so one may specify >
userid
password
http: g:netrw_http_cmd = "fetch" elseif fetch is available
http: *g:netrw_http_put_cmd* = "curl -T"
rcp: *g:netrw_rcp_cmd* = "rcp"
- rsync: *g:netrw_rsync_cmd* = "rsync -a"
+ rsync: *g:netrw_rsync_cmd* = "rsync" (see |g:netrw_rsync_sep|)
scp: *g:netrw_scp_cmd* = "scp -q"
sftp: *g:netrw_sftp_cmd* = "sftp"
file: *g:netrw_file_cmd* = "elinks" or "links"
elinks : "-source >"
links : "-dump >"
- curl : "-o"
+ curl : "-L -o"
wget : "-q -O"
fetch : "-o"
<
READING *netrw-read* *netrw-nread* {{{2
- Generally, one may just use the url notation with a normal editing
+ Generally, one may just use the URL notation with a normal editing
command, such as >
:e ftp://[user@]machine/path
WRITING *netrw-write* *netrw-nwrite* {{{2
- One may just use the url notation with a normal file writing
+ One may just use the URL notation with a normal file writing
command, such as >
:w ftp://[user@]machine/path
SOURCING *netrw-source* {{{2
- One may just use the url notation with the normal file sourcing
+ One may just use the URL notation with the normal file sourcing
command, such as >
:so ftp://[user@]machine/path
==============================================================================
4. Network-Oriented File Transfer *netrw-xfer* {{{1
-Network-oriented file transfer under Vim is implemented by a VimL-based script
+Network-oriented file transfer under Vim is implemented by a vim script
(<netrw.vim>) using plugin techniques. It currently supports both reading and
writing across networks using rcp, scp, ftp or ftp+<.netrc>, scp, fetch,
dav/cadaver, rsync, or sftp.
let g:netrw_sftp_cmd= '"c:\Program Files\PuTTY\psftp.exe"'
<
(note: it has been reported that windows 7 with putty v0.6's "-batch" option
- doesn't work, so it's best to leave it off for that system)
+ doesn't work, so its best to leave it off for that system)
See |netrw-p8| for more about putty, pscp, psftp, etc.
The usual read/write commands are supported. There are also a few
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
- :w url
+ :e URL
+ :r URL
+ :w URL
instead, as appropriate) -- see |netrw-urls|. In the explanations
-below, a {netfile} is an url to a remote file.
+below, a {netfile} is a URL to a remote file.
*:Nwrite* *:Nw*
:[range]Nw[rite] Write the specified lines to the current
g:netrw_http_cmd var ="fetch -o" if fetch is available
g:netrw_http_cmd var ="wget -O" else if wget is available
g:netrw_http_put_cmd var ="curl -T"
- |g:netrw_list_cmd| var ="ssh USEPORT HOSTNAME ls -Fa"
+ |g:netrw_list_cmd| var ="ssh USEPORT HOSTNAME ls -Fa"
g:netrw_rcp_cmd var ="rcp"
- g:netrw_rsync_cmd var ="rsync -a"
+ g:netrw_rsync_cmd var ="rsync"
+ *g:netrw_rsync_sep* var ="/" used to separate the hostname
+ from the file spec
g:netrw_scp_cmd var ="scp -q"
g:netrw_sftp_cmd var ="sftp" >
-------------------------------------------------------------------------
vim ftp://ftp.home.vim.org/pub/vim/
<
For local directories, the trailing slash is not required. Again, because it's
-easy to miss: to browse remote directories, the url must terminate with a
+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
<c-r> Browse using a gvim server |netrw-ctrl-r|
<c-tab> Shrink/expand a netrw/explore window |netrw-c-tab|
- Makes Netrw go up one directory |netrw--|
- a Toggles between normal display, |netrw-a|
+ a Cycles 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)
+ and showing (display only files which match g:netrw_list_hide)
c Make browsing directory the current directory |netrw-c|
C Setting the editing window |netrw-C|
d Make a directory |netrw-d|
gh Quick hide/unhide of dot-files |netrw-gh|
gn Make top of tree the directory below the cursor |netrw-gn|
i Cycle between thin, long, wide, and tree listings |netrw-i|
+ I Toggle the displaying of the banner |netrw-I|
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|
BANNER DISPLAY *netrw-I*
-One may toggle the banner display on and off by pressing "I".
+One may toggle the displaying of the banner by pressing "I".
Also See: |g:netrw_banner|
-BOOKMARKING A DIRECTORY *netrw-mb* *netrw-bookmark* *netrw-bookmarks* {{{2
+BOOKMARKING A DIRECTORY *netrw-mb* *netrw-bookmark* *netrw-bookmarks* {{{2
One may easily "bookmark" the currently browsed directory by using >
mb
<
*.netrwbook*
-Bookmarks are retained in between sessions in a $HOME/.netrwbook file, and are
-kept in sorted order.
+Bookmarks are retained in between sessions of vim in a file called .netrwbook
+as a |List|, which is typically stored in the first directory on the user's
+'|runtimepath|'; entries are kept in sorted order.
If there are marked files and/or directories, mb will add them to the bookmark
list.
-*netrw-:NetrwMB*
+ *netrw-:NetrwMB*
Addtionally, one may use :NetrwMB to bookmark files or directories. >
:NetrwMB[!] [files/directories]
invoked in the session).
The file ".netrwbook" holds bookmarks when netrw (and vim) is not active. By
-default, it's stored on the first directory on the user's |'runtimepath'|.
+default, its stored on the first directory on the user's |'runtimepath'|.
Related Topics:
|netrw-gb| how to return (go) to a bookmark
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|.
+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 holds ten entries). With the "u"
+map, one can change to an earlier directory (predecessor). To do the
+opposite, see |netrw-U|.
-The "u" map also accepts counts to go back in the history several slots.
-For your convenience, qb (see |netrw-qb|) lists the history number which may
-be used in that count.
+The "u" map also accepts counts to go back in the history several slots. For
+your convenience, qb (see |netrw-qb|) lists the history number which may be
+used in that count.
*.netrwhist*
See |g:netrw_dirhistmax| for how to control the quantity of history stack
slots. The file ".netrwhist" holds history when netrw (and vim) is not
-active. By default, it's stored on the first directory on the user's
+active. By default, its stored on the first directory on the user's
|'runtimepath'|.
Related Topics:
NETRW CLEAN *netrw-clean* *:NetrwClean* {{{2
-With NetrwClean one may easily remove netrw from one's home directory;
+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 attempt to remove netrw from all directories on
+With :NetrwClean!, netrw will attempt to remove netrw from all directories on
your |'runtimepath'|. Of course, you have to have write/delete permissions
correct to do this.
If g:netrw_browsex_viewer == '-', then netrwFileHandlers#Invoke() will be
used instead (see |netrw_filehandler|).
- * for Windows 32 or 64, the url and FileProtocolHandler dlls are used.
+ * 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.
One may also use visual mode (see |visual-start|) to select the text that the
special handler will use. Normally gx uses expand("<cfile>") to pick up the
text under the cursor; one may change what |expand()| uses via the
-|g:netrw_gx| variable. Alternatively, one may select the text to be used by
-gx via first making a visual selection (see |visual-block|) or by changing
-the |'isfname'| option (which is global, so netrw doesn't modify it).
+|g:netrw_gx| variable (options include "<cword>", "<cWORD>"). Note that
+expand("<cfile>") depends on the |'isfname'| setting. Alternatively, one may
+select the text to be used by gx by making a visual selection (see
+|visual-block|) and then pressing gx.
Associated setting variables:
|g:netrw_gx| control how gx picks up the text under the cursor
This will cause the matching files to be marked. Then,
press "D".
+If your vim has 7.4 with patch#1107, then |g:netrw_localrmdir| no longer
+is used to remove directories; instead, vim's |delete()| is used with
+the "d" option. Please note that only empty directories may be deleted
+with the "D" mapping. Regular files are deleted with |delete()|, too.
+
The |g:netrw_rm_cmd|, |g:netrw_rmf_cmd|, and |g:netrw_rmdir_cmd| variables are
used to control the attempts to remove remote files and directories. The
g:netrw_rm_cmd is used with files, and its default value is:
The [N] specifies a |g:netrw_winsize| just for the new :Lexplore
window.
- Those who like this method often also often like tree style displays;
+ Those who like this method often also like tree style displays;
see |g:netrw_liststyle|.
+:[N]Lexplore! [dir] is similar to :Lexplore, except that the full-height
+ Explorer window will open on the right hand side and an
+ uninitialized |g:netrw_chgwin| will be set to 1 (eg. edits will
+ preferentially occur in the leftmost window).
+
Also see: |netrw-C| |g:netrw_browse_split| |g:netrw_wiw|
|netrw-p| |netrw-P| |g:netrw_chgwin|
|netrw-c-tab| |g:netrw_winsize|
-:[N]Lexplore! is like :Lexplore, except that the full-height Explorer window
- will open on the right hand side and an uninitialized |g:netrw_chgwin|
- will be set to 1.
-
*netrw-:Sexplore*
:[N]Sexplore will always split the window before invoking the local-directory
browser. As with Explore, the splitting is normally done
Pressing X while the cursor is atop an executable file will yield a prompt
using the filename asking for any arguments. Upon pressing a [return], netrw
-will then call |system()| with that command and arguments. The result will
-be displayed by |:echomsg|, and so |:messages| will repeat display of the
-result. Ansi escape sequences will be stripped out.
+will then call |system()| with that command and arguments. The result will be
+displayed by |:echomsg|, and so |:messages| will repeat display of the result.
+Ansi escape sequences will be stripped out.
+
+See |cmdline-window| for directions for more on how to edit the arguments.
FORCING TREATMENT AS A FILE OR DIRECTORY *netrw-gd* *netrw-gf* {{{2
|g:netrw_remote_mkdir| |netrw-%|
-MAKING THE BROWSING DIRECTORY THE CURRENT DIRECTORY *netrw-c* {{{2
+MAKING THE BROWSING DIRECTORY THE CURRENT DIRECTORY *netrw-cd* {{{2
By default, |g:netrw_keepdir| is 1. This setting means that the current
directory will not track the browsing directory. (done for backwards
set Vim's notion of the current directory to netrw's current browsing
directory.
+*netrw-c* : This map's name has been changed from "c" to cd (see |netrw-cd|).
+ This change was done to allow for |netrw-cb| and |netrw-cB| maps.
+
Associated setting variable: |g:netrw_keepdir|
MARKING FILES *netrw-:MF* *netrw-mf* {{{2
|netrw-mg| Apply vimgrep to marked files
|netrw-mm| Move marked files to target
|netrw-mp| Print marked files
+ |netrw-ms| Netrw will source marked files
|netrw-mt| Set target for |netrw-mm| and |netrw-mc|
|netrw-mT| Generate tags using marked files
|netrw-mv| Apply vim command to marked files
future I may make it possible to use |regexp|s instead of glob()-style
expressions (yet-another-option).
+See |cmdline-window| for directions on more on how to edit the regular
+expression.
+
MARKED FILES, ARBITRARY VIM COMMAND *netrw-mv* {{{2
(See |netrw-mf| and |netrw-mr| for how to mark files)
* run vim command
* sil! keepalt wq!
-A prompt, "Enter vim command: ", will be issued to elicit the vim command
-you wish used.
+A prompt, "Enter vim command: ", will be issued to elicit the vim command you
+wish used. See |cmdline-window| for directions for more on how to edit the
+command.
MARKED FILES, ARBITRARY SHELL COMMAND *netrw-mx* {{{2
Using ma, one moves filenames from the marked file list to the argument list.
Using mA, one moves filenames from the argument list to the marked file list.
-See Also: |netrw-qF| |argument-list| |:args|
+See Also: |netrw-cb| |netrw-cB| |netrw-qF| |argument-list| |:args|
+
+
+MARKED FILES: BUFFER LIST *netrw-cb* *netrw-cB*
+ (See |netrw-mf| and |netrw-mr| for how to mark files)
+ (uses the global marked-file list)
+
+Using cb, one moves filenames from the marked file list to the buffer list.
+Using cB, one copies filenames from the buffer list to the marked file list.
+
+See Also: |netrw-ma| |netrw-mA| |netrw-qF| |buffer-list| |:buffers|
MARKED FILES: COMPRESSION AND DECOMPRESSION *netrw-mz* {{{2
directory.
Associated setting variables:
- |g:netrw_localcopycmd|
- |g:netrw_localcopydircmd|
+ |g:netrw_localcopycmd| |g:netrw_localcopycmdopt|
+ |g:netrw_localcopydircmd| |g:netrw_localcopydircmdopt|
|g:netrw_ssh_cmd|
MARKED FILES: DIFF *netrw-md* {{{2
ie. a copy is transferred to the local system's directory. The now local tags
file is then modified so that one may use it through the network. The
modification made 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
+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.
Associated setting variables: |g:netrw_ctags| |g:netrw_ssh_cmd|
editing. It will also use the specified tab
and window numbers to perform editing
(see |clientserver|, |netrw-ctrl-r|)
- This option does not affect |:Lexplore|
- windows.
+ This option does not affect the production of
+ |:Lexplore| windows.
Related topics:
|g:netrw_alto| |g:netrw_altv|
*g:netrw_home* The home directory for where bookmarks and
history are saved (as .netrwbook and
.netrwhist).
+ Netrw uses |expand()|on the string.
default: the first directory on the
|'runtimepath'|
default: (if ssh is executable)
"ssh HOSTNAME ls -FLa"
- *g:netrw_list_cmd_options* If this variable exists, then its contents are
+ *g:netrw_list_cmd_options* If this variable exists, then its contents are
appended to the g:netrw_list_cmd. For
example, use "2>/dev/null" to get rid of banner
messages on unix systems.
let g:netrw_list_hide= netrw_gitignore#Hide().'.*\.swp$'
default: ""
- *g:netrw_localcopycmd* ="cp" Linux/Unix/MacOS/Cygwin
- ="copy" Windows
+ *g:netrw_localcopycmd* ="cp" Linux/Unix/MacOS/Cygwin
+ =expand("$COMSPEC") Windows
Copies marked files (|netrw-mf|) to target
directory (|netrw-mt|, |netrw-mc|)
- *g:netrw_localcopydircmd* ="cp -R" Linux/Unix/MacOS/Cygwin
- ="xcopy /e /c /h/ /i /k" Windows
+ *g:netrw_localcopycmdopt* ='' Linux/Unix/MacOS/Cygwin
+ =' \c copy' Windows
+ Options for the |g:netrw_localcopycmd|
+
+ *g:netrw_localcopydircmd* ="cp" Linux/Unix/MacOS/Cygwin
+ =expand("$COMSPEC") Windows
Copies directories to target directory.
(|netrw-mc|, |netrw-mt|)
- *g:netrw_localmkdir* command for making a local directory
- default: "mkdir"
+ *g:netrw_localcopydircmdopt* =" -R" Linux/Unix/MacOS/Cygwin
+ =" /c xcopy /e /c /h/ /i /k" Windows
+ Options for |g:netrw_localcopydircmd|
- *g:netrw_localmovecmd* ="mv" Linux/Unix/MacOS/Cygwin
- ="move" Windows
+ *g:netrw_localmkdir* ="mkdir" Linux/Unix/MacOS/Cygwin
+ =expand("$COMSPEC") Windows
+ command for making a local directory
+
+ *g:netrw_localmkdiropt* ="" Linux/Unix/MacOS/Cygwin
+ =" /c mkdir" Windows
+ Options for |g:netrw_localmkdir|
+
+ *g:netrw_localmovecmd* ="mv" Linux/Unix/MacOS/Cygwin
+ =expand("$COMSPEC") Windows
Moves marked files (|netrw-mf|) to target
directory (|netrw-mt|, |netrw-mm|)
- *g:netrw_localrmdir* remove directory command (rmdir)
- default: "rmdir"
+ *g:netrw_localmovecmdopt* ="" Linux/Unix/MacOS/Cygwin
+ =" /c move" Windows
+ Options for |g:netrw_localmovecmd|
+
+ *g:netrw_localrmdir* ="rmdir" Linux/Unix/MacOS/Cygwin
+ =expand("$COMSPEC") Windows
+ Remove directory command (rmdir)
+ This variable is only used if your vim is
+ earlier than 7.4 or if your vim doesn't
+ have patch#1107. Otherwise, |delete()|
+ is used with the "d" option.
+
+ *g:netrw_localrmdiropt* ="" Linux/Unix/MacOS/Cygwin
+ =" /c rmdir" Windows
+ Options for |g:netrw_localrmdir|
*g:netrw_maxfilenamelen* =32 by default, selected so as to make long
listings fit on 80 column displays.
netrwTilde : *
netrwTmp : tmp* *tmp
- These syntax highlighting groups are linked
- to Folded or DiffChange by default
- (see |hl-Folded| and |hl-DiffChange|), but
- one may put lines like >
+ In addition, those groups mentioned in
+ |'suffixes'| are also added to the special
+ file highlighting group.
+ These syntax highlighting groups are linked
+ to netrwGray or Folded by default
+ (see |hl-Folded|), but one may put lines like >
hi link netrwCompress Visual
< into one's <.vimrc> to use one's own
preferences. Alternatively, one may
- put such specifications into
- .vim/after/syntax/netrw.vim.
-
- As an example, I myself use a dark-background
+ put such specifications into >
+ .vim/after/syntax/netrw.vim.
+< The netrwGray highlighting is set up by
+ netrw when >
+ * netrwGray has not been previously
+ defined
+ * the gui is running
+< As an example, I myself use a dark-background
colorscheme with the following in
.vim/after/syntax/netrw.vim: >
Renaming files and directories involves moving the cursor to the
file/directory to be moved (renamed) and pressing "R". You will then be
- queried for what you want the file/directory to be renamed to You may select
- a range of lines with the "V" command (visual selection), and then
+ queried for what you want the file/directory to be renamed to. You may
+ select a range of lines with the "V" command (visual selection), and then
press "R"; you will be queried for each file as to what you want it
renamed to.
Note that moving files is a dangerous operation; copies are safer. That's
because a "move" for remote files is actually a copy + delete -- and if
- the copy fails and the delete does not, you may lose the file.
+ the copy fails and the delete succeeds you may lose the file.
Use at your own risk.
-The g:netrw_rename_cmd variable is used to implement remote renaming. By
-default its value is:
+The *g:netrw_rename_cmd* variable is used to implement remote renaming. By
+default its value is: >
ssh HOSTNAME mv
-
+<
One may rename a block of files and directories by selecting them with
-V (|linewise-visual|) when using thin style
+V (|linewise-visual|) when using thin style.
+
+See |cmdline-editing| for more on how to edit the command line; in particular,
+you'll find <ctrl-f> (initiates cmdline window editing) and <ctrl-c> (uses the
+command line under the cursor) useful in conjunction with the R command.
SELECTING SORTING STYLE *netrw-s* *netrw-sort* {{{2
window.
* C : by itself, will select the current window holding a netrw buffer
- for editing via |netrw-cr|. The C mapping is only available while in
- netrw buffers.
+ for subsequent editing via |netrw-cr|. The C mapping is only available
+ while in netrw buffers.
* [count]C : the count will be used as the window number to be used
for subsequent editing via |netrw-cr|.
Using >
let g:netrw_chgwin= -1
will restore the default editing behavior
-(ie. editing will use the current window).
+(ie. subsequent editing will use the current window).
Related topics: |netrw-cr| |g:netrw_browse_split|
Associated setting variables: |g:netrw_chgwin|
* Else bring up a |:Lexplore| window
-If |g:netrw_usetab| exists or is zero, or if there is a pre-existing mapping
+If |g:netrw_usetab| exists and is zero, or if there is a pre-existing mapping
for <c-tab>, then the <c-tab> will not be mapped. One may map something other
-than a <c-tab>, too: (but you'll still need to have had g:netrw_usetab set) >
+than a <c-tab>, too: (but you'll still need to have had |g:netrw_usetab| set). >
nmap <unique> (whatever) <Plug>NetrwShrink
<
fun! ExampleUserMapFunc(islocal)
<
-where a:islocal is 1 if it's a local-directory system call or 0 when
+where a:islocal is 1 if its a local-directory system call or 0 when
remote-directory system call.
+ *netrw-call* *netrw-expose* *netrw-modify*
Use netrw#Expose("varname") to access netrw-internal (script-local)
variables.
Use netrw#Modify("varname",newvalue) to change netrw-internal variables.
*netrw-p16*
P16. When editing remote files (ex. :e ftp://hostname/path/file),
- under Windows I get an |E303| message complaining that it's unable
+ under Windows I get an |E303| message complaining that its unable
to open a swap file.
(romainl) It looks like you are starting Vim from a protected
P21. I've made a directory (or file) with an accented character, but
netrw isn't letting me enter that directory/read that file:
- It's likely that the shell or o/s is using a different encoding
+ Its likely that the shell or o/s is using a different encoding
than you have vim (netrw) using. A patch to vim supporting
"systemencoding" may address this issue in the future; for
now, just have netrw use the proper encoding. For example: >
==============================================================================
12. History *netrw-history* {{{1
+ v162: Sep 19, 2016 * (haya14busa) pointed out two syntax errors
+ with a patch; these are now fixed.
+ Oct 26, 2016 * I started using mate-terminal and found that
+ x and gx (|netrw-x| and |netrw-gx|) were no
+ longer working. Fixed (using atril when
+ $DESKTOP_SESSION is "mate").
+ Nov 04, 2016 * (Martin Vuille) pointed out that @+ was
+ being restored with keepregstar rather than
+ keepregplus.
+ Nov 09, 2016 * Broke apart the command from the options,
+ mostly for Windows. Introduced new netrw
+ settings: |g:netrw_localcopycmdopt|
+ |g:netrw_localcopydircmdopt| |g:netrw_localmkdiropt|
+ |g:netrw_localmovecmdopt| |g:netrw_localrmdiropt|
+ Nov 21, 2016 * (mattn) provided a patch for preview; swapped
+ winwidth() with winheight()
+ Nov 22, 2016 * (glacambre) reported that files containing
+ spaces weren't being obtained properly via
+ scp. Fix: apparently using single quotes
+ such as with 'file name' wasn't enough; the
+ spaces inside the quotes also had to be
+ escaped (ie. 'file\ name').
+ * Also fixed obtain (|netrw-O|) to be able to
+ obtain files with spaces in their names
+ Dec 20, 2016 * (xc1427) Reported that using "I" (|netrw-I|)
+ when atop "Hiding" in the banner also caused
+ the active-banner hiding control to occur
+ Jan 03, 2017 * (Enno Nagel) reported that attempting to
+ apply netrw to a directory that was without
+ read permission caused a syntax error.
+ Jan 13, 2017 * (Ingo Karkat) provided a patch which makes
+ using netrw#Call() better. Now returns
+ value of internal routines return, for example.
+ Jan 13, 2017 * (Ingo Karkat) changed netrw#FileUrlRead to
+ use |:edit| instead of |:read|. I also
+ changed the routine name to netrw#FileUrlEdit.
+ Jan 16, 2017 * (Sayem) reported a problem where :Lexplore
+ could generate a new listing buffer and
+ window instead of toggling the netrw display.
+ Unfortunately, the directions for eliciting
+ the problem weren't complete, so I may or
+ may not have fixed that issue.
+ Feb 06, 2017 * Implemented cb and cB. Changed "c" to "cd".
+ (see |netrw-cb|, |netrw-cB|, and |netrw-cd|)
+ Mar 21, 2017 * previously, netrw would specify (safe) settings
+ even when the setting was already safe for
+ netrw. Netrw now attempts to leave such
+ already-netrw-safe settings alone.
+ (affects s:NetrwOptionRestore() and
+ s:NetrwSafeOptions(); also introduced
+ s:NetrwRestoreSetting())
+ Jun 26, 2017 * (Christian Brabandt) provided a patch to
+ allow curl to follow redirects (ie. -L
+ option)
+ Jun 26, 2017 * (Callum Howard) reported a problem with
+ :Lexpore not removing the Lexplore window
+ after a change-directory
+ Aug 30, 2017 * (Ingo Karkat) one cannot switch to the
+ previously edited file (e.g. with CTRL-^)
+ after editing a file:// URL. Patch to
+ have a "keepalt" included.
+ Oct 17, 2017 * (Adam Faryna) reported that gn (|netrw-gn|)
+ did not work on directories in the current
+ tree
+ v157: Apr 20, 2016 * (Nicola) had set up a "nmap <expr> ..." with
+ a function that returned a 0 while silently
+ invoking a shell command. The shell command
+ activated a ShellCmdPost event which in turn
+ called s:LocalBrowseRefresh(). That looks
+ over all netrw buffers for changes needing
+ refreshes. However, inside a |:map-<expr>|,
+ tab and window changes are disallowed. Fixed.
+ (affects netrw's s:LocalBrowseRefresh())
+ * |g:netrw_localrmdir| not used any more, but
+ the relevant patch that causes |delete()| to
+ take over was #1107 (not #1109).
+ * |expand()| is now used on |g:netrw_home|;
+ consequently, g:netrw_home may now use
+ environment variables
+ * s:NetrwLeftmouse and s:NetrwCLeftmouse will
+ return without doing anything if invoked
+ when inside a non-netrw window
+ Jun 15, 2016 * gx now calls netrw#GX() which returns
+ the word under the cursor. The new
+ wrinkle: if one is in a netrw buffer,
+ then netrw's s:NetrwGetWord().
+ Jun 22, 2016 * Netrw was executing all its associated
+ Filetype commands silently; I'm going
+ to try doing that "noisily" and see if
+ folks have a problem with that.
+ Aug 12, 2016 * Changed order of tool selection for
+ handling http://... viewing.
+ (Nikolay Aleksandrovich Pavlov)
+ Aug 21, 2016 * Included hiding/showing/all for tree
+ listings
+ * Fixed refresh (^L) for tree listings
v156: Feb 18, 2016 * Changed =~ to =~# where appropriate
Feb 23, 2016 * s:ComposePath(base,subdir) now uses
fnameescape() on the base portion
tell me how they're useful and should be
retained?
Nov 20, 2015 * Added |netrw-ma| and |netrw-mA| support
- Nov 20, 2015 * gx (|netrw-gx|) on an url downloaded the
+ Nov 20, 2015 * gx (|netrw-gx|) on a URL downloaded the
file in addition to simply bringing up the
- url in a browser. Fixed.
+ URL in a browser. Fixed.
Nov 23, 2015 * Added |g:netrw_sizestyle| support
Nov 27, 2015 * Inserted a lot of <c-u>s into various netrw
maps.