blob: 005072f9999e1a1d06fdb67a012ba207a3d054eb [file] [log] [blame]
Bram Moolenaar269ec652004-07-29 08:43:53 +00001*pi_netrw.txt For Vim version 6.2. Last change: Jul 26, 2004
Bram Moolenaar071d4272004-06-13 20:20:40 +00002
3
4 VIM REFERENCE MANUAL by Charles E. Campbell, Jr.
5
Bram Moolenaar69a7cb42004-06-20 12:51:53 +00006*dav* *http* *network* *rcp* *scp*
7*fetch* *netrw* *Nread* *rsync* *sftp*
8*ftp* *netrw.vim* *Nwrite* *netrw-file*
Bram Moolenaar071d4272004-06-13 20:20:40 +00009
10==============================================================================
110. Contents *netrw-contents*
12
131. Netrw Reference.....................................|netrw-ref|
142. Network-Oriented File Transfer......................|netrw-xfer|
153. Activation..........................................|netrw-activate|
164. Transparent File Transfer...........................|netrw-transparent|
175. Ex Commands.........................................|netrw-ex|
186. Variables and Options...............................|netrw-var|
Bram Moolenaar843ee412004-06-30 16:16:41 +0000197. Remote Directory Browser............................|netrw-browse|
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000208. Debugging...........................................|netrw-debug|
219. History.............................................|netrw-history|
2210. Credits.............................................|netrw-credits|
Bram Moolenaar071d4272004-06-13 20:20:40 +000023
24The functionality mentioned here is done via using |standard-plugin|
25techniques. This plugin is only available if
26
Bram Moolenaar69a7cb42004-06-20 12:51:53 +000027 set nocp " 'compatible' is not set
28 filetype plugin on " plugins are enabled
Bram Moolenaar071d4272004-06-13 20:20:40 +000029
30You can avoid loading this plugin by setting the "loaded_netrw" variable
31in your <.vimrc> file: >
32
33 :let loaded_netrw = 1
34
35{Vi does not have any of this}
36
37==============================================================================
381. Netrw Reference *netrw-ref*
39
40 OPTIONS
41 let g:netrw_ftp =0 use ftp (default) (uid password)
42 =1 use alternate ftp method (user uid password)
43 If you're having trouble with ftp, try changing the value
44 of this variable in your <.vimrc> to change methods
45
46 let g:netrw_ignorenetrc= 1
47 If you have a <.netrc> file but it doesn't work and you
48 want it ignored, then set this variable as shown. Its mere
49 existence is enough to cause <.netrc> to be ignored.
50
51 Controlling External Applications
52
Bram Moolenaar69a7cb42004-06-20 12:51:53 +000053 Protocol Variable Default Value
54 -------- ---------------- -------------
55 dav: g:netrw_dav_cmd = "cadaver"
56 fetch: g:netrw_fetch_cmd = "fetch -o"
57 ftp: g:netrw_ftp_cmd = "ftp"
58 http: g:netrw_http_cmd = "fetch -o" if fetch is available
59 http: g:netrw_http_cmd = "wget -q -O" If wget is available
60 rcp: g:netrw_rcp_cmd = "rcp"
61 rsync: g:netrw_rsync_cmd = "rsync -a"
62 scp: g:netrw_scp_cmd = "scp -q"
Bram Moolenaar071d4272004-06-13 20:20:40 +000063 sftp: g:netrw_sftp_cmd = "sftp"
64
65 READING
66 :Nread ? give help
67 :Nread "machine:file" uses rcp
68 :Nread "machine file" uses ftp with <.netrc>
69 :Nread "machine id password file" uses ftp
70 :Nread "dav://machine[:port]/file" uses cadaver
71 :Nread "fetch://[user@]machine/file" uses fetch
72 :Nread "ftp://[user@]machine[[:#]port]/file" uses ftp autodetects <.netrc>
73 :Nread "http://[user@]machine/file" uses http uses wget
74 :Nread "rcp://[user@]machine/file" uses rcp
75 :Nread "rsync://[user@]machine[:port]/file" uses rsync
76 :Nread "scp://[user@]machine[[:#]port]/file" uses scp
77 :Nread "sftp://[user@]machine/file" uses sftp
78
79 WRITING
Bram Moolenaar69a7cb42004-06-20 12:51:53 +000080 :Nwrite ? give help
Bram Moolenaar071d4272004-06-13 20:20:40 +000081 :Nwrite "machine:file" uses rcp
82 :Nwrite "machine file" uses ftp with <.netrc>
83 :Nwrite "machine id password file" uses ftp
84 :Nwrite "dav://machine[:port]/file" uses cadaver
85 :Nwrite "ftp://[user@]machine[[:#]port]/file" uses ftp autodetects <.netrc>
86 :Nwrite "rcp://[user@]machine/file" uses rcp
87 :Nwrite "rsync://[user@]machine[:port]/file" uses rsync
88 :Nwrite "scp://[user@]machine[[:#]port]/file" uses scp
89 :Nwrite "sftp://[user@]machine/file" uses sftp
90 http: not supported!
91
Bram Moolenaar69a7cb42004-06-20 12:51:53 +000092 DIRECTORY LISTING
93 :Nread [protocol]://[user]@hostname/path/
94
Bram Moolenaar071d4272004-06-13 20:20:40 +000095 USER AND PASSWORD CHANGING
96 Attempts to use ftp will prompt you for a user-id and a password.
97 These will be saved in g:netrw_uid and g:netrw_passwd Subsequent uses
98 of ftp will re-use those. If you need to use a different user id
99 and/or password, you'll want to call NetUserPass() first.
100
101 :NetUserPass [uid [password]] -- prompts as needed
102 :call NetUserPass() -- prompts for uid and password
103 :call NetUserPass("uid") -- prompts for password
104 :call NetUserPass("uid","password") -- sets global uid and password
105
106 VARIABLES
107 b:netrw_lastfile last file Network-read/written retained on
108 a per-buffer basis (supports plain :Nw )
109 s:netrw_line during Nw/NetWrite, holds current line number
110 s:netrw_col during Nw/NetWrite, holds current column number
111 s:netrw_line and s:netrw_col are used to
112 restore the cursor position on writes
113 g:netrw_ftp if it doesn't exist, use default ftp
114 =0 use default ftp (uid password)
115 =1 use alternate ftp method (user uid password)
116 g:netrw_ftpmode ="binary" (default)
117 ="ascii" (or your choice)
118 g:netrw_uid (ftp) user-id, retained on a per-session basis
119 g:netrw_passwd (ftp) password, retained on a per-session basis
120 g:netrw_win95ftp =0 use unix-style ftp even if win95/win98/winME
121 =1 use default method to do ftp
122 g:netrw_cygwin =1 assume scp under windows is from cygwin
123 (default if windows)
124 =0 assume scp under windows accepts
125 windows-style paths (default otherwise)
126 g:netrw_use_nt_rcp=0 don't use the rcp of WinNT, Win2000 and WinXP (default)
127 =1 use the rcp of WinNT,... in binary mode
128
129
130==============================================================================
1312. Network-Oriented File Transfer *netrw-xfer*
132
133Network-oriented file transfer under Vim is implemented by a VimL-based script
134(<netrw.vim>) using plugin techniques. It currently supports both reading
135and writing across networks using rcp, scp, ftp or ftp+<.netrc>, scp, fetch,
136dav/cadaver, rsync, or sftp.
137
138http is currently supported read-only via use of wget or fetch.
139
140<netrw.vim> is a standard plugin which acts as glue between Vim and the
141various file transfer programs. It uses autocommand events (BufReadCmd,
142FileReadCmd, BufWriteCmd) to intercept reads/writes with url-like filenames. >
143
144 ex. vim ftp://hostname/path/to/file
145<
146The characters preceding the colon specify the protocol to use;
147in the example, its ftp. The <netrw.vim> script then formulates
148a command or a series of commands (typically ftp) which it issues
149to an external program (ftp, scp, etc) which does the actual file
150transfer/protocol. Files are read from/written to a temporary file
151(under Unix/Linux, /tmp/...) which the <netrw.vim> script will
152clean up.
153
154One may modify any protocol's implementing external application
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000155by settinbg a variable (ex. scp uses the variable g:netrw_scp_cmd,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000156which is defaulted to "scp -q").
157
158Ftp, an old protocol, seems to be blessed by numerous implementations.
159Unfortunately, some implementations are noisy (ie., add junk to the end
160of the file). Thus, concerned users may decide to write a NetReadFixup()
161function that will clean up after reading with their ftp. Some Unix systems
162(ie., FreeBSD) provide a utility called "fetch" which uses the ftp protocol
163but is not noisy and more convenient, actually, for <netrw.vim> to use.
164Consequently, if "fetch" is executable, it will be used to do reads for
165ftp://... (and http://...) . See |netrw-var| for more about this.
166
167For rcp, scp, sftp, and http, one may use network-oriented file transfers
168transparently; ie.
169>
170 vim rcp://[user@]machine/path
171 vim scp://[user@]machine/path
172<
173If your ftp supports <.netrc>, then it too can be just as transparently used
174if the needed triad of machine name, user id, and password are present in
175that file. Your ftp must be able to use the <.netrc> file on its own, however.
176>
177 vim ftp://[user@]machine[[:#]portnumber]/path
178<
179However, ftp will often need to query the user for the userid and password.
180The latter will be done "silently"; ie. asterisks will show up instead of
181the actually-typed-in password. Netrw will retain the userid and password
182for subsequent read/writes from the most recent transfer so subsequent
183transfers (read/write) to or from that machine will take place without
184additional prompting.
185
186 *netrw-urls*
187 +=================================+============================+============+
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000188 | Reading | Writing | Uses |
Bram Moolenaar071d4272004-06-13 20:20:40 +0000189 +=================================+============================+============+
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000190 | DAV: | | |
191 | dav://host/path | | cadaver |
192 | :Nread dav://host/path | :Nwrite dav://host/path | cadaver |
Bram Moolenaar071d4272004-06-13 20:20:40 +0000193 +---------------------------------+----------------------------+------------+
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000194 | FETCH: | | |
195 | fetch://[user@]host/path | | |
196 | fetch://[user@]host:http/path | Not Available | fetch |
197 | :Nread fetch://[user@]host/path| | |
Bram Moolenaar071d4272004-06-13 20:20:40 +0000198 +---------------------------------+----------------------------+------------+
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000199 | FILE: | | |
200 | file:///* | file:///* | |
201 | file://localhost/* | file://localhost/* | |
Bram Moolenaar071d4272004-06-13 20:20:40 +0000202 +---------------------------------+----------------------------+------------+
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000203 | FTP: (*3) | (*3) | |
204 | ftp://[user@]host/path | ftp://[user@]host/path | ftp (*2) |
205 | :Nread ftp://host/path | :Nwrite ftp://host/path | ftp+.netrc |
206 | :Nread host path | :Nwrite host path | ftp+.netrc |
207 | :Nread host uid pass path | :Nwrite host uid pass path | ftp |
Bram Moolenaar071d4272004-06-13 20:20:40 +0000208 +---------------------------------+----------------------------+------------+
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000209 | HTTP: wget is executable: (*4) | | |
210 | http://[user@]host/path | Not Available | wget |
Bram Moolenaar071d4272004-06-13 20:20:40 +0000211 +---------------------------------+----------------------------+------------+
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000212 | HTTP: fetch is executable (*4) | | |
213 | http://[user@]host/path | Not Available | fetch |
Bram Moolenaar071d4272004-06-13 20:20:40 +0000214 +---------------------------------+----------------------------+------------+
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000215 | RCP: | | |
216 | rcp://[user@]host/path | rcp://[user@]host/path | rcp |
Bram Moolenaar071d4272004-06-13 20:20:40 +0000217 +---------------------------------+----------------------------+------------+
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000218 | RSYNC: | | |
219 | rsync://[user@]host/path | rsync://[user@]host/path | rsync |
220 | :Nread rsync://host/path | :Nwrite rsync://host/path | rsync |
221 | :Nread rcp://host/path | :Nwrite rcp://host/path | rcp |
Bram Moolenaar071d4272004-06-13 20:20:40 +0000222 +---------------------------------+----------------------------+------------+
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000223 | SCP: | | |
224 | scp://[user@]host/path | scp://[user@]host/path | scp |
225 | :Nread scp://host/path | :Nwrite scp://host/path | scp (*1) |
Bram Moolenaar071d4272004-06-13 20:20:40 +0000226 +---------------------------------+----------------------------+------------+
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000227 | SFTP: | | |
228 | sftp://[user@]host/path | sftp://[user@]host/path | sftp |
229 | :Nread sftp://host/path | :Nwrite sftp://host/path | sftp (*1) |
Bram Moolenaar071d4272004-06-13 20:20:40 +0000230 +=================================+============================+============+
231
232 (*1) For an absolute path use scp://machine//path.
233
234 (*2) if <.netrc> is present, it is assumed that it will
235 work with your ftp client. Otherwise the script will
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000236 prompt for user-id and pasword.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000237
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000238 (*3) for ftp, "machine" may be machine#port or machine:port
Bram Moolenaar071d4272004-06-13 20:20:40 +0000239 if a different port is needed than the standard ftp port
240
241 (*4) for http:..., if wget is available it will be used. Otherwise,
242 if fetch is available it will be used.
243
244Both the :Nread and the :Nwrite ex-commands can accept multiple filenames.
245
246
247NETRC *netrw-netrc*
248
249The typical syntax for lines in a <.netrc> file is given as shown below.
250Ftp under Unix usually support <.netrc>; Windows' ftp usually doesn't.
251>
252 machine {full machine name} login {user-id} password "{password}"
253 default login {user-id} password "{password}"
254
255Your ftp client must handle the use of <.netrc> on its own, but if the
256<.netrc> file exists, an ftp transfer will not ask for the user-id or
257password.
258
259 Note:
260 Since this file contains passwords, make very sure nobody else can
261 read this file! Most programs will refuse to use a .netrc that is
262 readable for others. Don't forget that the system administrator can
263 still read the file!
264
265
266PASSWORD *netrw-passwd*
267
268The script attempts to get passwords for ftp invisibly using |inputsecret()|,
269a built-in Vim function. See |netrw-uidpass| for how to change the password
270after one has set it.
271
272Unfortunately there doesn't appear to be a way for netrw to feed a password
273to scp. Thus every transfer via scp will require re-entry of the password.
274
275
276==============================================================================
2773. Activation *netrw-activate*
278
279Network-oriented file transfers are available by default whenever
280|'nocompatible'| mode is enabled. The <netrw.vim> file resides in your
281system's vim-plugin directory and is sourced automatically whenever you
282bring up vim.
283
284
285==============================================================================
2864. Transparent File Transfer *netrw-transparent*
287
288Transparent file transfers occur whenever a regular file read or write
289(invoked via an |:autocmd| for |BufReadCmd| or |BufWriteCmd| events) is made.
290Thus one may use files across networks as if they were local. >
291
292 vim ftp://[user@]machine/path
293 ...
294 :wq
295
296
297==============================================================================
2985. Ex Commands *netrw-ex*
299
300The usual read/write commands are supported. There are also a couple of
301additional commands available.
302
303:[range]Nw Write the specified lines to the current
304 file as specified in b:netrw_lastfile.
305
306:[range]Nw {netfile} [{netfile}]...
307 Write the specified lines to the {netfile}.
308
309:Nread
310 Read the specified lines into the current
311 buffer from the file specified in
312 b:netrw_lastfile.
313
314:Nread {netfile} {netfile}...
315 Read the {netfile} after the current line.
316
317 *netrw-uidpass*
318:call NetUserPass()
319 If b:netrw_uid and b:netrw_passwd don't exist,
320 this function query the user for them.
321
322:call NetUserPass("userid")
323 This call will set the b:netrw_uid and, if
324 the password doesn't exist, will query the user for it.
325
326:call NetUserPass("userid","passwd")
327 This call will set both the b:netrw_uid and b:netrw_passwd.
328 The user-id and password are used by ftp transfers. One may
329 effectively remove the user-id and password by using ""
330 strings.
331
332
333==============================================================================
Bram Moolenaar69a7cb42004-06-20 12:51:53 +00003346. Variables and Options *netrw-options* *netrw-var*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000335
336The script <netrw.vim> uses several variables which can affect <netrw.vim>'s
337behavior. These variables typically may be set in the user's <.vimrc> file:
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000338>
339 -------------
340 Netrw Options
341 -------------
342 Option Meaning
343 -------------- -----------------------------------------------
344<
345 b:netrw_col Holds current cursor position (during NetWrite)
346 g:netrw_cygwin =1 assume scp under windows is from cygwin
347 (default/windows)
348 =0 assume scp under windows accepts windows
349 style paths (default/else)
350 g:netrw_ftp =0 use default ftp (uid password)
351 g:netrw_ftpmode ="binary" (default)
352 ="ascii" (your choice)
353 g:netrw_ignorenetrc =1 (default)
354 if you have a <.netrc> file but you don't
Bram Moolenaar071d4272004-06-13 20:20:40 +0000355 want it used, then set this variable. Its
356 mere existence is enough to cause <.netrc>
357 to be ignored.
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000358 b:netrw_lastfile Holds latest method/machine/path.
359 b:netrw_line Holds current line number (during NetWrite)
360 g:netrw_passwd Holds current password for ftp.
361 g:netrw_silent =0 transfers done normally
362 =1 transfers done silently
363 g:netrw_uid Holds current user-id for ftp.
364 =1 use alternate ftp (user uid password)
365 (see |netrw-options|)
366 g:netrw_use_nt_rcp =0 don't use WinNT/2K/XP's rcp (default)
367 =1 use WinNT/2K/XP's rcp, binary mode
368 g:netrw_win95ftp =0 use unix-style ftp even if win95/98/ME/etc
369 =1 use default method to do ftp >
370 -----------------------------------------------------------------------
371<
Bram Moolenaar071d4272004-06-13 20:20:40 +0000372The script will also make use of the following variables internally, albeit
373temporarily.
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000374>
375 -------------------
376 Temporary Variables
377 -------------------
378 Variable Meaning
379 -------- ------------------------------------
380<
Bram Moolenaar071d4272004-06-13 20:20:40 +0000381 g:netrw_method Index indicating rcp/ftp+.netrc/ftp
382 g:netrw_machine Holds machine name parsed from input
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000383 g:netrw_fname Holds filename being accessed >
384 ------------------------------------------------------------
385<
Bram Moolenaar071d4272004-06-13 20:20:40 +0000386 *netrw-protocol*
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000387
388Netrw supports a number of protocols. These protocols are invoked using the
389variables listed below, and may be modified by the user.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000390>
391 ------------------------
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000392 Protocol Control Options
Bram Moolenaar071d4272004-06-13 20:20:40 +0000393 ------------------------
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000394 Option Type Setting Meaning
395 --------- -------- -------------- ---------------------------
396<
397 netrw_ftp variable =doesn't exist userid set by "user userid"
398 =0 userid set by "user userid"
399 =1 userid set by "userid"
400 NetReadFixup function =doesn't exist no change
401 =exists Allows user to have files
402 read via ftp automatically
403 transformed however they wish
404 by NetReadFixup()
Bram Moolenaar071d4272004-06-13 20:20:40 +0000405 g:netrw_dav_cmd variable ="cadaver"
406 g:netrw_fetch_cmd variable ="fetch -o"
407 g:netrw_ftp_cmd variable ="ftp"
408 g:netrw_http_cmd variable ="fetch -o" else if fetch is executable
409 g:netrw_http_cmd variable ="wget -O" if wget is executable
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000410 g:netrw_list_cmd variable ="ssh HOSTNAME ls -Fa"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000411 g:netrw_rcp_cmd variable ="rcp"
412 g:netrw_rsync_cmd variable ="rsync -a"
413 g:netrw_scp_cmd variable ="scp -q"
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000414 g:netrw_sftp_cmd variable ="sftp" >
415 -------------------------------------------------------------------------
Bram Moolenaar071d4272004-06-13 20:20:40 +0000416<
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000417 *netrw-ftp*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000418The first two options both help with certain ftp's that give trouble otherwise.
419In order to best understand how to use these options if ftp is giving you
420troubles, a bit of discussion follows on how netrw does ftp reads.
421
422The g:netrw_..._cmd variables specify the external program to use handle
423the associated protocol (rcp, ftp, etc), plus any options.
424
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000425The g:netrw_list_cmd's HOSTNAME entry will be changed via substitution with
426whatever the current request is for a hostname.
427
428For ftp, netrw typically builds up lines of one of the following formats in a
Bram Moolenaar071d4272004-06-13 20:20:40 +0000429temporary file:
430>
431 IF g:netrw_ftp !exists or is not 1 IF g:netrw_ftp exists and is 1
432 ---------------------------------- ------------------------------
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000433<
434 open machine [port] open machine [port]
435 user userid password userid password
436 [g:netrw_ftpmode] password
437 get filename tempfile [g:netrw_ftpmode]
438 get filename tempfile >
439 ---------------------------------------------------------------------
Bram Moolenaar071d4272004-06-13 20:20:40 +0000440<
441Netrw then executes the lines above by use of a filter:
442>
443 :%! {g:netrw_ftp_cmd} -i [-n]
444<
445
446where
447 g:netrw_ftp_cmd is usually "ftp",
448 -i tells ftp not to be interactive
449 -n means don't use netrc and is used for Method #3 (ftp w/o <.netrc>)
450
451If <.netrc> exists it will be used to avoid having to query the user for
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000452userid and password. The transferred file is put into a temporary file.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000453The temporary file is then read into the main editing session window that
454requested it and the temporary file deleted.
455
456If your ftp doesn't accept the "user" command and immediately just demands
457a userid, then try putting "let netrw_ftp=1" in your <.vimrc>.
458
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000459 *netrw-cadaver*
460To handle the SSL certificate dialog for untrusted servers, one may pull
461down the certificate and place it into /usr/ssl/cert.pem. This operation
462renders the server treatment as "trusted".
463
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000464 *netrw-fixup*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000465If your ftp for whatever reason generates unwanted lines (such as AUTH
466messages) you may write a NetReadFixup(tmpfile) function:
467>
468 function! NetReadFixup(method,line1,line2)
469 " a:line1: first new line in current file
470 " a:line2: last new line in current file
471 if a:method == 1 "rcp
472 elseif a:method == 2 "ftp + <.netrc>
473 elseif a:method == 3 "ftp + machine,uid,password,filename
474 elseif a:method == 4 "scp
475 elseif a:method == 5 "http/wget
476 elseif a:method == 6 "dav/cadaver
477 elseif a:method == 7 "rsync
478 elseif a:method == 8 "fetch
479 elseif a:method == 9 "sftp
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000480 else " complain
Bram Moolenaar071d4272004-06-13 20:20:40 +0000481 endif
482 endfunction
483>
484The NetReadFixup() function will be called if it exists and thus allows
485you to customize your reading process. As a further example, <netrw.vim>
486contains just such a function to handle Windows 95 ftp. For whatever
487reason, Windows 95's ftp dumps four blank lines at the end of a transfer,
488and so it is desirable to automate their removal. Here's some code taken
489from <netrw.vim> itself:
490>
491 if has("win95") && g:netrw_win95ftp
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000492 fun! NetReadFixup(method, line1, line2)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000493 if method == 3 " ftp (no <.netrc>)
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000494 let fourblanklines= line2 - 3
495 silent fourblanklines.",".line2."g/^\s*/d"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000496 endif
497 endfunction
498 endif
499>
500
501==============================================================================
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005027. Remote Directory Browser *netrw-browse* *netrw-dir* *netrw-list* *netrw-help*
Bram Moolenaar8299df92004-07-10 09:47:34 +0000503 ?..........Help....................................|netrw-help|
504 <cr>.......Browsing................................|netrw-cr|
505 <c-l>......Refreshing the Listing..................|netrw-c-l|
Bram Moolenaar269ec652004-07-29 08:43:53 +0000506 <del>......Deleting Files or Directories...........|netrw-delete|
Bram Moolenaar8299df92004-07-10 09:47:34 +0000507 -..........Going Up................................|netrw--|
508 a..........Hiding Files or Directories.............|netrw-a|
Bram Moolenaar269ec652004-07-29 08:43:53 +0000509 D..........Deleting Files or Directories...........|netrw-D|
510 \h.........Edit File/Directory Hiding List.........|netrw-h|
Bram Moolenaar8299df92004-07-10 09:47:34 +0000511 i..........Long Listing............................|netrw-i|
Bram Moolenaar269ec652004-07-29 08:43:53 +0000512 \m.........Make A New Directory....................|netrw-m|
Bram Moolenaar8299df92004-07-10 09:47:34 +0000513 o..........Browsing with a Horizontal Split........|netrw-o|
514 r..........Reversing Sorting Order.................|netrw-r|
Bram Moolenaar269ec652004-07-29 08:43:53 +0000515 R..........Renaming Files or Directories...........|netrw-R|
Bram Moolenaar8299df92004-07-10 09:47:34 +0000516 s..........Selecting Sorting Style.................|netrw-s|
517 v..........Browsing with a Vertical Split..........|netrw-v|
518 x..........Customizing Browsing....................|netrw-x|
Bram Moolenaar269ec652004-07-29 08:43:53 +0000519
520QUICK REFERENCE COMMANDS TABLE *netrw-browse-cmds*
Bram Moolenaar843ee412004-06-30 16:16:41 +0000521>
Bram Moolenaar8299df92004-07-10 09:47:34 +0000522 ------- -----------
Bram Moolenaar843ee412004-06-30 16:16:41 +0000523 Command Explanation
524 ------- -----------
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000525 ? Causes Netrw to issue help
Bram Moolenaar843ee412004-06-30 16:16:41 +0000526 <cr> Netrw will enter the directory or read the file
527 <del> Netrw will attempt to remove the file/directory
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000528 <c-l> Causes Netrw to refresh the directory listing
Bram Moolenaar843ee412004-06-30 16:16:41 +0000529 D Netrw will attempt to remove the file(s)/directory(ies)
530 R Netrw will attempt to rename the file(s)/directory(ies)
531 - Makes Netrw go up one directory
532 a Show all of a directory (temporarily ignore g:netrw_list_hide)
Bram Moolenaar269ec652004-07-29 08:43:53 +0000533 \h Edit file hiding list
Bram Moolenaar8299df92004-07-10 09:47:34 +0000534 i Toggles between long and short listing
Bram Moolenaar269ec652004-07-29 08:43:53 +0000535 \m Make a directory
Bram Moolenaar843ee412004-06-30 16:16:41 +0000536 o Enter the file/directory under the cursor in a new browser
537 window. A horizontal split is used.
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000538 r Reverse sorting order
539 s Select sorting style: by name, time, or file size
Bram Moolenaar843ee412004-06-30 16:16:41 +0000540 v Enter the file/directory under the cursor in a new browser
541 window. A vertical split is used.
542 x Apply a function to a file.
Bram Moolenaar843ee412004-06-30 16:16:41 +0000543<
Bram Moolenaar269ec652004-07-29 08:43:53 +0000544NETRW BROWSER VARIABLES *netrw-browse-var*
Bram Moolenaar843ee412004-06-30 16:16:41 +0000545>
546 --- -----------
547 Var Explanation
548 --- -----------
549 g:netrw_list_cmd supports listing
Bram Moolenaar843ee412004-06-30 16:16:41 +0000550 g:netrw_list_hide comma separated list of patterns for
551 hiding files
Bram Moolenaar8299df92004-07-10 09:47:34 +0000552 g:netrw_local_mkdir specify command for making a directory locally
553 g:netrw_local_rmdir remove directory command default: rmdir
554 g:netrw_local_rename rename file/directory command
555 unix-default: rm win32-default: ren
556 g:netrw_mkdir_cmd specify command for making a directory remotely
557 g:netrw_rm_cmd supports removing files
558 g:netrw_rmdir_cmd supports removing directories
559 g:netrw_rmf_cmd supports removing softlinks to directories
Bram Moolenaar269ec652004-07-29 08:43:53 +0000560 g:netrw_hide if true, the hiding list is used
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000561 g:netrw_sort_by sort by "name", "time", or "size"
562 g:netrw_sort_direction sorting direction: "normal" or "reverse"
563 g:netrw_sort_sequence when sorting by name, first sort by the
564 comma-separated pattern sequence
Bram Moolenaar8299df92004-07-10 09:47:34 +0000565 g:netrw_timefmt specify format string to strftime() default: %c
566 g:netrw_winsize specify initial size of new o/v windows
Bram Moolenaar843ee412004-06-30 16:16:41 +0000567<
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000568INTRODUCTION TO REMOTE DIRECTORY BROWSING
569
Bram Moolenaar843ee412004-06-30 16:16:41 +0000570Netrw supports the browsing of directories on remote hosts, including
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000571generating listing directories, entering directories, editing files therein,
572deleting files/directories, and moving (renaming) files and directories. The
573Netrw browser generally implements the file explorer methods but for remote
574directories, although details (such as pertinent global variable names)
575necessarily differ.
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000576
Bram Moolenaar843ee412004-06-30 16:16:41 +0000577To enter the netrw directory browser, simply attempt to read a "file" with a
578trailing slash and it will be interpreted as a request to list a directory:
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000579
580 vim [protocol]://[user@]hostname/path/
581
Bram Moolenaar269ec652004-07-29 08:43:53 +0000582To get no-password directory listings, scp, ssh interaction, etc, see
583|netrw-list-hack|.
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000584
585REFRESHING THE LISTING *netrw-c-l*
586
587To refresh the directory listing, press ctrl-l (<c-l>) or hit the <cr>
588when atop the ./ directory entry in the listing.
589
590
591GOING UP *netrw--*
592
593To go up a directory, press - or his the <cr> when atop the ../ directory
594entry in the listing.
595
596Netrw will modify the command in *g:netrw_list_cmd* to perform the directory
Bram Moolenaar843ee412004-06-30 16:16:41 +0000597listing operation. By default the command is:
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000598
Bram Moolenaar843ee412004-06-30 16:16:41 +0000599 ssh HOSTNAME ls -FLa
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000600
Bram Moolenaar843ee412004-06-30 16:16:41 +0000601where the HOSTNAME becomes the [user@]hostname as requested by the attempt
602to read. Naturally, the user may override this command with whatever is
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000603preferred. The NetList function which implements remote directory
604browsing expects that directories will be flagged by a trailing slash.
605
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000606
Bram Moolenaar8299df92004-07-10 09:47:34 +0000607BROWSING *netrw-cr*
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000608
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000609Browsing is simple: move the cursor onto a file or directory of interest.
Bram Moolenaar843ee412004-06-30 16:16:41 +0000610Hitting the <cr> (the return key) will select the file or directory.
611Directories will themselves be listed, and files will be opened using the
612protocol given in the original read request.
613
Bram Moolenaar8299df92004-07-10 09:47:34 +0000614LONG VS SHORT LISTING *netrw-i*
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000615
Bram Moolenaar8299df92004-07-10 09:47:34 +0000616The short listing format gives just the files' and directories' names.
617The long listing is either based on the "ls" command via ssh for remote
618directories or displays the filename, file size (in bytes), and the
619time and date of last modification for local directories.
620
621
Bram Moolenaar269ec652004-07-29 08:43:53 +0000622MAKING A NEW DIRECTORY *netrw-m*
Bram Moolenaar8299df92004-07-10 09:47:34 +0000623
Bram Moolenaar269ec652004-07-29 08:43:53 +0000624Actually <Leader>m, where the <Leader> is, by default, the backslash.
Bram Moolenaar8299df92004-07-10 09:47:34 +0000625
Bram Moolenaar269ec652004-07-29 08:43:53 +0000626With the "<Leader>m" map one may make a new directory either remotely (which
Bram Moolenaar8299df92004-07-10 09:47:34 +0000627depends on the global variable g:netrw_mkdir_cmd) or locally (which depends on
628the global variable g:netrw_local_mkdir). Netrw will issue a request for the
629new directory's name. A bare <CR> at that point will abort the making of the
630directory. Attempts to make a local directory that already exists (as either
631a file or a directory) will be detected, reported on, and ignored.
632
Bram Moolenaar269ec652004-07-29 08:43:53 +0000633DELETING FILES OR DIRECTORIES *netrw-delete* *netrw-D*
Bram Moolenaar843ee412004-06-30 16:16:41 +0000634
635Deleting/removing files and directories involves moving the cursor to the
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000636file/directory to be deleted and pressing "D". Directories must be empty first
637before they can be successfully removed. If the directory is a softlink to a
638directory, then netrw will make two requests to remove the directory before
639succeeding. Netrw will ask for confirmation before doing the removal(s).
640You may select a range of lines with the "V" command (visual selection),
641and then pressing "D".
Bram Moolenaar843ee412004-06-30 16:16:41 +0000642
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000643 *g:netrw_rm_cmd*
644The g:netrw_rm_cmd, g:netrw_rmf_cmd, and g:netrw_rmdir_cmd variables are used
645to control the attempts to remove files and directories. The g:netrw_rm_cmd
646is used with files, and its default value is:
Bram Moolenaar843ee412004-06-30 16:16:41 +0000647
648 g:netrw_rm_cmd: ssh HOSTNAME rm
649
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000650 *g:netrw_rmdir_cmd*
651The g:netrw_rmdir_cmd variable is used to support the removal of directories.
652Its default value is:
Bram Moolenaar843ee412004-06-30 16:16:41 +0000653
654 g:netrw_rmdir_cmd: ssh HOSTNAME rmdir
655
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000656 *g:netrw_rmf_cmd*
Bram Moolenaar843ee412004-06-30 16:16:41 +0000657If removing a directory fails with g:netrw_rmdir_cmd, netrw then will attempt
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000658to remove it again using the g:netrw_rmf_cmd variable. Its default value is:
Bram Moolenaar843ee412004-06-30 16:16:41 +0000659
660 g:netrw_rmf_cmd: ssh HOSTNAME rm -f
661
Bram Moolenaar843ee412004-06-30 16:16:41 +0000662
Bram Moolenaar8299df92004-07-10 09:47:34 +0000663RENAMING FILES OR DIRECTORIES *netrw-move* *netrw-rename* *netrw-R*
Bram Moolenaar843ee412004-06-30 16:16:41 +0000664
665Renaming/moving files and directories involves moving the cursor to the
666file/directory to be moved (renamed) and pressing "R". You will then be
667queried for where you want the file/directory to be moved. You may select a
668range of lines with the "V" command (visual selection), and then pressing "R".
669
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000670The g:netrw_rename_cmd variable is used to implement renaming. By default its
Bram Moolenaar843ee412004-06-30 16:16:41 +0000671value is:
672
673 ssh HOSTNAME mv
674
Bram Moolenaar269ec652004-07-29 08:43:53 +0000675One may rename a block of files and directories by selecting them with
676the V (|linewise-visual|).
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000677
Bram Moolenaar269ec652004-07-29 08:43:53 +0000678HIDING FILES OR DIRECTORIES *g:netrw-a* *g:netrw_list_hide*
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000679
Bram Moolenaar269ec652004-07-29 08:43:53 +0000680The "a" map toggles the netrw vim file browser (both remote and local) between
681displaying hidden files (show-all) versus hiding files. For files to be
682hidden, the g:netrw_list_hide variable must hold a comma delimited list of
683patterns (ex. \.obj) to be hidden from normal listing. (see |netrw-h|)
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000684
685
Bram Moolenaar269ec652004-07-29 08:43:53 +0000686EDIT FILE OR DIRECTORY HIDING LIST *netrw-h*
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000687
Bram Moolenaar269ec652004-07-29 08:43:53 +0000688Actually <Leader>h, where the <Leader> is, by default, the backslash.
Bram Moolenaar8299df92004-07-10 09:47:34 +0000689
Bram Moolenaar269ec652004-07-29 08:43:53 +0000690The "<Leader>h" map brings up a requestor allowing the user to change the
691file/directory hiding list. The hiding list consists of one or more patterns
692delimited by commas. Files and/or directories satisfying these patterns will
693be hidden (ie. not shown).
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000694
695
696BROWSING WITH A HORIZONTALLY SPLIT WINDOW *netrw-o*
697
Bram Moolenaar269ec652004-07-29 08:43:53 +0000698Normally one enters a file or directory using the <cr>. However, the "o" map
699allows one to open a new window to hold the new directory listing or file. A
700horizontal split is used. (also see |netrw-v|)
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000701
702
703SELECTING SORTING STYLE *netrw-s*
704
705One may select the sorting style by name, time, or (file) size. The
706"s" map allows one to circulate among the three choices; the directory
707listing will automatically be refreshed to reflect the selected style.
708
709
710REVERSING SORTING ORDER *netrw-r*
711
712One may toggle between normal and reverse sorting order by pressing the
713"r" key.
714
715
716BROWSING WITH A VERTICALLY SPLIT WINDOW *netrw-v*
717
718Normally one enters a file or directory using the <cr>. However, the "v"
719map allows one to open a new window to hold the new directory listing or
720file. A vertical split is used. (also see |netrw-o|)
721
722
723CUSTOMIZING BROWSING WITH A USER FUNCTION *netrw-x*
724
725One may "enter" a file with a special handler, thereby firing up a browser or
726other application, for example, on a file by hitting the "x" key. Presumably
727one could write handlers that would start OpenOffice programs (oowriter), etc,
728based on the file's extension coupled with the user's hitting the "x" key atop
729the file.
730
731The Netrw executor applies a user-defined function to a file, based on its
732extension. Of course, the handler function must exist for it to be called!
733>
734 Ex. mypgm.html x ->
735 NetrwFileHandler_html("scp://user@host/some/path/mypgm.html")
736<
737See the <plugin/NetrwFileHandlers.vim> for an example of how to handle an html
738file with mozilla.
739
740
741IMPROVING DIRECTORY BROWSING *netrw-list-hack*
742
743Especially with the remote directory browser, constantly entering the password
744is tedious.
745
Bram Moolenaar843ee412004-06-30 16:16:41 +0000746For Linux/Unix systems, I suggest looking into
747
748 http://hacks.oreilly.com/pub/h/66
749
750It gives a tip for setting up password-less use of ssh and scp, and discusses
751the associated security issues.
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000752
753
754==============================================================================
7558. Debugging *netrw-debug*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000756
757The <netrw.vim> script is typically available as:
758
759 /usr/local/share/vim/vim6x/plugin/netrw.vim
760
761which is loaded automatically at startup (assuming :set nocp).
762
763 1. Get the <Decho.vim> script, available as:
764
765 http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_scripts
766 as "Decho, a vimL debugging aid"
767 or
768 http://vim.sourceforge.net/scripts/script.php?script_id=120
769
770 and put it into your local plugin directory
771
772 2. Edit the <netrw.vim> file as follows:
773
774 :DechoOn
775
776 (to restore to normal, use :DechoOff )
777
778 3. Then bring up vim and attempt a transfer. A set of messages
779 should appear concerning the steps that <netrw.vim> took in
780 attempting to read/write your file over the network. Please
781 send that information to <netrw.vim>'s maintainer,
782
783 drchipNOSPAM at campbellfamily.biz - NOSPAM
784
785==============================================================================
Bram Moolenaar69a7cb42004-06-20 12:51:53 +00007869. History *netrw-history*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000787
Bram Moolenaar269ec652004-07-29 08:43:53 +0000788 v47: * now handles local directory browsing.
Bram Moolenaar69a7cb42004-06-20 12:51:53 +0000789 v46: * now handles remote directory browsing
790 * g:netrw_silent (if 1) will cause all transfers to be silent'd
791 v45: * made the [user@]hostname:path form a bit more restrictive
792 to better handle errors in using protocols
793 (e.g. scp:usr@host:file was being recognized as an rcp request)
794 v44: * changed from "rsync -a" to just "rsync"
795 * somehow an editing error messed up the test to recognize
796 use of the fetch method for NetRead.
797 * more debugging statements included
798 v43: * moved "Explanation" comments to <pi_netrw.txt> help file
799 as "Network Reference" (|netrw-ref|)
800 * <netrw.vim> now uses Dfunc() Decho() and Dret() for debugging
801 * removed superfluous NetRestorePosn() calls
802 v42: * now does BufReadPre and BufReadPost events on file:///*
803 and file://localhost/*
804 v41: * installed file:///* and file://localhost/* handling
805 v40: * prevents redraw when a protocol error occurs so that the
806 user may see it
807 v39: * sftp support
808 v38: * Now uses NetRestorePosn() calls with Nread/Nwrite commands
809 * Temporary files now removed via bwipe! instead of bwipe
810 (thanks to Dave Roberts)
811 v37: * Claar's modifications which test if ftp is successful, otherwise
812 give an error message
813 * After a read, the alternate file was pointing to the temp file.
814 The temp file buffer is now wiped out.
815 * removed silent from transfer methods so user can see what's
816 happening
Bram Moolenaar071d4272004-06-13 20:20:40 +0000817
818
819==============================================================================
Bram Moolenaar69a7cb42004-06-20 12:51:53 +000082010. Credits *netrw-credits*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000821
822 Vim editor by Bram Moolenaar (Thanks, Bram!)
823 dav support by C Campbell
824 fetch support by Bram Moolenaar and C Campbell
825 ftp support by C Campbell <NdrOchip@ScampbellPfamily.AbizM> - NOSPAM
826 http support by Bram Moolenaar <bram@moolenaar.net>
827 rcp
828 rsync support by C Campbell (suggested by Erik Warendorph)
829 scp support by raf <raf@comdyn.com.au>
830 sftp support by C Campbell
831
832 inputsecret(), BufReadCmd, BufWriteCmd contributed by C Campbell
833
834 Jérôme Augé -- also using new buffer method with ftp+.netrc
835 Bram Moolenaar -- obviously vim itself, :e and v:cmdarg use, fetch,...
836 Yasuhiro Matsumoto -- pointing out undo+0r problem and a solution
837 Erik Warendorph -- for several suggestions (g:netrw_..._cmd
838 variables, rsync etc)
839 Doug Claar -- modifications to test for success with ftp operation
840
841==============================================================================
842 vim:tw=78:ts=8:ft=help:norl: