11
|
1 *pi_netrw.txt For Vim version 6.2. Last change: Jun 25, 2004
|
7
|
2
|
|
3
|
|
4 VIM REFERENCE MANUAL by Charles E. Campbell, Jr.
|
|
5
|
9
|
6 *dav* *http* *network* *rcp* *scp*
|
|
7 *fetch* *netrw* *Nread* *rsync* *sftp*
|
|
8 *ftp* *netrw.vim* *Nwrite* *netrw-file*
|
7
|
9
|
|
10 ==============================================================================
|
|
11 0. Contents *netrw-contents*
|
|
12
|
|
13 1. Netrw Reference.....................................|netrw-ref|
|
|
14 2. Network-Oriented File Transfer......................|netrw-xfer|
|
|
15 3. Activation..........................................|netrw-activate|
|
|
16 4. Transparent File Transfer...........................|netrw-transparent|
|
|
17 5. Ex Commands.........................................|netrw-ex|
|
|
18 6. Variables and Options...............................|netrw-var|
|
11
|
19 7. Remote Directory Browser............................|netrw-browse|
|
9
|
20 8. Debugging...........................................|netrw-debug|
|
|
21 9. History.............................................|netrw-history|
|
|
22 10. Credits.............................................|netrw-credits|
|
7
|
23
|
|
24 The functionality mentioned here is done via using |standard-plugin|
|
|
25 techniques. This plugin is only available if
|
|
26
|
9
|
27 set nocp " 'compatible' is not set
|
|
28 filetype plugin on " plugins are enabled
|
7
|
29
|
|
30 You can avoid loading this plugin by setting the "loaded_netrw" variable
|
|
31 in your <.vimrc> file: >
|
|
32
|
|
33 :let loaded_netrw = 1
|
|
34
|
|
35 {Vi does not have any of this}
|
|
36
|
|
37 ==============================================================================
|
|
38 1. 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
|
9
|
53 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"
|
7
|
63 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
|
9
|
80 :Nwrite ? give help
|
7
|
81 :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
|
9
|
92 DIRECTORY LISTING
|
|
93 :Nread [protocol]://[user]@hostname/path/
|
|
94
|
7
|
95 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 ==============================================================================
|
|
131 2. Network-Oriented File Transfer *netrw-xfer*
|
|
132
|
|
133 Network-oriented file transfer under Vim is implemented by a VimL-based script
|
|
134 (<netrw.vim>) using plugin techniques. It currently supports both reading
|
|
135 and writing across networks using rcp, scp, ftp or ftp+<.netrc>, scp, fetch,
|
|
136 dav/cadaver, rsync, or sftp.
|
|
137
|
|
138 http 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
|
|
141 various file transfer programs. It uses autocommand events (BufReadCmd,
|
|
142 FileReadCmd, BufWriteCmd) to intercept reads/writes with url-like filenames. >
|
|
143
|
|
144 ex. vim ftp://hostname/path/to/file
|
|
145 <
|
|
146 The characters preceding the colon specify the protocol to use;
|
|
147 in the example, its ftp. The <netrw.vim> script then formulates
|
|
148 a command or a series of commands (typically ftp) which it issues
|
|
149 to an external program (ftp, scp, etc) which does the actual file
|
|
150 transfer/protocol. Files are read from/written to a temporary file
|
|
151 (under Unix/Linux, /tmp/...) which the <netrw.vim> script will
|
|
152 clean up.
|
|
153
|
|
154 One may modify any protocol's implementing external application
|
9
|
155 by settinbg a variable (ex. scp uses the variable g:netrw_scp_cmd,
|
7
|
156 which is defaulted to "scp -q").
|
|
157
|
|
158 Ftp, an old protocol, seems to be blessed by numerous implementations.
|
|
159 Unfortunately, some implementations are noisy (ie., add junk to the end
|
|
160 of the file). Thus, concerned users may decide to write a NetReadFixup()
|
|
161 function 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
|
|
163 but is not noisy and more convenient, actually, for <netrw.vim> to use.
|
|
164 Consequently, if "fetch" is executable, it will be used to do reads for
|
|
165 ftp://... (and http://...) . See |netrw-var| for more about this.
|
|
166
|
|
167 For rcp, scp, sftp, and http, one may use network-oriented file transfers
|
|
168 transparently; ie.
|
|
169 >
|
|
170 vim rcp://[user@]machine/path
|
|
171 vim scp://[user@]machine/path
|
|
172 <
|
|
173 If your ftp supports <.netrc>, then it too can be just as transparently used
|
|
174 if the needed triad of machine name, user id, and password are present in
|
|
175 that file. Your ftp must be able to use the <.netrc> file on its own, however.
|
|
176 >
|
|
177 vim ftp://[user@]machine[[:#]portnumber]/path
|
|
178 <
|
|
179 However, ftp will often need to query the user for the userid and password.
|
|
180 The latter will be done "silently"; ie. asterisks will show up instead of
|
|
181 the actually-typed-in password. Netrw will retain the userid and password
|
|
182 for subsequent read/writes from the most recent transfer so subsequent
|
|
183 transfers (read/write) to or from that machine will take place without
|
|
184 additional prompting.
|
|
185
|
|
186 *netrw-urls*
|
|
187 +=================================+============================+============+
|
9
|
188 | Reading | Writing | Uses |
|
7
|
189 +=================================+============================+============+
|
9
|
190 | DAV: | | |
|
|
191 | dav://host/path | | cadaver |
|
|
192 | :Nread dav://host/path | :Nwrite dav://host/path | cadaver |
|
7
|
193 +---------------------------------+----------------------------+------------+
|
9
|
194 | FETCH: | | |
|
|
195 | fetch://[user@]host/path | | |
|
|
196 | fetch://[user@]host:http/path | Not Available | fetch |
|
|
197 | :Nread fetch://[user@]host/path| | |
|
7
|
198 +---------------------------------+----------------------------+------------+
|
9
|
199 | FILE: | | |
|
|
200 | file:///* | file:///* | |
|
|
201 | file://localhost/* | file://localhost/* | |
|
7
|
202 +---------------------------------+----------------------------+------------+
|
9
|
203 | 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 |
|
7
|
208 +---------------------------------+----------------------------+------------+
|
9
|
209 | HTTP: wget is executable: (*4) | | |
|
|
210 | http://[user@]host/path | Not Available | wget |
|
7
|
211 +---------------------------------+----------------------------+------------+
|
9
|
212 | HTTP: fetch is executable (*4) | | |
|
|
213 | http://[user@]host/path | Not Available | fetch |
|
7
|
214 +---------------------------------+----------------------------+------------+
|
9
|
215 | RCP: | | |
|
|
216 | rcp://[user@]host/path | rcp://[user@]host/path | rcp |
|
7
|
217 +---------------------------------+----------------------------+------------+
|
9
|
218 | 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 |
|
7
|
222 +---------------------------------+----------------------------+------------+
|
9
|
223 | SCP: | | |
|
|
224 | scp://[user@]host/path | scp://[user@]host/path | scp |
|
|
225 | :Nread scp://host/path | :Nwrite scp://host/path | scp (*1) |
|
7
|
226 +---------------------------------+----------------------------+------------+
|
9
|
227 | SFTP: | | |
|
|
228 | sftp://[user@]host/path | sftp://[user@]host/path | sftp |
|
|
229 | :Nread sftp://host/path | :Nwrite sftp://host/path | sftp (*1) |
|
7
|
230 +=================================+============================+============+
|
|
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
|
9
|
236 prompt for user-id and pasword.
|
7
|
237
|
9
|
238 (*3) for ftp, "machine" may be machine#port or machine:port
|
7
|
239 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
|
|
244 Both the :Nread and the :Nwrite ex-commands can accept multiple filenames.
|
|
245
|
|
246
|
|
247 NETRC *netrw-netrc*
|
|
248
|
|
249 The typical syntax for lines in a <.netrc> file is given as shown below.
|
|
250 Ftp 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
|
|
255 Your 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
|
|
257 password.
|
|
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
|
|
266 PASSWORD *netrw-passwd*
|
|
267
|
|
268 The script attempts to get passwords for ftp invisibly using |inputsecret()|,
|
|
269 a built-in Vim function. See |netrw-uidpass| for how to change the password
|
|
270 after one has set it.
|
|
271
|
|
272 Unfortunately there doesn't appear to be a way for netrw to feed a password
|
|
273 to scp. Thus every transfer via scp will require re-entry of the password.
|
|
274
|
|
275
|
|
276 ==============================================================================
|
|
277 3. Activation *netrw-activate*
|
|
278
|
|
279 Network-oriented file transfers are available by default whenever
|
|
280 |'nocompatible'| mode is enabled. The <netrw.vim> file resides in your
|
|
281 system's vim-plugin directory and is sourced automatically whenever you
|
|
282 bring up vim.
|
|
283
|
|
284
|
|
285 ==============================================================================
|
|
286 4. Transparent File Transfer *netrw-transparent*
|
|
287
|
|
288 Transparent file transfers occur whenever a regular file read or write
|
|
289 (invoked via an |:autocmd| for |BufReadCmd| or |BufWriteCmd| events) is made.
|
|
290 Thus one may use files across networks as if they were local. >
|
|
291
|
|
292 vim ftp://[user@]machine/path
|
|
293 ...
|
|
294 :wq
|
|
295
|
|
296
|
|
297 ==============================================================================
|
|
298 5. Ex Commands *netrw-ex*
|
|
299
|
|
300 The usual read/write commands are supported. There are also a couple of
|
|
301 additional 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 ==============================================================================
|
9
|
334 6. Variables and Options *netrw-options* *netrw-var*
|
7
|
335
|
|
336 The script <netrw.vim> uses several variables which can affect <netrw.vim>'s
|
|
337 behavior. These variables typically may be set in the user's <.vimrc> file:
|
9
|
338 >
|
|
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
|
7
|
355 want it used, then set this variable. Its
|
|
356 mere existence is enough to cause <.netrc>
|
|
357 to be ignored.
|
9
|
358 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 <
|
7
|
372 The script will also make use of the following variables internally, albeit
|
|
373 temporarily.
|
9
|
374 >
|
|
375 -------------------
|
|
376 Temporary Variables
|
|
377 -------------------
|
|
378 Variable Meaning
|
|
379 -------- ------------------------------------
|
|
380 <
|
7
|
381 g:netrw_method Index indicating rcp/ftp+.netrc/ftp
|
|
382 g:netrw_machine Holds machine name parsed from input
|
9
|
383 g:netrw_fname Holds filename being accessed >
|
|
384 ------------------------------------------------------------
|
|
385 <
|
|
386 *netrw-protocol*
|
7
|
387
|
9
|
388 Netrw supports a number of protocols. These protocols are invoked using the
|
|
389 variables listed below, and may be modified by the user.
|
7
|
390 >
|
|
391 ------------------------
|
9
|
392 Protocol Control Options
|
7
|
393 ------------------------
|
9
|
394 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()
|
7
|
405 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
|
9
|
410 g:netrw_list_cmd variable ="ssh HOSTNAME ls -Fa"
|
7
|
411 g:netrw_rcp_cmd variable ="rcp"
|
|
412 g:netrw_rsync_cmd variable ="rsync -a"
|
|
413 g:netrw_scp_cmd variable ="scp -q"
|
9
|
414 g:netrw_sftp_cmd variable ="sftp" >
|
|
415 -------------------------------------------------------------------------
|
7
|
416 <
|
|
417 The first two options both help with certain ftp's that give trouble otherwise.
|
|
418 In order to best understand how to use these options if ftp is giving you
|
|
419 troubles, a bit of discussion follows on how netrw does ftp reads.
|
|
420
|
|
421 The g:netrw_..._cmd variables specify the external program to use handle
|
|
422 the associated protocol (rcp, ftp, etc), plus any options.
|
|
423
|
9
|
424 The g:netrw_list_cmd's HOSTNAME entry will be changed via substitution with
|
|
425 whatever the current request is for a hostname.
|
|
426
|
|
427 For ftp, netrw typically builds up lines of one of the following formats in a
|
7
|
428 temporary file:
|
|
429 >
|
|
430 IF g:netrw_ftp !exists or is not 1 IF g:netrw_ftp exists and is 1
|
|
431 ---------------------------------- ------------------------------
|
9
|
432 <
|
|
433 open machine [port] open machine [port]
|
|
434 user userid password userid password
|
|
435 [g:netrw_ftpmode] password
|
|
436 get filename tempfile [g:netrw_ftpmode]
|
|
437 get filename tempfile >
|
|
438 ---------------------------------------------------------------------
|
7
|
439 <
|
|
440 Netrw then executes the lines above by use of a filter:
|
|
441 >
|
|
442 :%! {g:netrw_ftp_cmd} -i [-n]
|
|
443 <
|
|
444
|
|
445 where
|
|
446 g:netrw_ftp_cmd is usually "ftp",
|
|
447 -i tells ftp not to be interactive
|
|
448 -n means don't use netrc and is used for Method #3 (ftp w/o <.netrc>)
|
|
449
|
|
450 If <.netrc> exists it will be used to avoid having to query the user for
|
9
|
451 userid and password. The transferred file is put into a temporary file.
|
7
|
452 The temporary file is then read into the main editing session window that
|
|
453 requested it and the temporary file deleted.
|
|
454
|
|
455 If your ftp doesn't accept the "user" command and immediately just demands
|
|
456 a userid, then try putting "let netrw_ftp=1" in your <.vimrc>.
|
|
457
|
9
|
458 *netrw-fixup*
|
7
|
459 If your ftp for whatever reason generates unwanted lines (such as AUTH
|
|
460 messages) you may write a NetReadFixup(tmpfile) function:
|
|
461 >
|
|
462 function! NetReadFixup(method,line1,line2)
|
|
463 " a:line1: first new line in current file
|
|
464 " a:line2: last new line in current file
|
|
465 if a:method == 1 "rcp
|
|
466 elseif a:method == 2 "ftp + <.netrc>
|
|
467 elseif a:method == 3 "ftp + machine,uid,password,filename
|
|
468 elseif a:method == 4 "scp
|
|
469 elseif a:method == 5 "http/wget
|
|
470 elseif a:method == 6 "dav/cadaver
|
|
471 elseif a:method == 7 "rsync
|
|
472 elseif a:method == 8 "fetch
|
|
473 elseif a:method == 9 "sftp
|
9
|
474 else " complain
|
7
|
475 endif
|
|
476 endfunction
|
|
477 >
|
|
478 The NetReadFixup() function will be called if it exists and thus allows
|
|
479 you to customize your reading process. As a further example, <netrw.vim>
|
|
480 contains just such a function to handle Windows 95 ftp. For whatever
|
|
481 reason, Windows 95's ftp dumps four blank lines at the end of a transfer,
|
|
482 and so it is desirable to automate their removal. Here's some code taken
|
|
483 from <netrw.vim> itself:
|
|
484 >
|
|
485 if has("win95") && g:netrw_win95ftp
|
9
|
486 fun! NetReadFixup(method, line1, line2)
|
7
|
487 if method == 3 " ftp (no <.netrc>)
|
9
|
488 let fourblanklines= line2 - 3
|
|
489 silent fourblanklines.",".line2."g/^\s*/d"
|
7
|
490 endif
|
|
491 endfunction
|
|
492 endif
|
|
493 >
|
|
494
|
|
495 ==============================================================================
|
11
|
496 7. Remote Directory Browser *netrw-browse* *netrw-dir* *netrw-list*
|
|
497 >
|
|
498 ------- -----------
|
|
499 Command Explanation
|
|
500 ------- -----------
|
|
501 <cr> Netrw will enter the directory or read the file
|
|
502 <del> Netrw will attempt to remove the file/directory
|
|
503 D Netrw will attempt to remove the file(s)/directory(ies)
|
|
504 R Netrw will attempt to rename the file(s)/directory(ies)
|
|
505 - Makes Netrw go up one directory
|
|
506 a Show all of a directory (temporarily ignore g:netrw_list_hide)
|
|
507 o Enter the file/directory under the cursor in a new browser
|
|
508 window. A horizontal split is used.
|
|
509 v Enter the file/directory under the cursor in a new browser
|
|
510 window. A vertical split is used.
|
|
511 x Apply a function to a file.
|
|
512 <c-l> Causes Netrw to refresh the directory listing
|
|
513 ? Causes Netrw to issue help
|
|
514 <
|
|
515 *netrw-browse-var*
|
|
516 >
|
|
517 --- -----------
|
|
518 Var Explanation
|
|
519 --- -----------
|
|
520 g:netrw_list_cmd supports listing
|
|
521 g:netrw_rm_cmd supports removing files
|
|
522 g:netrw_rmf_cmd supports removing softlinks to directories
|
|
523 g:netrw_rmdir_cmd supports removing directories
|
|
524 g:netrw_winsize specify initial size of new o/v windows
|
|
525 g:netrw_list_hide comma separated list of patterns for
|
|
526 hiding files
|
|
527 <
|
|
528 Netrw supports the browsing of directories on remote hosts, including
|
|
529 generating listing directories, entering directories, editing files
|
|
530 therein, deleting files/directories, and moving (renaming) files and
|
|
531 directories.
|
9
|
532
|
11
|
533 To enter the netrw directory browser, simply attempt to read a "file" with a
|
|
534 trailing slash and it will be interpreted as a request to list a directory:
|
9
|
535
|
|
536 vim [protocol]://[user@]hostname/path/
|
|
537
|
11
|
538 Netrw will modify the command in g:netrw_list_cmd to perform the directory
|
|
539 listing operation. By default the command is:
|
9
|
540
|
11
|
541 ssh HOSTNAME ls -FLa
|
9
|
542
|
11
|
543 where the HOSTNAME becomes the [user@]hostname as requested by the attempt
|
|
544 to read. Naturally, the user may override this command with whatever is
|
9
|
545 preferred. The NetList function which implements remote directory
|
|
546 browsing expects that directories will be flagged by a trailing slash.
|
|
547
|
|
548 Browsing is simple: move the cursor onto a file or directory of interest.
|
11
|
549 Hitting the <cr> (the return key) will select the file or directory.
|
|
550 Directories will themselves be listed, and files will be opened using the
|
|
551 protocol given in the original read request.
|
|
552
|
|
553 *netrw-delete* *netrw-remove*
|
|
554
|
|
555 Deleting/removing files and directories involves moving the cursor to the
|
|
556 file/directory to be deleted and pressing "D". Directories must be empty
|
|
557 first before they can be successfully removed. If the directory is a softlink
|
|
558 to a directory, then netrw will make two requests to remove the directory
|
|
559 before succeeding. Netrw will ask for confirmation before doing the
|
|
560 removal(s). You may select a range of lines with the "V" command (visual
|
|
561 selection), and then pressing "D".
|
|
562
|
|
563 The g:netrw_rm_cmd, g:netrw_rmf_cmd, and g:netrw_rmdir_cmd variables are
|
|
564 used to control the attempts to remove files and directories. The
|
|
565 g:netrw_rm_cmd is used with files, and its default value is:
|
|
566
|
|
567 g:netrw_rm_cmd: ssh HOSTNAME rm
|
|
568
|
|
569 The g:netrw_rmdir_cmd is used with directories. Its default value is:
|
|
570
|
|
571 g:netrw_rmdir_cmd: ssh HOSTNAME rmdir
|
|
572
|
|
573 If removing a directory fails with g:netrw_rmdir_cmd, netrw then will attempt
|
|
574 to remove it again using the g:netrw_rmf_cmd. Its default value is:
|
|
575
|
|
576 g:netrw_rmf_cmd: ssh HOSTNAME rm -f
|
|
577
|
|
578 *netrw-x*
|
|
579
|
|
580 The Netrw executor applies a user-defined function to a file, based on its
|
|
581 extension. Of course, the handler function must exist for it to be called.
|
|
582 >
|
|
583 Ex. mypgm.html x -> NetrwFileHandler_html("scp://user@host/some/path/mypgm.html")
|
|
584 <
|
|
585 See the <NetrwFileHandlers.vim>
|
|
586
|
|
587 *netrw-move* *netrw-rename*
|
|
588
|
|
589 Renaming/moving files and directories involves moving the cursor to the
|
|
590 file/directory to be moved (renamed) and pressing "R". You will then be
|
|
591 queried for where you want the file/directory to be moved. You may select a
|
|
592 range of lines with the "V" command (visual selection), and then pressing "R".
|
|
593
|
|
594 The g:netrw_rename_cmd is used to implement renaming. By default its
|
|
595 value is:
|
|
596
|
|
597 ssh HOSTNAME mv
|
|
598
|
|
599 *netrw-list-hack*
|
|
600 For Linux/Unix systems, I suggest looking into
|
|
601
|
|
602 http://hacks.oreilly.com/pub/h/66
|
|
603
|
|
604 It gives a tip for setting up password-less use of ssh and scp, and discusses
|
|
605 the associated security issues.
|
9
|
606
|
|
607
|
|
608 ==============================================================================
|
|
609 8. Debugging *netrw-debug*
|
7
|
610
|
|
611 The <netrw.vim> script is typically available as:
|
|
612
|
|
613 /usr/local/share/vim/vim6x/plugin/netrw.vim
|
|
614
|
|
615 which is loaded automatically at startup (assuming :set nocp).
|
|
616
|
|
617 1. Get the <Decho.vim> script, available as:
|
|
618
|
|
619 http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_scripts
|
|
620 as "Decho, a vimL debugging aid"
|
|
621 or
|
|
622 http://vim.sourceforge.net/scripts/script.php?script_id=120
|
|
623
|
|
624 and put it into your local plugin directory
|
|
625
|
|
626 2. Edit the <netrw.vim> file as follows:
|
|
627
|
|
628 :DechoOn
|
|
629
|
|
630 (to restore to normal, use :DechoOff )
|
|
631
|
|
632 3. Then bring up vim and attempt a transfer. A set of messages
|
|
633 should appear concerning the steps that <netrw.vim> took in
|
|
634 attempting to read/write your file over the network. Please
|
|
635 send that information to <netrw.vim>'s maintainer,
|
|
636
|
|
637 drchipNOSPAM at campbellfamily.biz - NOSPAM
|
|
638
|
|
639 ==============================================================================
|
9
|
640 9. History *netrw-history*
|
7
|
641
|
11
|
642 v47: *
|
9
|
643 v46: * now handles remote directory browsing
|
|
644 * g:netrw_silent (if 1) will cause all transfers to be silent'd
|
|
645 v45: * made the [user@]hostname:path form a bit more restrictive
|
|
646 to better handle errors in using protocols
|
|
647 (e.g. scp:usr@host:file was being recognized as an rcp request)
|
|
648 v44: * changed from "rsync -a" to just "rsync"
|
|
649 * somehow an editing error messed up the test to recognize
|
|
650 use of the fetch method for NetRead.
|
|
651 * more debugging statements included
|
|
652 v43: * moved "Explanation" comments to <pi_netrw.txt> help file
|
|
653 as "Network Reference" (|netrw-ref|)
|
|
654 * <netrw.vim> now uses Dfunc() Decho() and Dret() for debugging
|
|
655 * removed superfluous NetRestorePosn() calls
|
|
656 v42: * now does BufReadPre and BufReadPost events on file:///*
|
|
657 and file://localhost/*
|
|
658 v41: * installed file:///* and file://localhost/* handling
|
|
659 v40: * prevents redraw when a protocol error occurs so that the
|
|
660 user may see it
|
|
661 v39: * sftp support
|
|
662 v38: * Now uses NetRestorePosn() calls with Nread/Nwrite commands
|
|
663 * Temporary files now removed via bwipe! instead of bwipe
|
|
664 (thanks to Dave Roberts)
|
|
665 v37: * Claar's modifications which test if ftp is successful, otherwise
|
|
666 give an error message
|
|
667 * After a read, the alternate file was pointing to the temp file.
|
|
668 The temp file buffer is now wiped out.
|
|
669 * removed silent from transfer methods so user can see what's
|
|
670 happening
|
7
|
671
|
|
672
|
|
673 ==============================================================================
|
9
|
674 10. Credits *netrw-credits*
|
7
|
675
|
|
676 Vim editor by Bram Moolenaar (Thanks, Bram!)
|
|
677 dav support by C Campbell
|
|
678 fetch support by Bram Moolenaar and C Campbell
|
|
679 ftp support by C Campbell <NdrOchip@ScampbellPfamily.AbizM> - NOSPAM
|
|
680 http support by Bram Moolenaar <bram@moolenaar.net>
|
|
681 rcp
|
|
682 rsync support by C Campbell (suggested by Erik Warendorph)
|
|
683 scp support by raf <raf@comdyn.com.au>
|
|
684 sftp support by C Campbell
|
|
685
|
|
686 inputsecret(), BufReadCmd, BufWriteCmd contributed by C Campbell
|
|
687
|
|
688 Jérôme Augé -- also using new buffer method with ftp+.netrc
|
|
689 Bram Moolenaar -- obviously vim itself, :e and v:cmdarg use, fetch,...
|
|
690 Yasuhiro Matsumoto -- pointing out undo+0r problem and a solution
|
|
691 Erik Warendorph -- for several suggestions (g:netrw_..._cmd
|
|
692 variables, rsync etc)
|
|
693 Doug Claar -- modifications to test for success with ftp operation
|
|
694
|
|
695 ==============================================================================
|
|
696 vim:tw=78:ts=8:ft=help:norl:
|