" netrw.vim: Handles file transfer and remote directory listing across a network
" AUTOLOAD PORTION
-" Date: Nov 28, 2005
-" Version: 76
+" Date: Jan 30, 2006
+" Version: 78
" Maintainer: Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz>
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
" Copyright: Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{1
if &cp || exists("g:loaded_netrw")
finish
endif
-let g:loaded_netrw = "v76"
+let g:loaded_netrw = "v78"
if v:version < 700
echohl WarningMsg | echo "***netrw*** you need vim version 7.0 or later for version ".g:loaded_netrw." of netrw" | echohl None
finish
set cpo&vim
" call Decho("doing autoload/netrw.vim")
+" ======================
+" Netrw Variables: {{{1
+" ======================
+
" ---------------------------------------------------------------------
-" Default values for netrw's global protocol variables {{{1
+" Default values for netrw's global protocol variables {{{2
if !exists("g:netrw_dav_cmd")
let g:netrw_dav_cmd = "cadaver"
endif
endif
" ---------------------------------------------------------------------
-" Default values for netrw's global variables {{{1
-" Default values - a-c ---------- {{{2
+" Default values for netrw's global variables {{{2
+" Default values - a-c ---------- {{{3
if !exists("g:netrw_alto")
let g:netrw_alto= 0
endif
if !exists("g:netrw_altv")
let g:netrw_altv= 0
endif
+if !exists("g:netrw_browse_split")
+ let g:netrw_browse_split= 0
+endif
if !exists("g:netrw_cygwin")
if has("win32") || has("win95") || has("win64") || has("win16")
if &shell == "bash"
let g:netrw_cygwin= 0
endif
endif
-" Default values - d-f ---------- {{{2
+" Default values - d-f ---------- {{{3
if !exists("g:NETRW_DIRHIST_CNT")
let g:NETRW_DIRHIST_CNT= 0
endif
if !exists("g:netrw_ftpmode")
let g:netrw_ftpmode= "binary"
endif
-" Default values - h-lh ---------- {{{2
+" Default values - h-lh ---------- {{{3
if !exists("g:netrw_hide")
let g:netrw_hide= 1
endif
if !exists("g:netrw_list_hide")
let g:netrw_list_hide= ""
endif
-" Default values - lh-lz ---------- {{{2
+" Default values - lh-lz ---------- {{{3
if !exists("g:netrw_local_mkdir")
let g:netrw_local_mkdir= "mkdir"
endif
if g:netrw_longlist == 1
let g:netrw_list_cmd= g:netrw_list_cmd." -l"
endif
-" Default values - m-r ---------- {{{2
+" Default values - m-r ---------- {{{3
if !exists("g:netrw_maxfilenamelen")
let g:netrw_maxfilenamelen= 32
endif
if !exists("g:netrw_rmf_cmd")
let g:netrw_rmf_cmd = g:netrw_ssh_cmd." HOSTNAME rm -f"
endif
-" Default values - s ---------- {{{2
+" Default values - s ---------- {{{3
if exists("g:netrw_silent") && g:netrw_silent != 0
let g:netrw_silentxfer= "silent "
else
if !exists("g:netrw_ssh_browse_reject")
let g:netrw_ssh_browse_reject='^total\s\+\d\+$'
endif
-" Default values - t-w ---------- {{{2
+" Default values - t-w ---------- {{{3
if !exists("g:netrw_timefmt")
let g:netrw_timefmt= "%c"
endif
let g:netrw_winsize= ""
endif
" ---------------------------------------------------------------------
-" Default values for netrw's script variables: {{{1
+" Default values for netrw's script variables: {{{2
if !exists("s:netrw_cd_escape")
if has("win32") || has("win95") || has("win64") || has("win16")
let s:netrw_cd_escape="#% "
" files read by network transfer aren't appropriately highlighted.
"let g:decho_bufenter = 1 "Decho
+" ==============================
+" Netrw Utility Functions: {{{1
+" ==============================
+
" ------------------------------------------------------------------------
-" NetSavePosn: saves position of cursor on screen {{{1
+" NetSavePosn: saves position of cursor on screen {{{2
fun! netrw#NetSavePosn()
" call Dfunc("NetSavePosn()")
" Save current line and column
endfun
" ------------------------------------------------------------------------
-" NetRestorePosn: restores the cursor and file position as saved by NetSavePosn() {{{1
+" NetRestorePosn: restores the cursor and file position as saved by NetSavePosn() {{{2
fun! netrw#NetRestorePosn()
" call Dfunc("NetRestorePosn() winnr=".w:netrw_winnr." line=".w:netrw_line." col=".w:netrw_col." hline=".w:netrw_hline)
let eikeep= &ei
" call Dret("NetRestorePosn")
endfun
+" ===============================
+" Netrw Transfer Functions: {{{1
+" ===============================
+
" ------------------------------------------------------------------------
-" NetRead: responsible for reading a file over the net {{{1
+" NetRead: responsible for reading a file over the net {{{2
fun! netrw#NetRead(...)
" call Dfunc("NetRead(a:1<".a:1.">)")
" save options
call s:NetOptionSave()
- " Special Exception: if a file is named "0r", then
+ " Special Exception: if a file is named "0r", then {{{3
" "0r" will be used to read the
" following files instead of "r"
if a:0 == 0
let ichoice = 1
endif
- " get name of a temporary file and set up shell-quoting character
+ " get name of a temporary file and set up shell-quoting character {{{3
let tmpfile= tempname()
let tmpfile= substitute(tmpfile,'\','/','ge')
if !isdirectory(substitute(tmpfile,'[^/]\+$','','e'))
let tmpfile = fnamemodify(tmpfile,':t')
endif
- " Determine method of read (ftp, rcp, etc)
+ " Determine method of read (ftp, rcp, etc) {{{3
call s:NetMethod(choice)
" Check if NetBrowse() should be handling this request
endif
" use filename's suffix for the temporary file
- if b:netrw_fname =~ '\.[^./]\+'
- let suffix = substitute(b:netrw_fname,'^.*\(\.[^./]\+\)','\1','e')
+ if b:netrw_fname =~ '\.[^./]\+$'
+ let suffix = substitute(b:netrw_fname,'^.*\(\.[^./]\+\)$','\1','e')
let tmpfile= substitute(tmpfile,"$",suffix,'e')
-" call Decho("chgd tmpfile<".tmpfile."> (added ".suffix." suffix)")
+" call Decho("chgd tmpfile<".tmpfile."> (added ".suffix." suffix) netrw_fname<".b:netrw_fname.">")
endif
" ============
- " Perform Read
- " ============
+ " Perform Protocol-Based Read {{{3
+ " ===========================
if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1
echo "(netrw) Processing your read request..."
endif
".........................................
- " rcp: NetRead Method #1
+ " rcp: NetRead Method #1 {{{3
if b:netrw_method == 1 " read with rcp
" call Decho("read via rcp (method #1)")
" ER: noting done with g:netrw_uid yet?
let b:netrw_lastfile = choice
".........................................
- " ftp + <.netrc>: NetRead Method #2
+ " ftp + <.netrc>: NetRead Method #2 {{{3
elseif b:netrw_method == 2 " read with ftp + <.netrc>
" call Decho("read via ftp+.netrc (method #2)")
let netrw_fname= b:netrw_fname
let b:netrw_lastfile = choice
".........................................
- " ftp + machine,id,passwd,filename: NetRead Method #3
+ " ftp + machine,id,passwd,filename: NetRead Method #3 {{{3
elseif b:netrw_method == 3 " read with ftp + machine, id, passwd, and fname
" Construct execution string (four lines) which will be passed through filter
" call Decho("read via ftp+mipf (method #3)")
let b:netrw_lastfile = choice
".........................................
- " scp: NetRead Method #4
+ " scp: NetRead Method #4 {{{3
elseif b:netrw_method == 4 " read with scp
" call Decho("read via scp (method #4)")
if exists("g:netrw_port") && g:netrw_port != ""
endif
if g:netrw_cygwin == 1
let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
-" call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile)
- exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile
+" call Decho("executing: !".g:netrw_scp_cmd.useport." '".g:netrw_machine.":".escape(b:netrw_fname,' ?&')."' ".cygtmpfile)
+ exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." '".g:netrw_machine.":".escape(b:netrw_fname,' ?&')."' ".cygtmpfile
else
-" call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile)
- exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile
+" call Decho("executing: !".g:netrw_scp_cmd.useport." '".g:netrw_machine.":".escape(b:netrw_fname,' ?&')."' ".tmpfile)
+ exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." '".g:netrw_machine.":".escape(b:netrw_fname,' ?&')."' ".tmpfile
endif
let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
let b:netrw_lastfile = choice
".........................................
- elseif b:netrw_method == 5 " read with http (wget)
+ " http: NetRead Method #5 (wget) {{{3
+ elseif b:netrw_method == 5
" call Decho("read via http (method #5)")
if g:netrw_http_cmd == ""
if !exists("g:netrw_quiet")
let b:netrw_lastfile = choice
".........................................
- " cadaver: NetRead Method #6
- elseif b:netrw_method == 6 " read with cadaver
+ " cadaver: NetRead Method #6 {{{3
+ elseif b:netrw_method == 6
" call Decho("read via cadaver (method #6)")
" Construct execution string (four lines) which will be passed through filter
let b:netrw_lastfile = choice
".........................................
- " rsync: NetRead Method #7
- elseif b:netrw_method == 7 " read with rsync
+ " rsync: NetRead Method #7 {{{3
+ elseif b:netrw_method == 7
" call Decho("read via rsync (method #7)")
if g:netrw_cygwin == 1
let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
let b:netrw_lastfile = choice
".........................................
- " fetch: NetRead Method #8
+ " fetch: NetRead Method #8 {{{3
" fetch://[user@]host[:http]/path
- elseif b:netrw_method == 8 " read with fetch
+ elseif b:netrw_method == 8
if g:netrw_fetch_cmd == ""
if !exists("g:netrw_quiet")
echohl Error | echo "***netrw*** fetch command not available" | echohl None
let b:netrw_lastfile = choice
".........................................
- " sftp: NetRead Method #9
- elseif b:netrw_method == 9 " read with sftp
+ " sftp: NetRead Method #9 {{{3
+ elseif b:netrw_method == 9
" call Decho("read via sftp (method #4)")
if g:netrw_cygwin == 1
let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
let b:netrw_lastfile = choice
".........................................
- else " Complain
+ " Complain {{{3
+ else
echo "***warning*** unable to comply with your request<" . choice . ">"
endif
endwhile
- " cleanup
+ " cleanup {{{3
" call Decho("cleanup")
if exists("b:netrw_method")
unlet b:netrw_method
endfun
" ------------------------------------------------------------------------
-" NetGetFile: Function to read temporary file "tfile" with command "readcmd". {{{1
+" NetGetFile: Function to read temporary file "tfile" with command "readcmd". {{{2
fun! s:NetGetFile(readcmd, tfile, method)
" call Dfunc("NetGetFile(readcmd<".a:readcmd.">,tfile<".a:tfile."> method<".a:method.">)")
elseif rfile =~ '\.tar$'
call tar#Browse(tfile)
else
+" call Decho("edit temporary file")
e
endif
" rename buffer back to remote filename
- keepalt exe "file ".rfile
+ keepalt exe "file ".escape(rfile,' ')
filetype detect
-" call Dredir("ls!","renamed buffer back to remote filename<".rfile.">")
+" call Dredir("ls!","renamed buffer back to remote filename<".rfile."> : expand(%)<".expand("%").">")
let line1 = 1
let line2 = line("$")
endfun
" ------------------------------------------------------------------------
-" NetWrite: responsible for writing a file over the net {{{1
+" NetWrite: responsible for writing a file over the net {{{2
fun! netrw#NetWrite(...) range
" call Dfunc("NetWrite(a:0=".a:0.")")
let mod= 0
call s:NetOptionSave()
- " Get Temporary Filename
+ " Get Temporary Filename {{{3
let tmpfile= tempname()
if !isdirectory(substitute(tmpfile,'[^/]\+$','','e'))
echohl Error | echo "***netrw*** your ".substitute(tmpfile,'[^/]\+$','','e')." directory is missing!"
while ichoice <= a:0
+ " Process arguments: {{{3
" attempt to repeat with previous host-file-etc
if exists("b:netrw_lastfile") && a:0 == 0
" call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">")
let tmpfile = fnamemodify(tmpfile,':t')
endif
- " Determine method of read (ftp, rcp, etc)
+ " Determine method of read (ftp, rcp, etc) {{{3
call s:NetMethod(choice)
" =============
- " Perform Write
- " =============
+ " Perform Protocol-Based Write {{{3
+ " ============================
if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1
echo "(netrw) Processing your write request..."
endif
".........................................
- " rcp: NetWrite Method #1
- if b:netrw_method == 1 " write with rcp
+ " rcp: NetWrite Method #1 {{{3
+ if b:netrw_method == 1
" call Decho("write via rcp (method #1)")
if s:netrw_has_nt_rcp == 1
if exists("g:netrw_uid") && ( g:netrw_uid != "" )
let b:netrw_lastfile = choice
".........................................
- " ftp + <.netrc>: NetWrite Method #2
- elseif b:netrw_method == 2 " write with ftp + <.netrc>
+ " ftp + <.netrc>: NetWrite Method #2 {{{3
+ elseif b:netrw_method == 2
let netrw_fname = b:netrw_fname
new
setlocal ff=unix
let b:netrw_lastfile = choice
".........................................
- " ftp + machine, id, passwd, filename: NetWrite Method #3
- elseif b:netrw_method == 3 " write with ftp + machine, id, passwd, and fname
+ " ftp + machine, id, passwd, filename: NetWrite Method #3 {{{3
+ elseif b:netrw_method == 3
let netrw_fname= b:netrw_fname
new
setlocal ff=unix
bd!
".........................................
- " scp: NetWrite Method #4
- elseif b:netrw_method == 4 " write with scp
+ " scp: NetWrite Method #4 {{{3
+ elseif b:netrw_method == 4
if exists("g:netrw_port") && g:netrw_port != ""
let useport= " -P ".g:netrw_port
else
endif
if g:netrw_cygwin == 1
let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
-" call Decho("executing: !".g:netrw_scp_cmd.useport." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&'))
- exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')
+" call Decho("executing: !".g:netrw_scp_cmd.useport." ".cygtmpfile." '".g:netrw_machine.":".escape(b:netrw_fname,' ?&')."'")
+ exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".cygtmpfile." '".g:netrw_machine.":".escape(b:netrw_fname,' ?&')."'"
else
-" call Decho("executing: !".g:netrw_scp_cmd.useport." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&'))
- exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')
+" call Decho("executing: !".g:netrw_scp_cmd.useport." ".tmpfile." '".g:netrw_machine.":".escape(b:netrw_fname,' ?&')."'")
+ exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".tmpfile." '".g:netrw_machine.":".escape(b:netrw_fname,' ?&')."'"
endif
let b:netrw_lastfile = choice
".........................................
- " http: NetWrite Method #5
+ " http: NetWrite Method #5 {{{3
elseif b:netrw_method == 5
if !exists("g:netrw_quiet")
echohl Error | echo "***netrw*** currently <netrw.vim> does not support writing using http:" | echohl None
endif
".........................................
- " dav: NetWrite Method #6
- elseif b:netrw_method == 6 " write with cadaver
+ " dav: NetWrite Method #6 (cadaver) {{{3
+ elseif b:netrw_method == 6
" call Decho("write via cadaver (method #6)")
" Construct execution string (four lines) which will be passed through filter
let b:netrw_lastfile = choice
".........................................
- " rsync: NetWrite Method #7
- elseif b:netrw_method == 7 " write with rsync
+ " rsync: NetWrite Method #7 {{{3
+ elseif b:netrw_method == 7
if g:netrw_cygwin == 1
let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
" call Decho("executing: !".g:netrw_rsync_cmd." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&'))
let b:netrw_lastfile = choice
".........................................
- " scp: NetWrite Method #9
- elseif b:netrw_method == 9 " write with sftp
+ " sftp: NetWrite Method #9 {{{3
+ elseif b:netrw_method == 9
let netrw_fname= b:netrw_fname
if exists("g:netrw_uid") && ( g:netrw_uid != "" )
let uid_machine = g:netrw_uid .'@'. g:netrw_machine
let b:netrw_lastfile= choice
".........................................
- else " Complain
+ " Complain {{{3
+ else
echo "***warning*** unable to comply with your request<" . choice . ">"
endif
endwhile
- " cleanup
+ " cleanup {{{3
" call Decho("cleanup")
let result=delete(tmpfile)
call s:NetOptionRestore()
" Remote Directory Browsing Support: {{{1
" ===========================================
+" ---------------------------------------------------------------------
" NetBrowse: This function uses the command in g:netrw_list_cmd to get a list {{{2
" of the contents of a remote directory. It is assumed that the
" g:netrw_list_cmd has a string, HOSTNAME, that needs to be substituted
" call Decho("exe file ".escape(bufname,s:netrw_cd_escape))
exe 'file '.escape(bufname,s:netrw_cd_escape)
" call Decho("renaming file to bufname<".bufname.">")
- setlocal bh=hide bt=nofile nobl nonu
+ setlocal bh=hide bt=nofile nobl nonu noswf
" save current directory on directory history list
- call <SID>NetBookmarkDir(3,expand("%"))
+ call s:NetBookmarkDir(3,expand("%"))
" set up buffer-local mappings
" call Decho("set up buffer-local mappings")
nnoremap <buffer> <silent> i :call <SID>NetLongList(0)<cr>
nnoremap <buffer> <silent> o :call <SID>NetSplit(0)<cr>
nnoremap <buffer> <silent> O :call <SID>NetObtain()<cr>
+ nnoremap <buffer> <silent> P :call <SID>NetPrevWinOpen(0)<cr>
nnoremap <buffer> <silent> q :<c-u>call <SID>NetBookmarkDir(2,expand("%"))<cr>
nnoremap <buffer> <silent> r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./'))<cr>
nnoremap <buffer> <silent> s :call <SID>NetSaveWordPosn()<bar>let g:netrw_sort_by= (g:netrw_sort_by =~ 'n')? 'time' : (g:netrw_sort_by =~ 't')? 'size' : 'name'<bar>exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./'))<bar>call <SID>NetRestoreWordPosn()<cr>
nnoremap <buffer> <silent> u :<c-u>call <SID>NetBookmarkDir(4,expand("%"))<cr>
nnoremap <buffer> <silent> U :<c-u>call <SID>NetBookmarkDir(5,expand("%"))<cr>
nnoremap <buffer> <silent> v :call <SID>NetSplit(1)<cr>
- nnoremap <buffer> <silent> x :call <SID>NetBrowseX(<SID>NetBrowseChgDir(expand("%"),<SID>NetGetWord()),1)<cr>
+ nnoremap <buffer> <silent> x :call netrw#NetBrowseX(<SID>NetBrowseChgDir(expand("%"),<SID>NetGetWord()),1)<cr>
nnoremap <buffer> <silent> <2-leftmouse> :call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),<SID>NetGetWord()))<cr>
exe 'nnoremap <buffer> <silent> <del> :call <SID>NetBrowseRm("'.user.machine.'","'.path.'")<cr>'
exe 'vnoremap <buffer> <silent> <del> :call <SID>NetBrowseRm("'.user.machine.'","'.path.'")<cr>'
if newdir !~ '[\/]$'
" handling a file
let dirname= dirname.newdir
+ if g:netrw_browse_split == 1
+ new
+ wincmd _
+ elseif g:netrw_browse_split == 2
+ rightb vert new
+ wincmd |
+ endif
" call Decho("handling a file: dirname<".dirname.">")
elseif newdir == './'
endfun
" ---------------------------------------------------------------------
-" NetGetWord: it gets the directory named under the cursor
+" NetGetWord: it gets the directory named under the cursor {{{2
fun! s:NetGetWord()
" call Dfunc("NetGetWord() line#".line("."))
call s:UseBufWinVars()
" refresh the directory
let curline= line(".")-1
" call Decho("refresh the directory")
- call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./'))
+ call s:NetBrowse(s:NetBrowseChgDir(expand("%"),'./'))
exe curline
" call Dret("NetBrowseRm")
" refresh the directory
let curline= line(".")
- call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./'))
+ call s:NetBrowse(s:NetBrowseChgDir(expand("%"),'./'))
exe "keepjumps ".curline
" call Dret("NetBrowseRename")
endfun
" =2 : local and o
" =3 : local and v
fun! s:NetSplit(mode)
-" call Dfunc("NetSplit(mode=".a:mode.")")
+" call Dfunc("NetSplit(mode=".a:mode.") alto=".g:netrw_alto." altv=".g:netrw_altv)
call s:SaveWinVars()
if a:mode == 0
exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s"
call s:CopyWinVars()
exe "norm! 0"
- call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),<SID>NetGetWord()))
+ call s:NetBrowse(s:NetBrowseChgDir(expand("%"),s:NetGetWord()))
elseif a:mode ==1
exe (g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v"
call s:CopyWinVars()
exe "norm! 0"
- call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),<SID>NetGetWord()))
+ call s:NetBrowse(s:NetBrowseChgDir(expand("%"),s:NetGetWord()))
elseif a:mode ==2
exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s"
call s:CopyWinVars()
exe "norm! 0"
- call s:LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord()))
+ call s:LocalBrowse(s:LocalBrowseChgDir(b:netrw_curdir,s:NetGetWord()))
else
exe (g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v"
call s:CopyWinVars()
exe "norm! 0"
- call s:LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord()))
+ call s:LocalBrowse(s:LocalBrowseChgDir(b:netrw_curdir,s:NetGetWord()))
endif
" call Dret("NetSplit")
" ---------------------------------------------------------------------
" NetBrowseX: allows users to write custom functions to operate on {{{2
" files given their extension. Passes 0=local, 1=remote
-fun! s:NetBrowseX(fname,remote)
-" call Dfunc("NetBrowseX(".a:fname." remote=".a:remote.")")
+fun! netrw#NetBrowseX(fname,remote)
+" call Dfunc("NetBrowseX(fname<".a:fname."> remote=".a:remote.")")
" set up the filename
" (lower case the extension, make a local copy of a remote file)
let fname= escape(a:fname,"%#")
" call Decho("fname<".fname."> after escape()")
+ " seems kde systems often have gnome-open due to dependencies, even though
+ " gnome-open's subsidiary display tools are largely absent. Kde systems
+ " usually have "kicker" running, though... (tnx Mikolaj Machowski)
+ if !exists("s:haskicker")
+ if has("unix")
+ let v:shell_error=0
+ silent! let s:haskicker= system('ps -e') =~ 'kicker'
+ if v:shell_error
+ let s:haskicker = 0
+ let v:shell_error = 0
+ endif
+ else
+ let s:haskicker= 0
+ endif
+" call Decho("setting s:haskicker=".s:haskicker)
+ endif
+
if a:remote == 1
" create a local copy
let fname= tempname().".".exten
endif
" call Decho("redir:".redir.":")
+ if exists("g:netrw_browsex_viewer") && executable(g:netrw_browsex_viewer)
+ if g:netrw_browsex_viewer == '-'
+ call netrwFileHandlers#Init()
+ if exten != "" && exists("*netrwFileHandlers#NFH_".exten)
+" call Decho("let ret= netrwFileHandlers#NFH_".exten.'("'.fname.'")')
+ exe "let ret= netrwFileHandlers#NFH_".exten.'("'.fname.'")'
+ endif
+ else
+" call Decho("exe silent !".g:netrw_browsex_viewer." '".escape(fname,'%#')."' ".redir)
+ exe "silent !".g:netrw_browsex_viewer." '".escape(fname,'%#')."'".redir
+ let ret= v:shell_error
+ endif
+
" execute the file handler
- if has("win32") || has("win64")
+ elseif has("win32") || has("win64")
" call Decho('exe silent !start rundll32 url.dll,FileProtocolHandler "'.escape(fname, '%#').'"')
exe 'silent !start rundll32 url.dll,FileProtocolHandler "'.escape(fname, '%#').'"'
let ret= v:shell_error
- elseif has("unix") && executable("gnome-open")
+ elseif has("unix") && executable("gnome-open") && !s:haskicker
" call Decho("exe silent !gnome-open '".escape(fname,'%#')."' ".redir)
exe "silent !gnome-open '".escape(fname,'%#')."'".redir
let ret= v:shell_error
- elseif has("unix") && executable("kfmclient")
+ elseif has("unix") && executable("kfmclient") && s:haskicker
" call Decho("exe silent !kfmclient exec '".escape(fname,'%#')."' ".redir)
exe "silent !kfmclient exec '".escape(fname,'%#')."' ".redir
let ret= v:shell_error
if a:islocal == 0
silent call s:NetBrowse(s:NetBrowseChgDir(expand("%"),'./'))
else
- silent call s:NetRefresh(<SID>LocalBrowseChgDir(b:netrw_curdir,"./"),a:islocal)
+ silent call s:NetRefresh(s:LocalBrowseChgDir(b:netrw_curdir,"./"),a:islocal)
endif
" call Dret("NetHideEdit")
if a:mode == 0
silent call s:NetBrowse(s:NetBrowseChgDir(expand("%"),'./'))
else
- silent call s:LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,"./"))
+ silent call s:LocalBrowse(s:LocalBrowseChgDir(b:netrw_curdir,"./"))
endif
" call Dret("NetSortSequence")
" refresh the listing
if a:mode == 0
- silent call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),"./"))
+ silent call s:NetBrowse(s:NetBrowseChgDir(expand("%"),"./"))
else
- silent call s:LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,"./"))
+ silent call s:LocalBrowse(s:LocalBrowseChgDir(b:netrw_curdir,"./"))
endif
" keep cursor on the filename
" call Dret("NetObtain")
endfun
+" ---------------------------------------------------------------------
+" NetPrevWinOpen: opoen file/directory in previous window. {{{2
+" If there's only one window, then the window will first be split.
+fun! s:NetPrevWinOpen(islocal)
+" call Dfunc("NetPrevWinOpen(islocal=".a:islocal.")")
+
+ " get last window number and the word currently under the cursor
+ let lastwinnr = winnr("$")
+ let curword = s:NetGetWord()
+ let curdir = b:netrw_curdir
+" call Decho("lastwinnr=".lastwinnr." curword<".curword.">")
+
+ let didsplit = 0
+ if lastwinnr == 1
+ " if only one window, open a new one first
+" call Decho("only one window, so open a new one (g:netrw_alto=".g:netrw_alto.")")
+ exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s"
+ let didsplit = 1
+
+ else
+ wincmd p
+ " if the previous window's buffer has been changed (is modified),
+ " and it doesn't appear in any other extant window, then ask the
+ " user if s/he wants to abandon modifications therein.
+ let bnr = winbufnr(0)
+ let bnrcnt = 0
+ if &mod
+ windo if winbufnr(0) == bnr | let bnrcnt=bnrcnt+1 | endif
+" call Decho("bnr=".bnr." bnrcnt=".bnrcnt)
+ if bnrcnt == 1
+ let bufname= bufname(winbufnr(winnr()))
+ let choice= confirm("Save modified file<".bufname.">?","&Yes\n&No\n&Cancel")
+
+ if choice == 1
+ " Yes -- write file & then browse
+ let v:errmsg= ""
+ silent w
+ if v:errmsg != ""
+ echohl Error | echo "***netrw*** "unable to write <".bufname.">!" | echohl None
+ call inputsave()|call input("Press <cr> to continue")|call inputrestore()
+ if didsplit
+ q
+ else
+ wincmd p
+ endif
+" call Dret("NetPrevWinOpen : unable to write <".bufname.">")
+ return
+ endif
+
+ elseif choice == 2
+ " No -- don't worry about changed file, just browse anyway
+ set nomod
+ echohl WarningMsg | echo "***netrw*** ".bufname." changes abandoned" | echohl None
+
+ else
+ " Cancel -- don't do this
+ if didsplit
+ q
+ else
+ wincmd p
+ endif
+" call Dret("NetPrevWinOpen : cancelled")
+ return
+ endif
+ endif
+ endif
+ endif
+
+ if a:islocal
+ call s:LocalBrowse(s:LocalBrowseChgDir(curdir,curword))
+ else
+ call s:NetBrowse(s:NetBrowseChgDir(expand("%"),curword))
+ endif
+" call Dret("NetPrevWinOpen")
+endfun
+
" ==========================================
" Local Directory Browsing Support: {{{1
" ==========================================
" the BufEnter event causes triggering when attempts to write to
" the DBG buffer are made.
if isdirectory(a:dirname)
- call netrw#DirBrowse(a:dirname)
+ silent! call netrw#DirBrowse(a:dirname)
endif
" not a directory, ignore it
endfun
" call Dret("DirBrowse")
return
endif
+
call s:NetOptionSave()
if v:version < 603
endif
" change the name of the buffer to reflect the b:netrw_curdir
+ " Hmm. When another vim is open to the same directory, I get
+ " a "Press ENTER" ... ok, setting "noswf" avoids it.
+" call Decho('exe silent! file '.escape(b:netrw_curdir,s:netrw_cd_escape))
exe 'silent! file '.escape(b:netrw_curdir,s:netrw_cd_escape)
" make this buffer not-a-file, modifiable, not line-numbered, etc
- setlocal bh=hide bt=nofile nobl ma nonu
+ setlocal bh=hide bt=nofile nobl ma nonu noswf
keepalt silent! %d
" ---------------------------
endif
" save current directory on directory history list
- call <SID>NetBookmarkDir(3,b:netrw_curdir)
+ call s:NetBookmarkDir(3,b:netrw_curdir)
" set up all the maps
" call Decho("Setting up local browser maps")
nnoremap <buffer> <silent> o :call <SID>NetSplit(2)<cr>
nnoremap <buffer> <silent> O :call <SID>LocalObtain()<cr>
nnoremap <buffer> <silent> p :call <SID>LocalPreview(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord(),1))<cr>
+ nnoremap <buffer> <silent> P :call <SID>NetPrevWinOpen(1)<cr>
nnoremap <buffer> <silent> q :<c-u>call <SID>NetBookmarkDir(2,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetRefresh(<SID>LocalBrowseChgDir(b:netrw_curdir,'./'),1)<cr>
nnoremap <buffer> <silent> s :call <SID>NetSaveWordPosn()<bar>let g:netrw_sort_by= (g:netrw_sort_by =~ 'n')? 'time' : (g:netrw_sort_by =~ 't')? 'size' : 'name'<bar>exe "norm! 0"<bar>call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,'./'))<bar>call <SID>NetRestoreWordPosn()<cr>
nnoremap <buffer> <silent> u :<c-u>call <SID>NetBookmarkDir(4,expand("%"))<cr>
nnoremap <buffer> <silent> U :<c-u>call <SID>NetBookmarkDir(5,expand("%"))<cr>
nnoremap <buffer> <silent> v :call <SID>NetSplit(3)<cr>
- nnoremap <buffer> <silent> x :call <SID>NetBrowseX(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord(),0),0)"<cr>
+ nnoremap <buffer> <silent> x :call netrw#NetBrowseX(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord(),0),0)"<cr>
nnoremap <buffer> <silent> <2-leftmouse> :call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord()))<cr>
nnoremap <buffer> <silent> <s-up> :Pexplore<cr>
nnoremap <buffer> <silent> <s-down> :Nexplore<cr>
let ft = strpart("000000000000000000",1,18-strlen(t)).t
" call Decho("exe keepjumps put ='".ft.'/'.filename."'")
let ftpfile= ft.'/'.pfile
- keepjumps put=ftpfile
+ keepjumps silent! put=ftpfile
elseif g:netrw_sort_by =~ "^s"
" sort by size (handles file sizes up to 1 quintillion bytes, US)
let fsz = strpart("000000000000000000",1,18-strlen(sz)).sz
" call Decho("exe keepjumps put ='".fsz.'/'.filename."'")
let fszpfile= fsz.'/'.pfile
- keepjumps put =fszpfile
+ keepjumps silent! put =fszpfile
else
" sort by name
" call Decho("exe keepjumps put ='".pfile."'")
- keepjumps put=pfile
+ keepjumps silent! put=pfile
endif
endwhile
if a:0 < 1
" call Decho("dirname<".dirname."> netrw_cd_escape<".s:netrw_cd_escape.">")
" call Decho("about to edit<".escape(dirname,s:netrw_cd_escape).">")
+ if g:netrw_browse_split == 1
+ new
+ wincmd _
+ elseif g:netrw_browse_split == 2
+ rightb vert new
+ wincmd |
+ endif
exe "e! ".escape(dirname,s:netrw_cd_escape)
set ma nomod
endif
" if dosplit or file has been modified
if a:dosplit || &modified
- call <SID>SaveWinVars()
+ call s:SaveWinVars()
if a:style == 0 " Explore, Sexplore
exe g:netrw_winsize."wincmd s"
endfun
" ---------------------------------------------------------------------
-" NetMethod: determine method of transfer {{{1
+" NetMethod: determine method of transfer {{{2
" method == 1: rcp
" 2: ftp + <.netrc>
" 3: ftp + machine, id, password, and [path]filename
endfun
" ------------------------------------------------------------------------
-" NetUserPass: set username and password for subsequent ftp transfer {{{1
+" NetUserPass: set username and password for subsequent ftp transfer {{{2
" Usage: :call NetUserPass() -- will prompt for userid and password
" :call NetUserPass("uid") -- will prompt for password
" :call NetUserPass("uid","password") -- sets global userid and password
endfun
" ------------------------------------------------------------------------
-" NetOptionSave: save options and set to "standard" form {{{1
+" NetOptionSave: save options and set to "standard" form {{{2
fun! s:NetOptionSave()
" call Dfunc("NetOptionSave()")
if !exists("w:netoptionsave")
endfun
" ------------------------------------------------------------------------
-" NetOptionRestore: restore options {{{1
+" NetOptionRestore: restore options {{{2
fun! s:NetOptionRestore()
" call Dfunc("NetOptionRestore()")
if !exists("w:netoptionsave")
endfun
" ------------------------------------------------------------------------
-" NetReadFixup: this sort of function is typically written by the user {{{1
+" NetReadFixup: this sort of function is typically written by the user {{{2
" to handle extra junk that their system's ftp dumps
" into the transfer. This function is provided as an
" example and as a fix for a Windows 95 problem: in my
endif
" ---------------------------------------------------------------------
-" NetSort: Piet Delport's BISort2() function, modified to take a range {{{1
+" NetSort: Piet Delport's BISort2() function, modified to take a range {{{2
if v:version < 700
fun! s:NetSort() range
" " call Dfunc("NetSort()")
endif
" ---------------------------------------------------------------------
-" SetSort: sets up the sort based on the g:netrw_sort_sequence {{{1
+" SetSort: sets up the sort based on the g:netrw_sort_sequence {{{2
" What this function does is to compute a priority for the patterns
" in the g:netrw_sort_sequence. It applies a substitute to any
" "files" that satisfy each pattern, putting the priority / in
endfun
" ---------------------------------------------------------------------
-" SaveWinVars: (used by Explore()) {{{1
+" SaveWinVars: (used by Explore()) {{{2
fun! s:SaveWinVars()
" call Dfunc("SaveWinVars()")
if exists("w:netrw_bannercnt") |let s:bannercnt = w:netrw_bannercnt |endif
endfun
" ---------------------------------------------------------------------
-" CopyWinVars: (used by Explore()) {{{1
+" CopyWinVars: (used by Explore()) {{{2
fun! s:CopyWinVars()
" call Dfunc("CopyWinVars()")
if exists("s:bannercnt") |let w:netrw_bannercnt = s:bannercnt |unlet s:bannercnt |endif
endfun
" ---------------------------------------------------------------------
-" SetBufWinVars: (used by NetBrowse() and LocalBrowse()) {{{1
+" SetBufWinVars: (used by NetBrowse() and LocalBrowse()) {{{2
" To allow separate windows to have their own activities, such as
" Explore **/pattern, several variables have been made window-oriented.
" However, when the user splits a browser window (ex: ctrl-w s), these
endfun
" ---------------------------------------------------------------------
-" UseBufWinVars: (used by NetBrowse() and LocalBrowse() {{{1
+" UseBufWinVars: (used by NetBrowse() and LocalBrowse() {{{2
" Matching function to BufferWinVars()
fun! s:UseBufWinVars()
" call Dfunc("UseBufWinVars()")
endfun
" ---------------------------------------------------------------------
-" RFC2396: converts %xx into characters
+" RFC2396: converts %xx into characters {{{2
fun! netrw#RFC2396(fname)
" call Dfunc("RFC2396(fname<".a:fname.">)")
let fname = escape(substitute(a:fname,'%\(\x\x\)','\=nr2char("0x".submatch(1))','ge')," \t")
endfun
" ------------------------------------------------------------------------
-" Settings Restoration: {{{1
+" Settings Restoration: {{{2
let &cpo= s:keepcpo
unlet s:keepcpo
-*pi_netrw.txt* For Vim version 7.0. Last change: Nov 28, 2005
+*pi_netrw.txt* For Vim version 7.0. Last change: Jan 27, 2006
VIM REFERENCE MANUAL by Charles E. Campbell, Jr.
==============================================================================
0. Contents *netrw-contents*
-1. Netrw Reference......................................|netrw-ref|
+1. Starting With Netrw.................................|netrw-start|
+2. Netrw Reference......................................|netrw-ref|
CONTROLLING EXTERNAL APPLICTIONS...................|netrw-externapp|
READING............................................|netrw-read|
WRITING............................................|netrw-write|
CHANGING THE USERID AND PASSWORD...................|netrw-chgup|
VARIABLES..........................................|netrw-variables|
PATHS..............................................|netrw-path|
-2. Network-Oriented File Transfer.......................|netrw-xfer|
+3. Network-Oriented File Transfer.......................|netrw-xfer|
NETRC..............................................|netrw-netrc|
PASSWORD...........................................|netrw-passwd|
-3. Activation...........................................|netrw-activate|
-4. Transparent File Transfer............................|netrw-transparent|
-5. Ex Commands..........................................|netrw-ex|
-6. Variables and Options................................|netrw-var|
-7. Directory Browsing...................................|netrw-browse| {{{1
+4. Activation...........................................|netrw-activate|
+5. Transparent File Transfer............................|netrw-transparent|
+6. Ex Commands..........................................|netrw-ex|
+7. Variables and Options................................|netrw-var|
+8. Directory Browsing...................................|netrw-browse| {{{1
Maps...............................................|netrw-maps|
Exploring..........................................|netrw-explore-cmds|
Quick Reference Commands Table.....................|netrw-browse-cmds|
Deleting Files Or Directories......................|netrw-delete|
Renaming Files Or Directories......................|netrw-move|
Hiding Files Or Directories........................|netrw-a|
- Edit File Or Directory Hiding List.................|netrw-h|
+ Edit File Or Directory Hiding List.................|netrw-ctrl-h|
Browsing With A Horizontally Split Window..........|netrw-o|
Preview Window.....................................|netrw-p|
Selecting Sorting Style............................|netrw-s|
Changing To A Bookmarked Directory.................|netrw-B| |netrw-NB|
Listing Bookmarks And History......................|netrw-q|
Improving Directory Browsing.......................|netrw-listhack| }}}1
-8. Problems and Fixes...................................|netrw-problems|
-9. Debugging............................................|netrw-debug|
-10. History..............................................|netrw-history|
-11. Credits..............................................|netrw-credits|
+9. Problems and Fixes...................................|netrw-problems|
+10. Debugging............................................|netrw-debug|
+11. History..............................................|netrw-history|
+12. Credits..............................................|netrw-credits|
The Netrw plugin is generally sourced automatically as it is a
|standard-plugin|. That said, to make use of netrw, one must
have plugins available which can be done with the following
-two lines in your <.vimrc>:
+two lines in your <.vimrc>: >
set nocp " 'compatible' is not set
filetype plugin on " plugins are enabled
-
+<
You can avoid loading this plugin by setting the "loaded_netrw" variable
in your <.vimrc> file: >
{Vi does not have any of this}
==============================================================================
-1. Netrw Reference *netrw-ref*
+1. Starting With Netrw *netrw-start*
+
+Netrw makes reading, writing, and browsing over a network connection easy!
+First, make sure that you have plugins enabled, so you'll need to have at
+least the following in your <.vimrc>: (or see |netrw-activate|) >
+
+ set nocp " 'compatible' is not set
+ filetype plugin on " plugins are enabled
+<
+(see |'cp'| and |:filetype-plugin-on|)
+
+Netrw supports "transparent" editing of files on other machines using urls
+(see |netrw-transparent|). As an example of this, let's assume you have an
+account on some other machine; try >
+
+ vim scp://hostname/path/to/file
+<
+if you have an ssh connection. Want to make ssh/scp easier to use? Check
+out |netrw-listhack|!
+
+What if you have ftp, not ssh/scp? That's easy, too; try >
+
+ vim ftp://hostname/path/to/file
+<
+Want to make ftp simpler to use? See if your ftp supports a file called
+<.netrc> -- typically it goes in your home directory, has read/write
+permissions for only the user to read (ie. not group, world, other, etc),
+and has lines resembling >
+
+ machine HOSTNAME login USERID password "PASSWORD"
+ machine HOSTNAME login USERID password "PASSWORD"
+ ...
+ default login USERID password "PASSWORD"
+<
+How about browsing -- ie. you just want to look around before editing a
+file. For browsing on your current host, just "edit" a directory: >
+
+ vim .
+ vim /home/userid/path
+<
+For browsing on a remote host, "edit" a directory (but make sure that
+the directory name is followed by a "/"): >
+
+ vim scp://hostname/
+ vim ftp://hostname/path/to/dir/
+<
+See |netrw-browse| for more!
+
+There's more protocols supported than scp and ftp, too: see the next
+section, |netrw-externapp|.
+
+==============================================================================
+2. Netrw Reference *netrw-ref*
CONTROLLING EXTERNAL APPLICTIONS *netrw-externapp*
Protocol Variable Default Value
-------- ---------------- -------------
dav: *g:netrw_dav_cmd* = "cadaver"
- fetch: *g:netrw_fetch_cmd* = "fetch -o"
+ fetch: *g:netrw_fetch_cmd* = "fetch -o" if fetch is available
ftp: *g:netrw_ftp_cmd* = "ftp"
http: *g:netrw_http_cmd* = "fetch -o" if fetch is available
http: g:netrw_http_cmd = "wget -q -O" If wget is available
<
==============================================================================
-2. Network-Oriented File Transfer *netrw-xfer*
+3. Network-Oriented File Transfer *netrw-xfer*
Network-oriented file transfer under Vim is implemented by a VimL-based script
(<netrw.vim>) using plugin techniques. It currently supports both reading and
==============================================================================
-3. Activation *netrw-activate*
+4. Activation *netrw-activate*
Network-oriented file transfers are available by default whenever
|'nocompatible'| mode is enabled. The <netrw.vim> file resides in your
<
==============================================================================
-4. Transparent File Transfer *netrw-transparent*
+5. Transparent File Transfer *netrw-transparent*
Transparent file transfers occur whenever a regular file read or write
(invoked via an |:autocmd| for |BufReadCmd| or |BufWriteCmd| events) is made.
such as netrw.
==============================================================================
-5. Ex Commands *netrw-ex*
+6. Ex Commands *netrw-ex*
The usual read/write commands are supported. There are also a couple of
additional commands available.
==============================================================================
-6. Variables and Options *netrw-options* *netrw-var*
+7. Variables and Options *netrw-options* *netrw-var*
The script <netrw.vim> uses several variables which can affect <netrw.vim>'s
behavior. These variables typically may be set in the user's <.vimrc> file:
transformed however they wish
by NetReadFixup()
g:netrw_dav_cmd variable ="cadaver"
- g:netrw_fetch_cmd variable ="fetch -o"
+ g:netrw_fetch_cmd variable ="fetch -o" if fetch is available
g:netrw_ftp_cmd variable ="ftp"
- g:netrw_http_cmd variable ="fetch -o" else if fetch is executable
- g:netrw_http_cmd variable ="wget -O" if wget is executable
+ g:netrw_http_cmd variable ="fetch -o" if fetch is available
+ g:netrw_http_cmd variable ="wget -O" else if wget is available
g:netrw_list_cmd variable ="ssh HOSTNAME ls -Fa"
g:netrw_rcp_cmd variable ="rcp"
g:netrw_rsync_cmd variable ="rsync -a"
-------------------------------------------------------------------------
<
*netrw-ftp*
-The first two options both help with certain ftp's that give trouble
-otherwise. In order to best understand how to use these options if ftp is
-giving you troubles, a bit of discussion follows on how netrw does ftp reads.
+The first two options (netrw_ftp and NetReadFixup) both help with certain
+ftp's that give trouble otherwise. In order to best understand how to use
+these options if ftp is giving you troubles, a bit of discussion follows on
+how netrw does ftp reads.
The g:netrw_..._cmd variables specify the external program to use handle the
associated protocol (rcp, ftp, etc), plus any options.
>
==============================================================================
-7. Directory Browsing *netrw-browse* *netrw-dir* *netrw-list* *netrw-help*
+8. Directory Browsing *netrw-browse* *netrw-dir* *netrw-list* *netrw-help*
MAPS *netrw-maps*
?................Help.......................................|netrw-help|
c................Make Browsing Directory The Current Dir....|netrw-c|
d................Make A New Directory.......................|netrw-d|
D................Deleting Files or Directories..............|netrw-D|
- <c-h>............Edit File/Directory Hiding List............|netrw-h|
+ <c-h>............Edit File/Directory Hiding List............|netrw-ctrl-h|
i................Long Listing...............................|netrw-i|
<c-l>............Refreshing the Listing.....................|netrw-ctrl-l|
o................Browsing with a Horizontal Split...........|netrw-o|
Command Explanation
------- -----------
< ? Causes Netrw to issue help
- <cr> Netrw will enter the directory or read the file
- <del> Netrw will attempt to remove the file/directory
- d Make a directory
- D Netrw will attempt to remove the file(s)/directory(ies)
- R Netrw will attempt to rename the file(s)/directory(ies)
- - Makes Netrw go up one directory
- a Toggles between normal display,
- hiding (suppress display of files matching g:netrw_list_hide)
- showing (display only files which match g:netrw_list_hide)
- c Make current browsing directory the current directory
- <c-h> Edit file hiding list
- i Toggles between long and short listing
- <c-l> Causes Netrw to refresh the directory listing
+ <cr> Netrw will enter the directory or read the file |netrw-cr|
+ <del> Netrw will attempt to remove the file/directory |netrw-del|
+ - Makes Netrw go up one directory |netrw--|
+ a Toggles between normal display, |netrw-a|
+ hiding (suppress display of files matching g:netrw_list_hide)
+ showing (display only files which match g:netrw_list_hide)
+ b bookmark current directory; use Nb if compact listing
+ in use |netrw-b|
+ B go to previous bookmarked directory; use Nb if compact
+ listing is in use |netrw-B|
+ c Make current browsing directory the current directory |netrw-c|
+ d Make a directory |netrw-d|
+ D Netrw will attempt to remove the file(s)/directory(ies) |netrw-D|
+ <c-h> Edit file hiding list |netrw-ctrl-h|
+ i Toggles between long and short listing |netrw-i|
+ <c-l> Causes Netrw to refresh the directory listing |netrw-ctrl-l|
+ Nb Same as b, but always available |netrw-Nb|
+ NB Same as B, but always available |netrw-NB|
o Enter the file/directory under the cursor in a new browser
- window. A horizontal split is used.
- p Preview the file
- r Reverse sorting order
- s Select sorting style: by name, time, or file size
+ window. A horizontal split is used. |netrw-o|
+ O Obtain a file specified by cursor |netrw-O|
+ p Preview the file |netrw-p|
+ P Browse in the previously used window |netrw-P|
+ r Reverse sorting order |netrw-r|
+ R Rename the designed file(s)/directory(ies) |netrw-R|
+ s Select sorting style: by name, time, or file size |netrw-s|
+ S Specify suffix priority for name-sorting |netrw-S|
+ u Change to recently-visited directory |netrw-u|
+ U Change to subsequently-visited directory |netrw-U|
v Enter the file/directory under the cursor in a new browser
- window. A vertical split is used.
- x Apply a function to a file.
+ window. A vertical split is used. |netrw-v|
+ x Apply a function to a file. (special browsers) |netrw-x|
NETRW BROWSER VARIABLES *netrw-browse-var*
>
by setting this variable (see |netrw-v|)
default: =0
+ *g:netrw_browse_split* when browsing, <cr> will open the file by:
+ =0: re-using the same window
+ =1: horizontally splitting the window first
+ =2: vertically splitting the window first
+ *g:netrw_browsex_viewer* specify user's preference for a viewer: >
+ "kfmclient exec"
+ "gnome-open"
+< If >
+ "-"
+< is used, then netrwFileHandler() will look for
+ a script/function to handle the given
+ extension. (see |netrw_filehandler|).
+<
*g:netrw_ftp_browse_reject* ftp can produce a number of errors and warnings
that can show up as "directories" and "files"
in the listing. This pattern is used to
or more spaces embedded in it, or any trailing spaces, then you'll need to
use the "thin" format to select it.
+The |g:netrw_browse_split| option, which is zero by default, may be used to
+cause the opening of files to be done in a new window. The splitting will
+be done horizontally if the option is one and vertically if the option is
+two.
+
OBTAINING A FILE *netrw-O*
a file or a directory) will be detected, reported on, and ignored.
-DELETING FILES OR DIRECTORIES *netrw-delete* *netrw-D*
+DELETING FILES OR DIRECTORIES *netrw-delete* *netrw-D* *netrw-del*
Deleting/removing files and directories involves moving the cursor to the
file/directory to be deleted and pressing "D". Directories must be empty
match. The "a" map allows the user to cycle about these three ways.
The g:netrw_list_hide variable holds a comma delimited list of patterns (ex.
-\.obj) which specify the hiding list. (also see |netrw-h|) To set the hiding
+\.obj) which specify the hiding list. (also see |netrw-ctrl-h|) To set the hiding
list, use the <c-h> map. As an example, to hide files which begin with a ".",
one may use the <c-h> map to set the hiding list to '^\..*' (or one may put
let g:netrw_list_hide= '^\..*' in one's <.vimrc>). One may then use the "a"
files.
-EDIT FILE OR DIRECTORY HIDING LIST *netrw-h* *netrw-edithide*
+EDIT FILE OR DIRECTORY HIDING LIST *netrw-ctrl-h* *netrw-edithide*
The "<ctrl-h>" map brings up a requestor allowing the user to change the
file/directory hiding list. The hiding list consists of one or more patterns
"p" key when the cursor is atop the desired filename to be previewed.
+PREVIOUS WINDOW *netrw-P* *netrw-prvwin*
+
+To edit a file or directory in the previously used window (see :he |CTRL-W_P|),
+press a "P". If there's only one window, then the one window will be
+horizontally split (above/below splitting is controlled by |g:netrw_alto|,
+and its initial size is controlled by |g:netrw_winsize|).
+
+If there's more than one window, the previous window will be re-used on
+the selected file/directory. If the previous window's associated buffer
+has been modified, and there's only one window with that buffer, then
+the user will be asked if s/he wishes to save the buffer first (yes,
+no, or cancel).
+
+
SELECTING SORTING STYLE *netrw-s* *netrw-sort*
One may select the sorting style by name, time, or (file) size. The "s" map
in your <.vimrc>.
-CUSTOMIZING BROWSING WITH A USER FUNCTION *netrw-x* *netrw-handler*
+CUSTOMIZING BROWSING WITH A USER FUNCTION *netrw-x* *netrw-handler* *gx*
-One may "enter" a file with a special handler, thereby firing up a browser or
-other application, for example, on a file by hitting the "x" key. The special
-handler varies:
+Certain files, such as html, gif, jpeg, (word/office) doc, etc, files, are
+best seen with a special handler (ie. a tool provided with your computer).
+Netrw allows one to invoke such special handlers by: >
+
+ * when Exploring, hit the "x" key
+ * when editing, hit gx with the cursor atop the special filename
+<
+Netrw determines which special handler by the following method:
+
+ * if |g:netrw_browsex_viewer| exists, then it will be used to attempt to
+ view files. Examples of useful settings (place into your <.vimrc>): >
+
+ :let g:netrw_browsex_viewer= "kfmclient exec"
+< or >
+ :let g:netrw_browsex_viewer= "gnome-open"
+<
+ If g:netrw_browsex_viewer == '-', then netrwFileHandler() will be
+ invoked first (see |netrw_filehandler|).
* for Windows 32 or 64, the url and FileProtocolHandler dlls are used.
- * for KDE (with kfmclient): kfmclient is used.
* for Gnome (with gnome-open): gnome-open is used.
+ * for KDE (with kfmclient): kfmclient is used.
* otherwise the netrwFileHandler plugin is used.
The file's suffix is used by these various approaches to determine an
OpenOffice (*.sfx), visualization (*.jpg, *.gif, etc), and PostScript (*.ps,
*.eps) can be handled.
+ *netrw_filehandler*
The netrwFileHandler applies a user-defined function to a file, based on its
extension. Of course, the handler function must exist for it to be called!
>
See the <plugin/netrwFileHandlers.vim> for an example of how to handle an html
file with mozilla.
-One may write custom netrwFileHandlers; please look at the
-plugin/netrwFileHandlers.vim script for examples. If its likely to be
-generally useful, please feel free to forward a copy to me for future
-inclusion in the distribution.
+One may write custom netrwFileHandlers; please look at the >
+
+ plugin/netrwFileHandlers.vim
+
+script for examples. If its likely to be generally useful, please feel free
+to forward a copy to me for future inclusion in the distribution.
MAKING THE BROWSING DIRECTORY THE CURRENT DIRECTORY *netrw-c* *netrw-curdir*
==============================================================================
-8. Problems and Fixes *netrw-problems*
+9. Problems and Fixes *netrw-problems*
(This section is likely to grow as I get feedback)
(also see |netrw-debug|)
==============================================================================
-9. Debugging *netrw-debug*
+10. Debugging *netrw-debug*
The <netrw.vim> script is typically available as:
>
NdrOchip at ScampbellPfamily.AbizM - NOSPAM
==============================================================================
-10. History *netrw-history*
-
+11. History *netrw-history* {{{1
+
+ v78: * progress has been made on allowing spaces inside directory
+ names for remote work (reading, writing, browsing). (scp)
+ v77: * Mikolaj Machowski fixed a bug in a substitute command
+ * g:netrw_browsex_viewer implemented
+ * Mikolaj Machowski pointed out that gnome-open is often
+ executable under KDE systems, although it is effectively
+ not functional. NetBrowseX now looks for "kicker" as
+ a running process to determine if KDE is actually the
+ really running.
+ * Explorer's O functionality was inadvertently left out.
+ Netrw now does the same thing, but with the "P" key.
+ * added g:netrw_browse_split option
+ * fixed a bug where the directory contained a "." but
+ the file didn't (was treating the dirname from "."
+ onwards as a suffix)
v76: * "directory is missing" error message now restores echo
highlighting
v75: * file://... now conforms to RFC2396 (thanks to S. Zacchiroli)
==============================================================================
-11. Credits *netrw-credits*
+11. Credits *netrw-credits* {{{1
Vim editor by Bram Moolenaar (Thanks, Bram!)
dav support by C Campbell