Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 1 | *pi_netrw.txt* For Vim version 6.2. Last change: Jun 15, 2004 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2 | |
| 3 | |
| 4 | VIM REFERENCE MANUAL by Charles E. Campbell, Jr. |
| 5 | |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 6 | *dav* *http* *network* *rcp* *scp* |
| 7 | *fetch* *netrw* *Nread* *rsync* *sftp* |
| 8 | *ftp* *netrw.vim* *Nwrite* *netrw-file* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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| |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 19 | 7. Remote Directory Listing............................|netrw-dir| |
| 20 | 8. Debugging...........................................|netrw-debug| |
| 21 | 9. History.............................................|netrw-history| |
| 22 | 10. Credits.............................................|netrw-credits| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 23 | |
| 24 | The functionality mentioned here is done via using |standard-plugin| |
| 25 | techniques. This plugin is only available if |
| 26 | |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 27 | set nocp " 'compatible' is not set |
| 28 | filetype plugin on " plugins are enabled |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 | |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 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" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 80 | :Nwrite ? give help |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 | |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 92 | DIRECTORY LISTING |
| 93 | :Nread [protocol]://[user]@hostname/path/ |
| 94 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 155 | by settinbg a variable (ex. scp uses the variable g:netrw_scp_cmd, |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 | +=================================+============================+============+ |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 188 | | Reading | Writing | Uses | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 189 | +=================================+============================+============+ |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 190 | | DAV: | | | |
| 191 | | dav://host/path | | cadaver | |
| 192 | | :Nread dav://host/path | :Nwrite dav://host/path | cadaver | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 193 | +---------------------------------+----------------------------+------------+ |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 194 | | FETCH: | | | |
| 195 | | fetch://[user@]host/path | | | |
| 196 | | fetch://[user@]host:http/path | Not Available | fetch | |
| 197 | | :Nread fetch://[user@]host/path| | | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 198 | +---------------------------------+----------------------------+------------+ |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 199 | | FILE: | | | |
| 200 | | file:///* | file:///* | | |
| 201 | | file://localhost/* | file://localhost/* | | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 202 | +---------------------------------+----------------------------+------------+ |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 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 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 208 | +---------------------------------+----------------------------+------------+ |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 209 | | HTTP: wget is executable: (*4) | | | |
| 210 | | http://[user@]host/path | Not Available | wget | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 211 | +---------------------------------+----------------------------+------------+ |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 212 | | HTTP: fetch is executable (*4) | | | |
| 213 | | http://[user@]host/path | Not Available | fetch | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 214 | +---------------------------------+----------------------------+------------+ |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 215 | | RCP: | | | |
| 216 | | rcp://[user@]host/path | rcp://[user@]host/path | rcp | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 217 | +---------------------------------+----------------------------+------------+ |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 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 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 222 | +---------------------------------+----------------------------+------------+ |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 223 | | SCP: | | | |
| 224 | | scp://[user@]host/path | scp://[user@]host/path | scp | |
| 225 | | :Nread scp://host/path | :Nwrite scp://host/path | scp (*1) | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 226 | +---------------------------------+----------------------------+------------+ |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 227 | | SFTP: | | | |
| 228 | | sftp://[user@]host/path | sftp://[user@]host/path | sftp | |
| 229 | | :Nread sftp://host/path | :Nwrite sftp://host/path | sftp (*1) | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 236 | prompt for user-id and pasword. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 237 | |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 238 | (*3) for ftp, "machine" may be machine#port or machine:port |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 | ============================================================================== |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 334 | 6. Variables and Options *netrw-options* *netrw-var* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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: |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 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 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 355 | want it used, then set this variable. Its |
| 356 | mere existence is enough to cause <.netrc> |
| 357 | to be ignored. |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 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 | < |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 372 | The script will also make use of the following variables internally, albeit |
| 373 | temporarily. |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 374 | > |
| 375 | ------------------- |
| 376 | Temporary Variables |
| 377 | ------------------- |
| 378 | Variable Meaning |
| 379 | -------- ------------------------------------ |
| 380 | < |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 381 | g:netrw_method Index indicating rcp/ftp+.netrc/ftp |
| 382 | g:netrw_machine Holds machine name parsed from input |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 383 | g:netrw_fname Holds filename being accessed > |
| 384 | ------------------------------------------------------------ |
| 385 | < |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 386 | *netrw-protocol* |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 387 | |
| 388 | Netrw supports a number of protocols. These protocols are invoked using the |
| 389 | variables listed below, and may be modified by the user. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 390 | > |
| 391 | ------------------------ |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 392 | Protocol Control Options |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 393 | ------------------------ |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 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() |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 410 | g:netrw_list_cmd variable ="ssh HOSTNAME ls -Fa" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 411 | g:netrw_rcp_cmd variable ="rcp" |
| 412 | g:netrw_rsync_cmd variable ="rsync -a" |
| 413 | g:netrw_scp_cmd variable ="scp -q" |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 414 | g:netrw_sftp_cmd variable ="sftp" > |
| 415 | ------------------------------------------------------------------------- |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 | |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 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 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 428 | temporary file: |
| 429 | > |
| 430 | IF g:netrw_ftp !exists or is not 1 IF g:netrw_ftp exists and is 1 |
| 431 | ---------------------------------- ------------------------------ |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 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 | --------------------------------------------------------------------- |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 451 | userid and password. The transferred file is put into a temporary file. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 | |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 458 | *netrw-fixup* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 474 | else " complain |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 486 | fun! NetReadFixup(method, line1, line2) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 487 | if method == 3 " ftp (no <.netrc>) |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 488 | let fourblanklines= line2 - 3 |
| 489 | silent fourblanklines.",".line2."g/^\s*/d" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 490 | endif |
| 491 | endfunction |
| 492 | endif |
| 493 | > |
| 494 | |
| 495 | ============================================================================== |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 496 | 7. Remote Directory Listing *netrw-dir* *netrw-list* |
| 497 | |
| 498 | Netrw supports listing (browsing) directories on remote hosts; simply attempt |
| 499 | to read a "file" with a trailing slash and it will be interpreted as a |
| 500 | request to browse a directory: |
| 501 | |
| 502 | vim [protocol]://[user@]hostname/path/ |
| 503 | |
| 504 | Netrw will modify the command in g:netrw_list to perform the directory listing |
| 505 | operation. By default the command is: |
| 506 | |
| 507 | ssh HOSTNAME ls -Fa |
| 508 | |
| 509 | where the HOSTNAME becomes the hostname as requested by the attempted |
| 510 | read. Naturally, the user may override this command with whatever is |
| 511 | preferred. The NetList function which implements remote directory |
| 512 | browsing expects that directories will be flagged by a trailing slash. |
| 513 | |
| 514 | Browsing is simple: move the cursor onto a file or directory of interest. |
| 515 | Hitting the <cr> (the return key) will select the file or directory. Directories |
| 516 | will themselves be listed, and files will be opened using the protocol given |
| 517 | in the original read request. |
| 518 | |
| 519 | |
| 520 | ============================================================================== |
| 521 | 8. Debugging *netrw-debug* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 522 | |
| 523 | The <netrw.vim> script is typically available as: |
| 524 | |
| 525 | /usr/local/share/vim/vim6x/plugin/netrw.vim |
| 526 | |
| 527 | which is loaded automatically at startup (assuming :set nocp). |
| 528 | |
| 529 | 1. Get the <Decho.vim> script, available as: |
| 530 | |
| 531 | http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_scripts |
| 532 | as "Decho, a vimL debugging aid" |
| 533 | or |
| 534 | http://vim.sourceforge.net/scripts/script.php?script_id=120 |
| 535 | |
| 536 | and put it into your local plugin directory |
| 537 | |
| 538 | 2. Edit the <netrw.vim> file as follows: |
| 539 | |
| 540 | :DechoOn |
| 541 | |
| 542 | (to restore to normal, use :DechoOff ) |
| 543 | |
| 544 | 3. Then bring up vim and attempt a transfer. A set of messages |
| 545 | should appear concerning the steps that <netrw.vim> took in |
| 546 | attempting to read/write your file over the network. Please |
| 547 | send that information to <netrw.vim>'s maintainer, |
| 548 | |
| 549 | drchipNOSPAM at campbellfamily.biz - NOSPAM |
| 550 | |
| 551 | ============================================================================== |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 552 | 9. History *netrw-history* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 553 | |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 554 | v46: * now handles remote directory browsing |
| 555 | * g:netrw_silent (if 1) will cause all transfers to be silent'd |
| 556 | v45: * made the [user@]hostname:path form a bit more restrictive |
| 557 | to better handle errors in using protocols |
| 558 | (e.g. scp:usr@host:file was being recognized as an rcp request) |
| 559 | v44: * changed from "rsync -a" to just "rsync" |
| 560 | * somehow an editing error messed up the test to recognize |
| 561 | use of the fetch method for NetRead. |
| 562 | * more debugging statements included |
| 563 | v43: * moved "Explanation" comments to <pi_netrw.txt> help file |
| 564 | as "Network Reference" (|netrw-ref|) |
| 565 | * <netrw.vim> now uses Dfunc() Decho() and Dret() for debugging |
| 566 | * removed superfluous NetRestorePosn() calls |
| 567 | v42: * now does BufReadPre and BufReadPost events on file:///* |
| 568 | and file://localhost/* |
| 569 | v41: * installed file:///* and file://localhost/* handling |
| 570 | v40: * prevents redraw when a protocol error occurs so that the |
| 571 | user may see it |
| 572 | v39: * sftp support |
| 573 | v38: * Now uses NetRestorePosn() calls with Nread/Nwrite commands |
| 574 | * Temporary files now removed via bwipe! instead of bwipe |
| 575 | (thanks to Dave Roberts) |
| 576 | v37: * Claar's modifications which test if ftp is successful, otherwise |
| 577 | give an error message |
| 578 | * After a read, the alternate file was pointing to the temp file. |
| 579 | The temp file buffer is now wiped out. |
| 580 | * removed silent from transfer methods so user can see what's |
| 581 | happening |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 582 | |
| 583 | |
| 584 | ============================================================================== |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 585 | 10. Credits *netrw-credits* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 586 | |
| 587 | Vim editor by Bram Moolenaar (Thanks, Bram!) |
| 588 | dav support by C Campbell |
| 589 | fetch support by Bram Moolenaar and C Campbell |
| 590 | ftp support by C Campbell <NdrOchip@ScampbellPfamily.AbizM> - NOSPAM |
| 591 | http support by Bram Moolenaar <bram@moolenaar.net> |
| 592 | rcp |
| 593 | rsync support by C Campbell (suggested by Erik Warendorph) |
| 594 | scp support by raf <raf@comdyn.com.au> |
| 595 | sftp support by C Campbell |
| 596 | |
| 597 | inputsecret(), BufReadCmd, BufWriteCmd contributed by C Campbell |
| 598 | |
| 599 | Jérôme Augé -- also using new buffer method with ftp+.netrc |
| 600 | Bram Moolenaar -- obviously vim itself, :e and v:cmdarg use, fetch,... |
| 601 | Yasuhiro Matsumoto -- pointing out undo+0r problem and a solution |
| 602 | Erik Warendorph -- for several suggestions (g:netrw_..._cmd |
| 603 | variables, rsync etc) |
| 604 | Doug Claar -- modifications to test for success with ftp operation |
| 605 | |
| 606 | ============================================================================== |
| 607 | vim:tw=78:ts=8:ft=help:norl: |