*pi_netrw.txt* For Vim version 7.2. 最近更新: 2008年8月
NETRW 参考手册 作者: Charles E. Campbell, Jr.
译者: Willis
http://vimcdoc.sf.net
*dav* *ftp* *netrw-file* *Nread* *rcp* *scp*
*davs* *http* *netrw.vim* *Nsource* *rsync* *sftp*
*fetch* *netrw* *network* *Nwrite*
1. 内容 *netrw-contents* {{{1
1. 内容.................................................|netrw-contents| 2. netrw 初步...........................................|netrw-start| 3. netrw 参考手册.......................................|netrw-ref| 外 部 程 序 及 协 议...............................|netrw-externapp| 读 取..............................................|netrw-read| 写 入..............................................|netrw-write| 目 录 列 表........................................|netrw-dirlist| 改 变 用 户 名 和 密 码............................|netrw-chgup| 变 量 与 设 置.....................................|netrw-variables| 路 径..............................................|netrw-path| 4. 基于网络的文件传输...................................|netrw-xfer| NETRC..............................................|netrw-netrc| 密 码..............................................|netrw-passwd| 5. 激活.................................................|netrw-activate| 6. 透明文件编辑.........................................|netrw-transparent| 7. Ex 命令..............................................|netrw-ex| 8. 变量和选项...........................................|netrw-var| 9. 目录浏览.............................................|netrw-browse| 浏览简介...........................................|netrw-intro-browse| 快速参考: 映射.....................................|netrw-browse-maps| 快速参考: 命令.....................................|netrw-browse-cmds| 把目录加入书签.....................................|netrw-mb| 浏览...............................................|netrw-cr| 水平分割窗口方式浏览...............................|netrw-o| 在新标签页中浏览...................................|netrw-t| 垂直分割窗口方式浏览...............................|netrw-v| 改变列表方式.......................................|netrw-i| 切换到收入书签的目录...............................|netrw-gb| 切换到较早访问的目录...............................|netrw-u| 切换到较迟访问的目录...............................|netrw-U| 通过用户函数定制浏览...............................|netrw-x| 删除文件或目录.....................................|netrw-D| 目录探索命令.......................................|netrw-explore| 使用星号和模式进行探索.............................|netrw-star| 显示文件信息.......................................|netrw-qf| 编辑文件或目录隐藏列表.............................|netrw-ctrl-h| 编辑排序序列.......................................|netrw-S| 向上一层...........................................|netrw--| 隐藏文件或目录.....................................|netrw-a| 改进浏览...........................................|netrw-ssh-hack| 列出书签和历史.....................................|netrw-qb| 建立新目录.........................................|netrw-d| 使浏览目录成为当前目录.............................|netrw-c| 标记文件...........................................|netrw-mf| 用正规表达式标记文件...............................|netrw-mr| 带标记文件: 任意命令...............................|netrw-mx| 带标记文件: 压缩及解压缩...........................|netrw-mz| 带标记文件: 复制...................................|netrw-mc| 带标记文件: 比较...................................|netrw-md| 带标记文件: 编辑...................................|netrw-me| 带标记文件: grep...................................|netrw-mg| 带标记文件: 按后缀隐藏或显示.......................|netrw-mh| 带标记文件: 移动...................................|netrw-mm| 带标记文件: 打印...................................|netrw-mp| 带标记文件: 执行...................................|netrw-ms| 带标记文件: 建立标签...............................|netrw-mT| 带标记文件: 设置目标目录...........................|netrw-mt| 带标记文件: 撤销标记...............................|netrw-mu| netrw 浏览器变量...................................|netrw-browser-var| netrw 浏览和选项不兼容性...........................|netrw-incompatible| netrw 设置............. ...........................|netrw-settings| 获取文件...........................................|netrw-O| 预览窗口...........................................|netrw-p| 前次窗口...........................................|netrw-P| 刷新列表...........................................|netrw-ctrl-l| 给文件或目录换名...................................|netrw-move| 反转排序顺序.......................................|netrw-r| 选择排序风格.......................................|netrw-s| 10. 问题和修正...........................................|netrw-problems| 11. 调试 netrw 自身......................................|netrw-debug| 12. 历史。...............................................|netrw-history| 13. 鸣谢.................................................|netrw-credits|{Vi 没有此项功能}
2. netrw 初步 *netrw-start* {{{1
netrw 使得读写文件和通过本地或网络进行和浏览变得容易! 首先,确信你打开了插件。这样,你需要至少在<.vimrc>里设置: (或者参见 |netrw-activate|)set nocp " 不设置 'compatible'filetype plugin on " 允许使用插件(见 |'cp'| 和 |:filetype-plugin-on|) netrw 支持用 url "透明" 地编辑其它机器上的文件 (见 |netrw-transparent|)。考虑 一个例子,假设你在其它机器上有一个帐号;如果 scp 可用的话,尝试vim scp://hostname/path/to/file想使 ssh/scp 更容易使用么?察看 |netrw-ssh-hack|! 如果你只有 ftp,没有 ssh/scp 怎么办?也很容易;尝试vim ftp://hostname/path/to/file想使 ftp 更容易使用么?检查你的 ftp 是不是支持叫<.netrc>的文件 -- 通常,它在 你的主目录里,读写权限的设置只限用户自己可读 (也就是,没有组、世界、其它用户等 的权限),其形式是以下这样的行machine HOSTNAME login USERID password "PASSWORD"machine HOSTNAME login USERID password "PASSWORD"...default login USERID password "PASSWORD"还有浏览 -- 你只想在编辑文件前四处看看。在自己机器上浏览,只要 "编辑" 目录:vim .vim /home/userid/path要在远端机器上浏览,也就是 "编辑" 目录 (但要确保目录名后面跟上 "/"):vim scp://hostname/vim ftp://hostname/path/to/dir/详情可见 |netrw-browse|! 除了 scp 和 ftp 以外,还支持更多其他的协议!关于如何使用这些外部应用,见下一 节,|netrw-externapp|。 如果你想使用插件,但由于某种原因不想用 netrw,那你需要禁止调入 netrw 插件本身 和自动调入的部分。为此,在<.vimrc>里加入如下两行::let g:loaded_netrw = 1:let g:loaded_netrwPlugin = 1
3. netrw 参考手册 *netrw-ref* {{{1
除了 |netrw-start| 提到的 scp 和 ftp 以外,netrw 还支持几个协议。包括 dav、 fetch、http、...。可以参阅 |netrw-externapp| 的列表。每个协议和一个变量关 联,该变量指定支持协议的缺省命令。 外 部 程 序 及 协 议 *netrw-externapp* {{{2 协议 变量 缺省值 -------- ---------------- ------------- dav: *g:netrw_dav_cmd* = "cadaver" fetch: *g:netrw_fetch_cmd* = "fetch -o" 如果 fetch 可用 ftp: *g:netrw_ftp_cmd* = "ftp" http: *g:netrw_http_cmd* = "curl -o" 如果 curl 可用 http: g:netrw_http_cmd = "wget -q -O" 否则,如果 wget 可用 http: g:netrw_http_cmd = "fetch -o" 否则,如果 fetch 可用 rcp: *g:netrw_rcp_cmd* = "rcp" rsync: *g:netrw_rsync_cmd* = "rsync -a" scp: *g:netrw_scp_cmd* = "scp -q" sftp: *g:netrw_sftp_cmd* = "sftp" 读 取 *netrw-read* *netrw-nread* {{{2 一般的,普通的编辑命令都可以使用 url 形式,例如:e ftp://[user@]machine/pathNetrw 也支持 Nread 命令: :Nread ? 给出帮助 :Nread "machine:file" 使用 rcp :Nread "machine file" 使用 ftp 并用<.netrc>:Nread "machine id password file" 使用 ftp :Nread "dav://machine[:port]/file" 使用 cadaver :Nread "fetch://[user@]machine/file" 使用 fetch :Nread "ftp://[user@]machine[[:#]port]/file" 使用 ftp 并用<.netrc>:Nread "http://[user@]machine/file" 使用 http 用 wget 方法 :Nread "rcp://[user@]machine/file" 使用 rcp :Nread "rsync://[user@]machine[:port]/file" 使用 rsync :Nread "scp://[user@]machine[[:#]port]/file" 使用 scp :Nread "sftp://[user@]machine/file" 使用 sftp 写 入 *netrw-write* *netrw-nwrite* {{{2 普通的保存命令都可以使用 url 形式,例如:w ftp://[user@]machine/pathNetrw 也支持 Nwrite 命令: :Nwrite ? 给出帮助 :Nwrite "machine:file" 使用 rcp :Nwrite "machine file" 使用 ftp 并用<.netrc>:Nwrite "machine id password file" 使用 ftp :Nwrite "dav://machine[:port]/file" 使用 cadaver :Nwrite "ftp://[user@]machine[[:#]port]/file" 使用 ftp 并用<.netrc>:Nwrite "rcp://[user@]machine/file" 使用 rcp :Nwrite "rsync://[user@]machine[:port]/file" 使用 rsync :Nwrite "scp://[user@]machine[[:#]port]/file" 使用 scp :Nwrite "sftp://[user@]machine/file" 使用 sftp 不支持 http: 协议! 执 行 脚 本 *netrw-source* {{{2 普通的执行脚本命令都可以使用 url 形式,例如:so ftp://[user@]machine/pathNetrw 也支持 Nsource 命令: :Nsource ? 给出帮助 :Nsource "dav://machine[:port]/path" 使用 cadaver :Nsource "fetch://[user@]machine/path" 使用 fetch :Nsource "ftp://[user@]machine[[:#]port]/path" 使用 ftp w/<.netrc>:Nsource "http://[user@]machine/path" 使用 http 用 wget 方法 :Nsource "rcp://[user@]machine/path" 使用 rcp :Nsource "rsync://[user@]machine[:port]/path" 使用 rsync :Nsource "scp://[user@]machine[[:#]port]/path" 使用 scp :Nsource "sftp://[user@]machine/path" 使用 sftp 目 录 列 表 *netrw-dirlist* {{{2 要浏览一个目录以得到文件列表,只需编辑该目录::e scp://[user]@hostname/path/:e ftp://[user]@hostname/path/对于远程目录 (也就是使用 scp 或 ftp 的那些),结尾的 "/" 是必需的 (它 告诉 netrw 使用目录方式浏览而不是去下载文件)。 不过,Nread 命令也可完成: :Nread [protocol]://[user]@hostname/path/ *netrw-login* *netrw-password* 改 变 用 户 名 和 密 码 *netrw-chgup* *netrw-userpass* {{{2 使用 ftp 的尝试会提示你输入用户名字和密码。它们被存在全局变量 g:netrw_uid 和 s:netrw_passwd 里。下一次使用 ftp 就会再次使用这两个项 目来简化 ftp 将来的应用。不过,如果你要使用别的用户名和/或密码,先调用 NetUserPass()。为了解决输入密码的问题,检查一下你的 ftp 是否支持在你的 主目录下的<.netrc>文件。另见 |netrw-passwd| (如果你用 ssh/scp 但希望 知道如何能不输入密码,见 |netrw-ssh-hack|)。 :NetUserPass [uid [password]] -- 如果需要,提示 :call NetUserPass() -- 提示 uid 和 password :call NetUserPass("uid") -- 提示 password :call NetUserPass("uid","password") -- 设置全局 uid 和 password NETRW 变 量 和 设 置 *netrw-variables* {{{2 (另见: |netrw-browser-var| |netrw-protocol| |netrw-settings| |netrw-var|) netrw 提供很多变量,方便你根据自己的喜好定制 netrw。一个查阅这些变量的方法是 :NetrwSettings (见 |netrw-settings|),它显示你当前的 netrw 设置。大多数设置在 下面描述,还有的在 |netrw-browser-options| 和 |netrw-externapp| 那里: *b:netrw_lastfile* 最近一次通过网络读写的文件,该变量局部于缓冲区 (用于支持无参数的 :Nw ) *g:netrw_ftp* 如果不存在,用缺省的 ftp =0 使用缺省的 ftp (uid password) =1 使用替代的 ftp 方法 (user uid password) 如果你的 ftp 使用有问题,尝试修改此值,看看另一个 ftp 方法是否适合你的设置。 *g:netrw_extracmd* 缺省: 不存在 如果此变量存在,那么它包含的任何字符串将被加入到发送给 ftp 客户的命令中。一个例子: ="passive" *g:netrw_ftpmode* ="binary" (缺省) ="ascii" *g:netrw_ignorenetrc* =0 (linux、cygwin 缺省) =1 如果你有<.netrc>文件但不能工作,设置此变量可以忽 略该文件。(Windows + cmd.exe 缺省) *g:netrw_menu* =0 关闭 netrw 菜单 =1 (缺省) 打开 netrw 菜单 *g:netrw_nogx* 如果此变量存在,"gx" 映射不可用 (见 |netrw-gx|) *g:netrw_uid* (ftp) 用户名, 可用于同一会话中 *s:netrw_passwd* (ftp) 密码, 可用于同一会话中 *g:netrw_preview* =0 (缺省) 在横向分割的窗口中显示预览窗口 =1 在纵向分割的窗口中显示预览窗口 以相同方式影响 "前次窗口" (见 |netrw-P|)。 *g:netrw_scpport* = "-P" : 设置 scp 端口的选项 *g:netrw_sshport* = "-p" : 设置 ssh 端口的选项 *g:netrw_silent* =0 : 正常方式完成传输 =1 : 安静方式完成传输 *g:netrw_use_errorwindow* =1 : netrw 的消息会使用分开的单行窗口。该窗口提供 了消息的可靠传送。(缺省) =0 : netrw 的消息使用 echoerr;这种方式下不是所有 消息都保证能看到,但不需要退出窗口。 *g:netrw_win95ftp* =1 如果使用 Win95,删除四个操作系统在传输时 "提供" 的 拖尾行 =0 强制正常的 ftp 行为 (不删除拖尾的行) *g:netrw_cygwin* =1 假设在 windows 上的 scp 是 cygwin 的版本。同时允许 用带时间和大小排序的 ls 进行网络浏览 (windows 的缺 省值) =0 假设在 windows 上的 scp 接受 windows 风格的路径 网络浏览使用 dir 而不是 ls 如果使用 unix,忽略此选项 *g:netrw_use_nt_rcp* =0 不要使用 WinNT、Win2000 和 WinXP 的 rcp (缺省) =1 使用 WinNT 二进制模式的 rcp 路 径 *netrw-path* {{{2 对于多数协议,文件路径通常相对于用户目录。不过,有的协议里路径可以相对于一些相 关的目录。例如: vim scp://user@host/somefile例如: vim scp://user@host/subdir1/subdir2/somefile其中 "somefile" 在 "user" 的主目录。如果你想要文件相对于根目录的路径,使用完整 路径:例如: vim scp://user@host//somefile例如: vim scp://user@host//subdir1/subdir2/somefile
4. 基于网络的文件传输 *netrw-xfer* {{{1
Vim 下基于网络的文件传输是用基于 Vim 脚本的插件技术实现的 (<netrw.vim>)。目 前,它支持基于网络的读写,并支持 rcp、scp、ftp 或者 ftp+<.netrc>、scp、fetch、 dav/cadaver、rsync、 或者 sftp。 目前,http 只支持通过 wget 或者 fetch 读取。<netrw.vim>是一个标准插件,它起到 Vim 和若干文件传输程序的粘结剂作用。它使用 自动命令事件 (BufReadCmd、FileReadCmd、BufWriteCmd) 来拦截貌似 url 的文件名的 读写。例如 vim ftp://hostname/path/to/file冒号前面的字符序列指定所使用的协议;在这个例子里,就是 ftp。<netrw.vim>脚本然后构成一个或多个命令 (一般是 ftp),然后用外部程序去执行 (ftp,scp 等) 来完成实际的文件传输/协议。文件被先读写到一个临时文件里 (在 Unix/Linux 上,/tmp/...),<netrw.vim>脚本会清理该文件。 *netrw-putty* *netrw-pscp* *netrw-psftp* 你可以通过修改变量修改任何实现协议的外部应用程序 (例如,scp 使用 g:netrw_scp_cmd 变量,缺省是 "scp -q")。 例如,考虑 PuTTY 的使用:let g:netrw_scp_cmd = '"c:\Program Files\PuTTY\pscp.exe" -q -batch'let g:netrw_sftp_cmd= '"c:\Program Files\PuTTY\psftp.exe"'|netrw-p8| 介绍更多,如 putty、pscp、psftp 等。 ftp,一个古老的协议,看来被很多实现所支持。不幸的是,很多实现都有问题 (例如, 在文件尾部加入垃圾字符)。所以,如果有这样的问题,用户可以自己决定写一个 NetReadFixup() 函数来在从 ftp 读文件后进行清理。有些 Unix 系统 (例如, FreeBSD) 提供了一个叫 "fetch" 的工具,它使用 ftp 协议,但是没有这样的问题,而 且更方便<netrw.vim>的使用。所以,只要 "fetch" 可以执行,它就被用来实现 ftp://... (和 http://...) 的读取。见 |netrw-var| 来了解详情。 对于 rcp、scp、sftp 和 http 协议,你可能希望基于网络的文件传输尽可能透明;例如vim rcp://[user@]machine/pathvim scp://[user@]machine/path如果你的 ftp 支持<.netrc>,那么也可以透明的使用 ftp,因为需要的机器名字,用户 名和密码都定义在这个文件里。你的 ftp 必须自己能理解并使用<.netrc>文件。可以 这样,vim ftp://[user@]machine[[:#]portnumber]/path不然,ftp 通常需要查询用户需要的用户名和密码。后者通常不会被显示出来;也就是, 输入的密码显示的是星号。netrw 会保留用户名和密码,以便以后从相同机器的读写不需 要再提示输入。 *netrw-urls* +=================================+============================+============+ | 读 | 写 | 使用 | +=================================+============================+============+ | DAV: | | | | dav://host/path | | cadaver | | :Nread dav://host/path | :Nwrite dav://host/path | cadaver | +---------------------------------+----------------------------+------------+ | DAV + SSL: | | | | davs://host/path | | cadaver | | :Nread davs://host/path | :Nwrite davs://host/path | cadaver | +---------------------------------+----------------------------+------------+ | FETCH: | | | | fetch://[user@]host/path | | | | fetch://[user@]host:http/path | 不可用 | fetch | | :Nread fetch://[user@]host/path| | | +---------------------------------+----------------------------+------------+ | FILE: | | | | file:///* | file:///* | | | file://localhost/* | file://localhost/* | | +---------------------------------+----------------------------+------------+ | FTP: (*3) | (*3) | | | ftp://[user@]host/path | ftp://[user@]host/path | ftp (*2) | | :Nread ftp://host/path | :Nwrite ftp://host/path | ftp+.netrc | | :Nread host path | :Nwrite host path | ftp+.netrc | | :Nread host uid pass path | :Nwrite host uid pass path | ftp | +---------------------------------+----------------------------+------------+ | HTTP: wget is executable: (*4) | | | | http://[user@]host/path | 不可用 | wget | +---------------------------------+----------------------------+------------+ | HTTP: fetch is executable (*4) | | | | http://[user@]host/path | 不可用 | fetch | +---------------------------------+----------------------------+------------+ | RCP: | | | | rcp://[user@]host/path | rcp://[user@]host/path | rcp | +---------------------------------+----------------------------+------------+ | RSYNC: | | | | rsync://[user@]host/path | rsync://[user@]host/path | rsync | | :Nread rsync://host/path | :Nwrite rsync://host/path | rsync | | :Nread rcp://host/path | :Nwrite rcp://host/path | rcp | +---------------------------------+----------------------------+------------+ | SCP: | | | | scp://[user@]host/path | scp://[user@]host/path | scp | | :Nread scp://host/path | :Nwrite scp://host/path | scp (*1) | +---------------------------------+----------------------------+------------+ | SFTP: | | | | sftp://[user@]host/path | sftp://[user@]host/path | sftp | | :Nread sftp://host/path | :Nwrite sftp://host/path | sftp (*1) | +=================================+============================+============+ (*1) 要指出绝对路径,用 scp://machine//path。 (*2) 如果<.netrc>存在,假设你的 ftp 客户端会使用之。不然,该脚本提示 输入用户名和密码。 (*3) 对于 ftp,"machine" 可以是 machine#port 或者 machine:port,如果需 要使用不同于标准 ftp 的端口的话。 (*4) 对于 http:...,如果 wget 可用,就使用之。不然,如果 fetch 可用, 就使用之。 :Nread 和 :Nwrite 这几个 ex 命令都能接受多个文件名。 NETRC *netrw-netrc*<.netrc>文件通常位于你的主目录,它包含的内容是你想用的和机器名对应的用户名和 密码。<.netrc>文件典型的语法如下显示。Unix 上的 ftp 通常支持<.netrc>;而 Windows 上的 ftp 通常不支持。machine{full machine name}login{user-id}password "{password}"default login{user-id}password "{password}"你的 ftp 客户端必须自己会使用<.netrc>,如果<.netrc>文件存在,ftp 传输就不会 询问用户名字和密码。注意: 既然这个文件包含密码明码,要确保没人能够读到这个文件!许多程序拒绝使用 能给别人读取的 .netrc 文件。当然不要忘记,系统管理员总是可以读到这个文 件的!为此,对 Linux/Unix 而言: chmod 600 .netrc 密 码 *netrw-passwd* 脚本试图用内建的 Vim 函数 |inputsecret()| 不回显地读取 ftp 的密码。参见 |netrw-uidpass| 了解如何在设置以后修改密码。 不幸的是,netrw 没有办法自动提供密码给 scp。所以每次通过 scp 传输文件都需要重 新输入密码。不过, |netrw-ssh-hack| 有助于解决这个问题。
5. 激活 *netrw-activate* {{{1
基于网络的文件传输缺省在 |'nocompatible'| 模式打开时就可用。netrw 的脚本文件在 你系统的 plugin、autoload 和 syntax 目录下,而在启动 vim 时,只自动加载 plugin/netrwPlugin.vim。netrw 的主要脚本定义在 autoload/netrw.vim 中,它只有在 实际使用 netrw 时才会载入。我建议你至少在<.vimrc>定制文件里放上:set nocpif version >= 600filetype plugin indent onendif
6. 透明文件编辑 *netrw-transparent* {{{1
透明文件传输指通过普通的文件读写命令进行的传输 (通过 |:autocmd| 的 |BufReadCmd|、|BufWriteCmd| 或 |SourceCmd| 事件)。这样网络文件的读写或执行就能 和本地文件一样容易。vim ftp://[user@]machine/path...:wq|netrw-activate| 进一步说明如何让你的 vim 更好地使用 netrw 这样的插件。
7. Ex 命令 *netrw-ex* {{{1
支持普通的读写命令。此外,还有一些额外的命令。通常你不需要使用 Nwrite 或 Nread,就像 |netrw-transparent| 演示的那样 (也就是,用:e url:r url:w url等即可) -- 见 |netrw-urls|。下面的解释中,{netfile}指代指向远程文件的 URL。 :[range]Nw[rite] 把特定的行写到当前由 b:netrw_lastfile 指定的文件里。 :[range]Nw[rite]{netfile}[{netfile}]... 把特定的行写到{netfile}所指定的网络文件里。 :Nr[ead] 从当前由 b:netrw_lastfile 指定的文件里读取特定的行到当前的缓冲 区。 :Nr[ead]{netfile}{netfile}... 读取{netfile}到当前行之后。 :Ns[ource]{netfile}执行{netfile}。 启动 vim 时如要使用远程的 .vimrc,可以使用如下 (都在同一行上) (多谢 Antoine Mechelynck) 的命令vim -u NORC -N--cmd "runtime plugin/netrwPlugin.vim"--cmd "source scp://HOSTNAME/.vimrc"*netrw-uidpass* :call NetUserPass() 如果 g:netrw_uid 和 s:netrw_passwd 不存在,该函数向用户查询。 :call NetUserPass("userid") 该调用设置 g:netrw_uid 并且,如果密码不存在的话,向用户查询。 :call NetUserPass("userid","passwd") 该调用设置 g:netrw_uid 和 s:netrw_passwd。用户名和密码则被 ftp 传输使用。要删除用户名和密码,只用使用空字符串 (即 "") 便可。 :NetrwSettings |netrw-settings| 里描述此命令 -- 用于显示 netrw 设置和修改 netrw 行为。
8. 变量和选项 *netrw-options* *netrw-var* {{{1
(如果你对 netrw 浏览器设置感兴趣,见: |netrw-browser-var|)<netrw.vim>脚本提供若干变量,作为控制<netrw.vim>行为的选项。这些变量通常在 用户的<.vimrc>里设置: (另见: |netrw-settings| |netrw-protocol|)
netrw 选项
选项 含义-------------- -----------------------------------------------b:netrw_col 保存当前的列号 (NetWrite 时) g:netrw_cygwin =1 假设在 windows 上的 scp 是 cygwin 的版本 (windows 的缺省值) =0 假设在 windows 上的 scp 接受 windows 风格的 路径 (其他情况的缺省值) g:netrw_ftp =0 使用缺省的 ftp (uid password) =1 使用替代的 ftp (user uid password) (见 |netrw-options|) g:netrw_ftpmode ="binary" (缺省) ="ascii" (你的选择) g:netrw_ignorenetrc = 1 (缺省) 如果你有<.netrc>文件,但是你不想用它,就 这么设置。它唯一的作用是使得<.netrc>被忽 略。 b:netrw_lastfile 最近一次通过网络读写的方法/机器/路径。 b:netrw_line 保存当前的行号 (NetWrite 时) g:netrw_passwd 保存当前 ftp 的 password。 g:netrw_silent =0 正常方式的传输 =1 安静方式的传输 g:netrw_uid 保存当前 ftp 的 user-id。 =1 使用替代 ftp 方法 (user uid password) (见 |netrw-options|) g:netrw_use_nt_rcp =0 不要使用 WinNT/2K/XP 的 rcp (缺省) =1 使用 WinNT/2K/XP 二进制模式的 rcp g:netrw_win95ftp =0 使用 unix 风格连接 ftp,即使 win95/98/ME 等 =1 使用缺省的方法连接 ftp
脚本里也可以使用以下的内部变量,尽管应该是暂时的。
临时变量
选项 含义-------------- --------------------------------g:netrw_method 指名 rcp/ftp+.netrc/ftp 等的索引 g:netrw_machine 保存输入分析结果的机器名 g:netrw_fname 保存访问的文件名
*netrw-protocol*
netrw 支持若干协议。调用这些协议时使用下面的列出的变量,用户可以修改。
协议控制选项
选项 类型 设置 意义--------- -------- -------------- ---------------------------netrw_ftp 变量 =不存在 userid 由 "user userid" 设置 =0 userid 由 "user userid" 设置 =1 userid 由 "userid" 设置 NetReadFixup 函数 =不存在 没有改变 =存在 允许用户通过 ftp 自动传输的 文件通过 NetReadFixUp() 进行 转换 g:netrw_dav_cmd 变量 ="cadaver" g:netrw_fetch_cmd 变量 ="fetch -o" 如果 fetch 可以执行 g:netrw_ftp_cmd 变量 ="ftp" g:netrw_http_cmd 变量 ="fetch -o" 如果 fetch 可以执行 g:netrw_http_cmd 变量 ="wget -O" 不然,如果 wget 可以执行 g:netrw_list_cmd 变量 ="ssh USEPORT HOSTNAME ls -Fa" g:netrw_rcp_cmd 变量 ="rcp" g:netrw_rsync_cmd 变量 ="rsync -a" g:netrw_scp_cmd 变量 ="scp -q" g:netrw_sftp_cmd 变量 ="sftp"
*netrw-ftp*
g:netrw_..._cmd 选项 (|g:netrw_ftp_cmd| 和 |g:netrw_sftp_cmd|) 指定如何处理特
定的协议 (rcp、ftp 等) 的外部程序,也可以包含需要的命令行选项 (如指定 passive
模式的 -p)。
|g:netrw_list_cmd| 提供浏览支持: 其中的 HOSTNAME 子串会被替代为当前请求的机器
名。
两个选项 (|g:netrw_ftp| 和 |netrw-fixup|) 都提供解决特定 ftp 问题的帮助。为了
更好的理解如何在 ftp 有问题的时候使用这些选项,以下是 netrw 如何进行 ftp 读取
的一点讨论。
对于 ftp,netrw 通常用以下几种格式之一构造命令行,并写到临时文件里:
如果 g:netrw_ftp 不存在或者不是 1 如果 g:netrw_ftp 存在且为 1
---------------------------------- ------------------------------
open machine [port] open machine [port]
user userid password userid password
[g:netrw_ftpmode] password
[g:netrw_extracmd] [g:netrw_ftpmode]
get filename tempfile [g:netrw_extracmd]
get filename tempfile
|g:netrw_ftpmode| 和 |g:netrw_extracmd| 是可选的。 netrw 然后通过过滤命令执行上述命令行::%!其中 g:netrw_ftp_cmd 通常是 "ftp", -i 告诉 ftp 不要交互 -n 意味着不要用 netrc,它用于方法 #3 (ftp 不用{g:netrw_ftp_cmd}-i [-n]<.netrc>) 如果<.netrc>存在,就不需要想用户查询用户名和密码。传输完毕后,保存文件到临时 文件里。这时,从临时文件里读取的内容被读到被请求的主编辑会话窗口中,并删除临时 文件。 如果你的 ftp 不支持 "user" 命令,而是立即需要输入用户名,那么试试把 "let netrw_ftp=1" 放到你的<.vimrc>里。 *netrw-cadaver* 要解决不受信任的服务器弹出 SSL 认证对话框的问题,你可以下载该认证,并把它放到 /usr/ssl/cert.pem 里。此操作使该服务器被认为是 "可信任的"。 *netrw-fixup* *netreadfixup* 如果你的 ftp 因某种原因产生不需要的行 (例如 AUTH 消息),你需要写一个 NetReadFixup(tmpfile) 函数:function! NetReadFixup(method,line1,line2)" a:line1: 当前文件的第一行新行" a:line2: 当前文件的最后一行新行if a:method == 1 "rcpelseif a:method == 2 "ftp +<.netrc>elseif a:method == 3 "ftp + machine,uid,password,filenameelseif a:method == 4 "scpelseif a:method == 5 "http/wgetelseif a:method == 6 "dav/cadaverelseif a:method == 7 "rsyncelseif a:method == 8 "fetchelseif a:method == 9 "sftpelse " 报错endifendfunction如果 NetReadFixup() 函数存在,它就会被调用,这样你就可以订制自己的读取进程。一 个进一步的例子可以看看<netrw.vim>如何处理 Windows 95 ftp 的函数。不知何种原 因,Windows 95 的 ftp 在传输结束以后加了四个空行,所以应该自动把它们删除。这里 是<netrw.vim>自己的一些代码:if has("win95") && g:netrw_win95ftpfun! NetReadFixup(method, line1, line2)if method == 3 " ftp (无<.netrc>)let fourblanklines= line2 - 3silent fourblanklines.",".line2."g/^\s*/d"endifendfunctionendif
9. 浏览 *netrw-browsing* *netrw-browse* *netrw-help* {{{1
*netrw-browser* *netrw-dir* *netrw-list* 浏 览 简 介 *netrw-intro-browse* {{{2 (快速参考: |netrw-quickmaps| |netrw-quickcoms|) netrw 支持本地系统和远端机器上的目录浏览;浏览包括列出文件和目录、进入目录、编 辑那里的文件、删除文件/目录、建立新目录和移动 (换名) 文件和目录,复制文件和目 录,等等。还可以对文件进行标记,并对标记的文件执行任何系统命令!netrw 浏览器实 现以前探索器里的映射和命令的更一般的版本以支持远程目录,不过具体细节 (比如使用 的全局变量名) 肯定有所不同。要浏览一个目录,简单地 "编辑" 之便可!vim /your/directory/vim .vim c:\your\directory\(相关主题: |netrw-cr| |netrw-o| |netrw-p| |netrw-P| |netrw-t| |netrw-mf| |netrw-mx| |netrw-D| |netrw-R| |netrw-v| ) netrw 远程文件和目录浏览器能处理两个协议: ssh 和 ftp。url 如果使用 ftp 协议, netrw 远程浏览时就同时使用 ftp。相反,如果指定其它协议,该协议将用于文件传输, 而 ssh 协议会被用来进行远程浏览。 要使用 netrw 的远程目录浏览器,只要读入带拖尾斜杠的 "文件" 就可以,它被解释为 列出目录的请求:vim [protocol]://[user@]hostname/path/其中 [protocol] 一般是 scp 或 ftp。例如:vim ftp://ftp.home.vim.org/pub/vim/对于本地目录,拖尾的斜杠是不必要的。不过因为很容易忘记,这里不厌其烦再重复一 遍: 要浏览远程目录,url 必须以斜杠结尾! 如果要避免 ssh 或 scp 在远程目录列表时反复输入密码的麻烦,见 |netrw-ssh-hack|。要避免 ftp 密码的输入,见 |netrw-netrc| (如果你的 ftp 支持的 话)。 改变浏览器显示文件的方式有以下几个途径: * 要改变列表风格,按 "i" 键 (|netrw-i|)。 目前支持四种风格: 瘦、长、宽和树状。 * 要隐藏文件 (不想再显示那些 xyz~ 文件?) 见 |netrw-ctrl-h|。 * 按 s 来对文件按名字、时间或大小排序。 要知道 netrw 可以做的一切事情,见 |netrw-browse-cmds|! 快 速 帮 助 *netrw-quickhelp* {{{2(按 ctrl-] 可选择主题)浏览简介........................................|netrw-intro-browse| 快速参考: 映射................................|netrw-quickmap| 快速参考: 命令................................|netrw-browse-cmds| 隐藏 编辑隐藏列表..................................|netrw-ctrl-h| 隐藏文件或目录................................|netrw-a| 按后缀隐藏或显示..............................|netrw-mh| 隐藏点文件....................................|netrw-gh| 列表风格 选择列表风格 (瘦/长/宽/树状)..................|netrw-i| 相关的设置变量................................|g:netrw_liststyle| 执行列表的外壳命令............................|g:netrw_list_cmd| 快速文件信息..................................|netrw-qf| 如何排序 选择排序风格 (名字/时间/大小).................|netrw-s| 编辑排序序列..................................|netrw-S| 排序选项......................................|g:netrw_sort_options| 相关的设置变量................................|g:netrw_sort_sequence| 反转排序顺序..................................|netrw-r| *netrw-quickmap* *netrw-quickmaps* 快 速 参 考 : 映 射 *netrw-browse-maps* {{{2---- -------- ----映射 简要解释 链接---- -------- ----<F1>netrw 给出帮助<cr>netrw 进入目录或者打开文件 |netrw-cr|<del>netrw 试图删除文件/目录 |netrw-del| - netrw 往上一层目录 |netrw--| a 切换普通显示方式、 |netrw-a| 隐藏方式 (不显示匹配 g:netrw_list_hide 的文件) 和 显示方式 (只显示匹配 g:netrw_list_hide 的文件) c 使浏览中的目录成为当前目录 |netrw-c| d 建立新目录 |netrw-d| D 试图删除文件/目录 |netrw-D| gb 切换到收入书签的目录 |netrw-gb| gh 快速隐藏/显示点文件 |netrw-gh| gi 显示文件信息 |netrw-qf|<c-h>编辑文件隐藏列表 |netrw-ctrl-h| i 在瘦、长、宽和树状列表方式循环 |netrw-i|<c-l>使 netrw 刷新目录列表 |netrw-ctrl-l| mb 把当前目录加入书签 |netrw-mb| mc 把带标记文件复制到标记目标目录中 |netrw-mc| md 对带标记文件进行比较 (不超过 3 个) |netrw-md| me 把带标记文件放到参数列表中并编辑之 |netrw-me| mf 标记文件 |netrw-mf| mh 切换带标记文件的后缀在隐藏列表中的存在与否 |netrw-mh| mm 把带标记文件移动到标记目标目录中 |netrw-mm| mp 打印带标记文件 |netrw-mp| mr 标记满足 |regexp| 的文件 |netrw-mr| mt 使当前浏览目录成为标记文件的目标目录 |netrw-mt| mT 对带标记文件应用 ctags |netrw-mT| mu 撤销所有带标记文件的标记 |netrw-mu| mx 对带标记文件应用任意外壳命令 |netrw-mx| mz 对带标记文件压缩/解压缩 |netrw-mz| o 用水平分割在新浏览窗口中进入光标所在的文件/目录 |netrw-o| O 获取光标指定的文件 |netrw-O| p 预览文件 |netrw-p| P 在前次使用的窗口中浏览 |netrw-P| q 列出书签内的目录和历史 |netrw-qb| r 反转排序顺序 |netrw-r| R 给指定的文件或目录换名 |netrw-R| s 选择排序风格: 按名字、时间或文件大小 |netrw-s| S 指定按名排序时的后缀优先级 |netrw-S| t 在新标签页里进入光标所在的文件/目录 |netrw-t| u 切换到较早访问的目录 |netrw-u| U 切换到较迟访问的目录 |netrw-U| v 用垂直分割在新浏览窗口中进入光标所在的文件/目录 |netrw-v| x 用指定程序阅读文件 |netrw-x| % 在 netrw 当前目录打开新文件 |netrw-%|<leftmouse>(仅限于 gvim) 选择鼠标所在的单词,就像按了<cr>一样 (即编辑文件、改变目录)<middlemouse>(仅限于 gvim) 等价于鼠标所在的单词上按 P;见 |netrw-P|<rightmouse>(仅限于 gvim) 删除鼠标所在的文件/目录<2-leftmouse>(仅限于 gvim) 当: * 在 netrw 选择的文件中,_且_ * |g:netrw_retmap| == 1 _且_ * 用户没有在 netrw 自动载入之前已经定义<2-leftmouse>映射, 那么双击鼠标左键返回到 netrw 浏览器窗口。<s-leftmouse>(仅限于 gvim) 等价于 mf,标记文件 *netrw-quickcom* *netrw-quickcoms* 快 速 参 考 : 命 令 *netrw-explore-cmds* *netrw-browse-cmds* {{{2 :NetrwClean[!] ...........................................|netrw-clean| :NetrwSettings ...........................................|netrw-settings| :Explore[!] [dir] 探索当前文件所在的目录.................|netrw-explore| :Hexplore[!] [dir] 水平分割并探索.........................|netrw-explore| :Nexplore[!] [dir] 垂直分割并探索 (译者注: 应为转到下一个匹配的文件).....|netrw-explore| :Pexplore[!] [dir] 垂直分割并探索 (译者注: 应为转到前一个匹配的文件).....|netrw-explore| :Rexplore 返回浏览器.............................|netrw-explore| :Sexplore[!] [dir] 分割并探索目录.........................|netrw-explore| :Texplore[!] [dir] 建立新标签页并探索.....................|netrw-explore| :Vexplore[!] [dir] 垂直分割并探索.........................|netrw-explore| 把 目 录 加 入 书 签 *netrw-mb* *netrw-bookmark* *netrw-bookmarks* {{{2 用下面的命令可以很方便地把目录加入 "书签"可以使用任何计数。用 viminfo 的 "!" 选项 (|'viminfo'|),可以在不同的 vim 会话 间保存书签。|netrw-gb| 说明如何回到书签里的某个目录,而 |netrw-qb| 说明如何列 出这些目录。 浏 览 *netrw-cr* {{{2 浏览很简单: 移动光标到感兴趣的文件或目录上,按{cnt}mb<cr>(回车键) 就可以选择该文件 或目录。如果还是目录,列出其内容,如果是文件,使用原来读请求中给出的协议来打开 该文件。 警 告: 有四种列表的形式 (见 |netrw-i|)。netrw 假设两个或更多的空格定界长列表 和宽列表格式下的文件和目录名。所以如果你的文件或目录名本身内嵌或拖尾两个或更 多的空格,用 "瘦" 格式来选择文件。 |g:netrw_browse_split| 选项缺省为零。可以修改它,使文件的打开在新窗口或标签页 里进行。如果该选项为一,分割会以水平方式进行,如果为二,分割以垂直方式进行。如 果为三,<cr>使得文件在新标签页里出现。 如果是用图形界面 (gvim),可以按<leftmouse>选择文件。此外,如果 * |g:netrw_retmap| == 1 _且_ (其缺省值为 0) * 在 netrw 选择的文件中,_且_ * 用户没有在 netrw 载入之前已经定义<2-leftmouse>映射 那么双击鼠标左键返回到 netrw 浏览器窗口。 为了试图加快浏览速度,尤其是可能需要输入密码的远程浏览速度,netrw 会保留和重用 上次得到的目录列表缓冲区。|g:netrw_fastbrowse| 变量控制此行为;可以选择慢速浏 览 (没有目录缓冲区列表重用),中速浏览 (只对远程目录重用目录缓冲区列表) 和快速 浏览 (尽可能重用目录缓冲区列表)。重用的代价是如果发生了改动 (例如在目录中出现 了新文件),列表就可能不是最新的。此时,按 ctrl-L 可以刷新目录列表缓冲区 (见 |netrw-ctrl-l|)。 相关主题: |netrw-o| |netrw-p| |netrw-P| |netrw-t| |netrw-v| 相关设置变量: |g:netrw_browse_split| |g:netrw_fastbrowse| |g:netrw_ftp_list_cmd| |g:netrw_ftp_sizelist_cmd| |g:netrw_ftp_timelist_cmd| |g:netrw_ssh_cmd| |g:netrw_ssh_browse_reject| |g:netrw_use_noswf| 水 平 分 割 窗 口 方 式 浏 览 *netrw-o* *netrw-horiz* {{{2 通常用<cr>方式进入文件或目录。不过,"o" 映射可以打开新窗口来浏览新目录列表或 文件。这里使用水平分割。(垂直分割可见 |netrw-v|) 通常,o 键水平分割窗口并使新窗口和光标出现在上方。要改变水平分割使之把新窗口和 光标放到下方,在你的<.vimrc>里放上:let g:netrw_alto = 1(另见 |netrw-t| |netrw-v|) 只能有一个树状列表的缓冲区;因而,在子目录上按 "o" 会分割屏幕,但显示相同的缓 冲区两遍。 相关设置变量: |g:netrw_alto| |g:netrw_winsize| 在 新 标 签 页 里 浏 览 *netrw-t* {{{2 通常你用<cr>进入文件或目录。"t" 映射允许你在新标签页里打开新的目录列表或文 件。(另见: |netrw-o| |netrw-v|) 垂 直 分 割 窗 口 方 式 浏 览 *netrw-v* {{{2 通常用<cr>方式进入文件或目录。不过,"v" 映射可以打开新窗口来浏览新目录列表或 文件。这里使用垂直分割。(水平分割可见 |netrw-o|) 通常,v 键垂直分割窗口并使新窗口和光标出现在左方。要改变垂直分割使之把新窗口和 光标放到右方,在你的<.vimrc>里放上:let g:netrw_altv = 1(另见 |netrw-o| |netrw-t|) 只能有一个树状列表的缓冲区;因而,在子目录上按 "v" 会分割屏幕,但显示相同的缓 冲区两遍。 相关设置变量: |g:netrw_altv| |g:netrw_winsize| 改 变 列 表 方 式 *netrw-i* {{{2 "i" 映射在瘦、长、宽和树形列表格式之间循环。 短 (瘦) 列表格式只给出文件和目录名。 对于远程目录,长格式基于通过 ssh 执行的 "ls" 命令结果,对于本地目录,则显示文 件名、文件大小 (字节计) 和最近修改日期和时间。使用长格式时,netrw 不能识别带拖 尾空格的文件名。这样的文件只能用瘦列表格式。 宽列表格式使用两个或多个连续的空格来给文件名定界;使用此格式时,netrw 不能识别 内嵌或拖尾带有两个或多个连续的空格的文件名。不过,瘦格式可以处理这些文件。该列 表方式最为紧凑。 树形列表格式列出顶层目录,然后是文件和目录,它们的前面有一个 "|"。可以在目录名 上按<cr>来打开或关闭目录。只能有一个树状列表的缓冲区;因而,在子目录上按 "v" 或 "o" 只会打开相同的缓冲区,显示两遍。 相关设置变量: |g:netrw_liststyle| |g:netrw_maxfilenamelen| |g:netrw_timefmt| |g:netrw_list_cmd| 切 换 到 收 入 书 签 的 目 录 *netrw-gb* {{{2 要切换回收入书签的目录,用{cnt}gb可以使用计数来引用任何书签项目。|netrw-mb| 说明如何加入书签,而 |netrw-qb| 说 明如何列出书签。 切 换 到 较 早 访 问 的 目 录 *netrw-u* *netrw-updir* {{{2 每次你切换到新目录时 (当前会话里新出现),netrw 会把该目录保存在最近访问过的目 录历史列表里 (除非 g:netrw_dirhistmax 为零;缺省该值为 10)。用 "u" 映射可以切 换到较早访问的目录 (前任)。相反的操作见 |netrw-U|。 切 换 到 较 迟 访 问 的 目 录 *netrw-U* *netrw-downdir* {{{2 用 "U" 映射可以切换到较迟访问的目录 (后任)。和 "u" 映射相反。(见 |netrw-u|) 用 q 映射可以同时列出书签和历史。(见 |netrw-qb|) NETRW 清 理 *netrw-clean* *:NetrwClean* {{{2 使用 :NetrwClean 可以很容易地从用户主目录中删除 netrw;更准确的说,从 |'runtimepath'| 的第一个目录中删除之。 使用 :NetrwClean! 则会从 |'runtimepath'| 的所有目录中删除。 不管哪种形式,netrw 都会先确认你是否真的要这么做。如果 netrw 没有权限删除某文 件,它会报错。 *netrw-gx* 通 过 用 户 函 数 定 制 浏 览 *netrw-x* *netrw-handler* {{{2 (另见 |netrw_filehandler|) html、gif、jpeg、(word/office) 文档等若干类型的文件最好用特殊处理程序 (也即, 你机器上的特定工具程序) 来察看。netrw 允许你调用这些特殊的处理程序:* 探索时,按 "x" 键* 编辑时,在光标所在的特殊文件名上按 gx(|g:netrw_nogx| 变量存在时不可用) netrw 用下面的方法决定使用哪个特殊处理程序: * 如果存在 |g:netrw_browsex_viewer|,尝试用它来察看文件。包含可用设置的示例 (把它放在<.vimrc>里)::let g:netrw_browsex_viewer= "kfmclient exec"或:let g:netrw_browsex_viewer= "gnome-open"如果 g:netrw_browsex_viewer == '-',那么先调用 netrwFileHandler() (见 |netrw_filehandler|)。 * 对 Windows 32 或 64 来说,使用 url 和 FileProtocolHandler dll。 * 对 Gnome (带 gnome-open) 来说: 使用 gnome-open。 * 对 KDE (带 kfmclient) 来说: 使用 kfmclient。 * 对 Mac OS X 来说: 使用 open。 * 否则,使用 netrwFileHandler 插件。 这些方法使用文件的后缀名来决定 "处理" 这些文件的合适的应用程序。这样就可以处理 OpenOffice (*.sfx)、可视文件 (*.jpg、*.gif 等) 和 PostScript (*.ps、 *.eps)。 *netrw_filehandler* "x" 映射根据文件扩展名来对文件应用一个函数。当然能够调用的前提是该处理函数本身 必须已经存在!例如 mypgm.html x ->NFH_html("scp://user@host/some/path/mypgm.html")用户可以编写他们自己的 netrw 文件处理函数来对更多后缀进行特殊处理。参见<plugin/netrwFileHandlers.vim>的例子来了解如何建立文件处理函数。例如:" NFH_suffix(filename)fun! NFH_suffix(filename)..对文件名进行特殊处理..endfun这些函数需要在你的 .vim/plugin (vimfiles\plugin) 目录下的某个文件里定义。Vim 的函数名不能包含标点符号 (除了下划线以外)。要支持包含这类字符的后缀,netrw 会 先按照下表对后缀进行转换:@ -> AT ! -> EXCLAMATION % -> PERCENT: -> COLON = -> EQUAL ? -> QUESTION, -> COMMA - -> MINUS ; -> SEMICOLON$ -> DOLLAR + -> PLUS ~ -> TILDE因而,对于下例:file.rcs,v -> NFH_rcsCOMMAv()如果你需要更多的转换,请给我发电子邮件:NdrOchip at ScampbellPfamily.AbizM - NOSPAM提出要求。 相关设置变量: |g:netrw_browsex_viewer| 删 除 文 件 或 目 录 *netrw-delete* *netrw-D* *netrw-del* {{{2 如果没有用 |netrw-mf| 标记过文件: (局部标记文件列表) 文件和目录的删除涉及如下操作: 移动光标到要删除的文件/目录,然后按 "D"。目 录必须为空才能成功删除。如果所谓的目录是指向目录的软链接。要成功删除该目 录,netrw 需要发出两个请求。删除前 netrw 会给出确认。用 "V" 命令 (可视选 择) 然后按 "D" 可以选择行范围。 如果用 |netrw-mf| 标记过文件: (局部标记文件列表) 带标记文件 (含空目录) 会被删除;还是一样,在实际操作之前,你会被询问以确认 删除动作。 |g:netrw_rm_cmd|、|g:netrw_rmf_cmd| 和 |g:netrw_rmdir_cmd| 变量用以控制如何删 除文件和目录。g:netrw_rm_cmd 用于文件,缺省值为: g:netrw_rm_cmd: ssh HOSTNAME rm :netrw_rmdir_cmd 变量用于删除目录。缺省值为: g:netrw_rmdir_cmd: ssh HOSTNAME rmdir 如果用 g:netrw_rmdir_cmd 删除目录失败,netrw 会再尝试一次用 g:netrw_rmf_cmd 变 量进行删除。缺省值为: g:netrw_rmf_cmd: ssh HOSTNAME rm -f 相关设置变量: |g:netrw_local_rmdir| |g:netrw_rm_cmd| |g:netrw_rmdir_cmd| |g:netrw_ssh_cmd| *netrw-explore* *netrw-hexplore* *netrw-nexplore* *netrw-pexplore* *netrw-rexplore* *netrw-sexplore* *netrw-texplore* *netrw-vexplore* 目 录 探 索 命 令 {{{2 :Explore[!] [dir]... 探索当前文件所在的目录 *:Explore* :Hexplore[!] [dir]... 水平分割 并探索 *:Hexplore* :Rexplore ... 返回到浏览器 *:Rexplore* :Sexplore[!] [dir]... 分割并探索当前文件所在的目录 *:Sexplore* :Texplore [dir]... 建立新标签页并探索 *:Texplore* :Vexplore[!] [dir]... 垂直分割 并探索 *:Vexplore* 用于 :Explore **/模式 : (另见 |netrw-starstar|) :Nexplore............. 转到下一个匹配的文件 *:Nexplore* :Pexplore............. 转到前一个匹配的文件 *:Pexplore* :Explore 会打开当前文件目录上的本地目录浏览器 (或者如果指定,[dir] 目录)。 只有该文件被修改才会分割窗口,否则浏览窗口使用该窗口。通常使用水平分 割。 :Explore! 类似于 :Explore,但使用垂直分割。 :Sexplore 调用本地目录浏览器前总分割窗口。和 Explore 相同,通常使用水平分割。 :Sexplore! [dir] 类似于 :Sexplore,但使用垂直分割。 :Hexplore [dir] 执行 :Explore,用 |:belowright| 水平分割。 :Hexplore! [dir] 执行 :Explore,用 |:aboveleft| 水平分割。 :Vexplore [dir] 执行 :Explore,用 |:leftabove| 垂直分割。 :Vexplore! [dir] 执行 :Explore,用 |:rightbelow| 垂直分割。 :Texplore [dir] 在生成浏览窗口前先执行 tabnew 缺省这些命令使用当前文件的目录。不过你可以显式提供使用的目录 (路径)。 |g:netrw_winsize| 变量如果被用户指定,也用来设置 Hexplore 和 Vexplore 窗口的大 小。 :Rexplore 此命令和其它的有所不同。当用在 netrw 浏览器窗口的文件上按<cr>等方 式编辑文件时,:Rexplore 会重新显示上次的 netrw 浏览器窗口。它是<2-leftmouse>的命令行版本 (后者只有在 gvim 和有相应支持的终端才存 在)。 *netrw-star* *netrw-starpat* *netrw-starstar* *netrw-starstarpat* 使 用 星 号 和 模 式 进 行 探 索 {{{2 Explore、Sexplore、Hexplore 或 Vexplore 使用以下四种风格的路径时,Explore 生成 满足要求的文件列表。*/filepat 当前目录满足文件模式 filepat 的文件**/filepat 当前目录或之下满足文件模式的文件*//pattern 当前目录内容包含模式 pattern 的文件 (使用 vimgrep)**//pattern 当前目录或之下内容包含模式 pattern 的文件 (使用 vimgrep)光标会被放在列表的第一个文件上。用 |:Nexplore| 可以访问该列表后面的文件,也可 用 |:Pexplore| 访问列表前面的文件。Explore 会更新目录并把光标放在合适的位置。 简单的:Explore会清除探索列表。 如果控制台或 GUI 产生的 shift-up 或 shift-down 序列能够被识别,也许你会发现 shift-下箭头 和 shift-上箭头 更方便。netrw 提供它们的映射:<s-down>== Nexplore,而<s-up>== Pexplore。 考虑下例:Explore */*.c:Nexplore:Nexplore:Pexplore状态行的右侧会显示 "Match 3 of 20" 这样的消息。 相关设置变量: |g:netrw_keepdir| |g:netrw_browse_split| |g:netrw_fastbrowse| |g:netrw_ftp_browse_reject| |g:netrw_ftp_list_cmd| |g:netrw_ftp_sizelist_cmd| |g:netrw_ftp_timelist_cmd| |g:netrw_list_cmd| |g:netrw_liststyle| 显 示 文 件 信 息 *netrw-qf* {{{2 把光标放在文件名上,按 "qf" 会显示文件的大小和最近的修改时间。目前,此功能只适 用于本地文件。 编 辑 文 件 或 目 录 的 隐 藏 列 表 *netrw-ctrl-h* *netrw-edithide* {{{2 "<ctrl-h>" 映射显示请求以允许用户改变 |g:netrw_list_hide| 包含的文件/目录隐藏 列表。隐藏列表包含一个或多个逗号分隔的模式列表。可以隐藏 (也就是不显示) 或只显 示满足这些模式的文件和/或目录 (见 |netrw-a|)。 "gh" 映射 (见 |netrw-gh|) 在普通的隐藏列表和隐藏 "." 开始的文件或目录间快速切 换。 相关设置变量: |g:netrw_hide| |g:netrw_list_hide| 相关主题: |netrw-a| |netrw-gh| |netrw-mh| 编 辑 排 序 序 列 *netrw-S* *netrw-sortsequence* {{{2 如果 "排序风格" 为 name,用此排序序列可决定优先次序 (g:netrw_sort_sequence)。 排序序列里,通常按后缀名安排名字列表的优先级,但其实任何模式都可以用。用逗号定 界模式。缺省的排序序列是 (在一行上):'[\/]$,\.[a-np-z]$,\.h$,\.c$,\.cpp$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$'单独的 * 包含其它模式没有覆盖的所有文件名。用 g:netrw_sort_sequence 变量 (手动 或在<.vimrc>里设置) 可以修改排序序列,"S" 映射也可以完成。 相关主题: |netrw-s| |netrw-S| 相关设置变量: |g:netrw_sort_sequence| |g:netrw_sort_options| 向 上 一 层 *netrw--* {{{2 要到上一层的目录,按 "-" 或在列表的 ../ 目录项上按<cr>。 netrw 用 |g:netrw_list_cmd| 命令执行目录列表操作,其中 HOSTNAME 被用户提供的 url 的宿主名替换。netrw 提供的缺省命令是: ssh HOSTNAME ls -FLa 其中的 HOSTNAME 将根据读取操作的请求设为 [user@]hostname。很自然地,用户可以自 行设置以覆盖此命令。NetList 函数实现远程浏览,它期待拖尾斜杠能标记目录名。 隐 藏 文 件 或 目 录 *netrw-a* *netrw-hiding* {{{2 netrw 的浏览机制提供三种使用隐藏列表的方法: 忽略此列表、隐藏匹配的文件、还有只 显示匹配的文件。 如果没有用 |netrw-mf| 标记过文件: 用户可以用 "a" 映射在这三种方式间切换。 |g:netrw_list_hide| 变量保存逗号分隔的正规表达式列表 (例如 ^.*\.obj$,^\.),以 指定隐藏列表。(另见 |netrw-ctrl-h|) 要设置隐藏列表,可以用<c-h>映射。例如, 要隐藏 "." 开头的文件,可以用<c-h>映射来设置隐藏列表为 '^\..*' (你也可以在<.vimrc>里设置 g:netrw_list_hide= '^\..*')。然后用 "a" 键就可以显示所有文件、 隐藏匹配文件或只显示匹配文件。 示例: \.[ch]$ 这个隐藏列表命令会隐藏/显示所有的 *.c 和 *.h 文件。 示例: \.c$,\.h$ 这个隐藏列表命令也会隐藏/显示所有的 *.c 和 *.h 文件。 不要忘记用 "a" 映射来选择你想要的 (普通/隐藏/显示) 模式! 如果用 |netrw-mf| 标记过文件,那么此命令会: 如果显示所有文件或非隐藏文件: 修改 g:netrw_list_hide 列表,加入带标记文件,并只显示非隐藏文件。 否则,如果只显示隐藏文件: 修改 g:netrw_list_hide 列表,删除带标记文件,并只显示非隐藏文件。 *netrw-gh* *netrw-hide* 有一个快捷键,按gh可以切换是否隐藏句号 (点) 开始的文件。 相关设置变量: |g:netrw_list_hide| 相关主题: |netrw-a| |netrw-ctrl-h| |netrw-mh| 改 进 目 录 浏 览 *netrw-listhack* *netrw-ssh-hack* {{{2 不断要求输入密码很讨厌,远程目录的浏览尤其受这个问题影响。 对 Linux/Unix 系统而言,Rob Flickenger 所著的 "Linux Server Hacks - 100 industrial strength tips & tools" (O'Reilly, ISBN 0-596-00461-3) 一书给出如 何设置无需密码的 ssh 和 scp 的使用方式的提示,也包括相关安全问题的讨论。该书 曾经可从 http://hacks.oreilly.com/pub/h/66 得到,但现在该地址已经被重定向到某 个 "hackzine" 网站。基于该文章和我与 Ben Schmidt 的通信,我试图给一个小结: 1. 在本地机器 (ssh 客户端) 上生成 公钥/私钥 对:ssh-keygen -t rsa(按照提示,把该文件存到 ~/.ssh/id_rsa)2. 如果不要 passphrase,提示 passphrase 时只要按<CR>即可 (两次)。如 果需要 passphrase,你要使用 ssh-agent,从而每个会话期间只需输入一次 passphrase。如果不用 passphrase,只要简单地登录到你的本地机器上或者 用任何方式得到密钥文件就足够可以访问任何使用该密钥提供授权登录的 ssh 服务器。 3. 这会建立两个文件:~/.ssh/id_rsa~/.ssh/id_rsa.pub4. 在目标机器 (ssh 服务器) 上:cdmkdir -p .sshchmod 0700 .ssh5. 在你的本地机器 (ssh 客户端) 上: (在一行上输入)ssh{serverhostname}cat '>>' '~/.ssh/authorized_keys2' < ~/.ssh/id_rsa.pub或者,对于 OpenSSH 而言,(在一行上输入)ssh{serverhostname}cat '>>' '~/.ssh/authorized_keys' < ~/.ssh/id_rsa.pub你可以这样测试ssh你应该可以登录到服务器机器而无须任何进一步的输入。 如果你决定使用 passphrase:{serverhostname}ssh-agent $SHELLssh-addsshssh-add 时,你会被提示输入密钥 passphrase,但之后 ssh 就无须再输入了。要用于 vim,你可以用{serverhostname}ssh-agent vim然后在 vim 中,用:!ssh-add另一个方案是在要执行 vim 的终端上应用 ssh-agent:ssh-agent xterm &然后需要的时候执行 ssh-add。 vim 邮件列表上也有人提到 Windows 上的 Pageant 有助于避免不断要求输入密码的麻 烦。 Kingston Fung 写下另一个避免不断要求输入密码的方法: 要避免每次使用 scp 都输入密码的需要,你在文档里给出了一个设置无密码 ssh 帐 号的技巧。我有个更好的方法: 我可以使用普通有密码的 ssh 帐号来访问内容,而 无须每次都输入密码。既安全又方便。我试了 ssh 公钥验证和 ssh-agent,这么做 就可以用了!这里是具体操作的链接: http://www.ibm.com/developerworks/library/l-keyc2/ http://sial.org/howto/openssh/publickey-auth/ 列 出 书 签 和 历 史 *netrw-qb* *netrw-listbookmark* {{{2 按 "qb" (query bookmarks,查询书签) 会列出书签里记录的目录和目录遍历的历史。 (见 |netrw-mb|、 |netrw-gb|、|netrw-u| 和 |netrw-U|) 建 立 新 目 录 *netrw-d* {{{2 用 "d" 映射可以在远端 (取决于全局变量 g:netrw_mkdir_cmd) 或本地 (取决于全局变 量 g:netrw_local_mkdir) 建立目录。netrw 会要求新目录的名字。这时单输入<CR>可 以中止目录建立过程。试图建立已经存在的本地目录 (可以是文件或目录) 会被检测到并 进行报告,然后忽略。 目前,不支持用 ftp 建立目录。 相关设置变量: |g:netrw_local_mkdir| |g:netrw_mkdir_cmd| 使 浏 览 目 录 成 为 当 前 目 录 *netrw-c* *netrw-curdir* {{{2 |g:netrw_keepdir| 缺省为 1。该设置意味着当前目录不会跟踪浏览目录。 设置 g:netrw_keepdir 为 0 告诉 netrw 使 vim 的当前目录跟踪 netrw 的浏览目录。 不过,保持缺省为 1 的 g:netrw_keepdir 设置意味着 netrw 维护它自己的当前目录的 概念。要想使两个目录相同,可用 "c" 映射 (只要按 c 就可以)。该映射会把 Vim 概念 的当前目录设为当前的浏览目录。 相关设置变量: |g:netrw_keepdir| 标 记 文 件 *netrw-mf* {{{2 (另见 |netrw-mr|) 把光标移到文件名上按 "mf" 就可以标记文件。gvim 中,更可以用<s-leftmouse>来标 记文件。下面的 netrw 映射使用带标记文件: |netrw-a| 隐藏标记文件/目录 |netrw-D| 删除标记文件/目录 |netrw-mc| 复制标记文件到目标 |netrw-md| 给标记文件应用 vimdiff |netrw-me| 编辑标记文件 |netrw-mg| 在标记文件上应用 vimgrep |netrw-mm| 移动标记文件 |netrw-mp| 打印标记文件 |netrw-mt| 为 |netrw-mm| 和 |netrw-mc| 设定目标 |netrw-mT| 用标记文件生成标签 |netrw-mx| 在标记文件上应用外壳命令 |netrw-mz| 压缩/解压标记文件 |netrw-O| 获取标记文件 |netrw-R| 为标记文件换名 用标记文件相同的方式可以撤销文件的标记,也就是,把光标移到带标记的文件上按 "mf"。这也适用于 gvim 的<s-leftmouse>。按 "mu" 可以一次撤销所有标记 (见 |netrw-mu|)。 *markfilelist* *global_markfilelist* *local_markfilelist* 所有的标记文件都进入全局标记文件列表;只有唯一的这样的列表。此外,每个 netrw 缓冲区都有自己局部的标记文件列表;因为 netrw 缓冲区和特定的目录相关联,这意味 着每个目录都有自己的局部标记文件列表。操作标记文件的命令分别使用两个标记文件列 表中的一个。 用 正 规 表 达 式 标 记 文 件 *netrw-mr* {{{2 (另见 |netrw-mf|) 也可以用 "mr" 来标记文件;netrw 会给出提示,"Enter regexp: "。此时,你可以输入 一个正规表达式,比如 \.c$。当前目录下的所有 (译者注: 应为所有 .c 文件) 都被标 记。注意正规表达式采用 vim 风格的 |regexp|,而不是外壳风格的。所以输入 *.c 可 能得不到你要的结果! 带 标 记 文 件 : 任 意 命 令 *netrw-mx* {{{2 (关于如何标记文件,见 |netrw-mf| and |netrw-mr|) (使用局部标记文件列表) 激活 "mx" 映射后,netrw 会询问用户应用于所有带标记文件的 (外部) 命令。命令中所 有的 "%" 被带标记文件的每个名字依次替代。如果命令中没有 “%”,那么命令后附加一 个空格和一个带标记文件名。 带 标 记 文 件 : 压 缩 与 解 压 缩 *netrw-mz* {{{2 (关于如何标记文件,见 |netrw-mf| and |netrw-mr|) (使用局部标记文件列表) 对任何压缩过的带标记文件,"mz" 会对它们解压。 对任何被解压的带标记文件,"mz" 会用 |g:netrw_compress| 指定的命令对它们进行压 缩。缺省,使用 "gzip"。 对于解压,netrw 提供一个后缀到相应解压工具的 |Dictionary|;见 |g:netrw_decompress|。 相关设置变量: |g:netrw_compress| |g:netrw_decompress| 带 标 记 文 件 : 复 制 *netrw-mc* {{{2 (关于如何标记文件,见 |netrw-mf| and |netrw-mr|) (使用全局标记文件列表) 用 mt 选择目标目录 (|netrw-mt|)。然后改变目录,选择文件 (见 |netrw-mf|),然后 按 "mc"。 相关设置变量: |g:netrw_localcopycmd| |g:netrw_ssh_cmd| 带 标 记 文 件 : 比 较 *netrw-md* {{{2 (关于如何标记文件,见 |netrw-mf| and |netrw-mr|) (使用全局标记文件列表) 用 |vimdiff| 来显示选择文件的差异 (为此,可以选择两到三个文件)。 带 标 记 文 件 : 编 辑 *netrw-me* {{{2 (关于如何标记文件,见 |netrw-mf| and |netrw-mr|) (使用全局标记文件列表) 此命令把带标记文件放在 |arglist| 上,然后开始编辑它们。用 |:Rexplore| 可以回到 浏览器窗口。 带 标 记 文 件: GREP *netrw-mg* {{{2 (关于如何标记文件,见 |netrw-mf| and |netrw-mr|) (使用全局标记文件列表) 此命令在带标记文件上应用 |:vimgrep|。该命令会询问需要的模式;你可以输入:/pattern/[g][j]! /pattern/[g][j]pattern带 标 记 文 件 : 按 后 缀 隐 藏 或 显 示 *netrw-mh* {{{2 (关于如何标记文件,见 |netrw-mf| and |netrw-mr|) (使用局部标记文件列表) 此命令提取带标记文件的后缀,然后在隐藏列表中切换它们的存在与否。请注意据此, 带有相同后缀的文件多次出现会使得每个文件都切换一次此后缀的存在与否 (所以偶数个 相同后缀的带标记文件和不选任何文件的作用是一样的)。 相关主题: |netrw-a| |g:netrw_list_hide| 带 标 记 文 件 : 移 动 *netrw-mm* {{{2 (关于如何标记文件,见 |netrw-mf| and |netrw-mr|) (使用全局标记文件列表) 警 告: 移动文件比复制文件要危险。被移动的文件先被复制然后被删除;如果 复制操作失败但删除操作成功,该文件就丢失了。你要么用不太重要的文件先试 试,要么用 mc 和 D 先进行复制然后再删除。请自行负责! 用 mt 选择目标目录 (|netrw-mt|)。然后改变目录,选择文件 (见 |netrw-mf|),然后 按 "mm"。 相关设置变量: |g:netrw_localmovecmd| |g:netrw_ssh_cmd| 带 标 记 文 件 : 打 印 *netrw-mp* {{{2 (关于如何标记文件,见 |netrw-mf| and |netrw-mr|) (使用局部标记文件列表) netrw 会对带标记文件应用 |:hardcopy| 命令。具体地,它在一个单行的窗口上打开每 个文件,执行 hardcopy,然后关闭这个单行窗口。 带 标 记 文 件 : 执 行 *netrw-ms* {{{2 (关于如何标记文件,见 |netrw-mf| and |netrw-mr|) (使用局部标记文件列表) netrw 会执行带标记文件 (使用 vim 的 |:source| 命令) 带 标 记 文 件 : 建 立 标 签 *netrw-mT* {{{2 (关于如何标记文件,见 |netrw-mf| and |netrw-mr|) (使用全局标记文件列表) "mt" 映射为带标记文件应用 |g:netrw_ctags| 定义的命令 (缺省是 "ctags")。对于远 程浏览,为了建立一个标签文件,netrw 会使用 ssh (见 |g:netrw_ssh_cmd|),所以要 能在远程系统使用此命令,ssh 必须存在。对于本地系统,见 |ctags| 说明如何得到可 用的版本。我自己用 hdrtags,目前可从 http://mysite.verizon.net/astronaut/src/index.html 获得,并在我的<.vimrc>中 有let g:netrw_ctags= "hdrtag"如果为一组远程的文件建立了标签,产生的 tags 文件被 "获取";也即,一个备份被传 输到本地系统的目录。然后这个本地的 tags 文件被修改,使得它可以在网上使用。具体 地,tags 里的文件名被修改,每个路径前面加上了用于获取的 netrw 兼容的 url。如果 用户随后用某个转到标签的动作 (|tags|),netrw 就可以用该 url 来编辑想要的文件, 并转到对应的标签上。 相关设置变量: |g:netrw_ctags| |g:netrw_ssh_cmd| 带 标 记 文 件 : 设 置 目 标 目 录 *netrw-mt* {{{2 (关于如何标记文件,见 |netrw-mf| and |netrw-mr|) 设置带标记文件复制/移动的目标 (见 |netrw-mc| 和 |netrw-mm|): * 如果光标在文件名上,使用 netrw 窗口当前显示的目录作为复制/移动目标。 * 同样,如果光标在窗口头部,使用 netrw 窗口当前显示的目录作为复制/移动目标。 * 但如果光标在一个目录名上,使用该目录作为复制/移动目标。 每个 vim 会话只有一个复制/移动目标;也就是说,该目标是一个脚本变量 (见 |s:var|),并且由所有 (同一 vim 实例中的) netrw 窗口共享。 带 标 记 文 件 : 撤 销 标 记 *netrw-mu* {{{2 (关于如何标记文件,见 |netrw-mf| and |netrw-mr|) "mu" 映射撤销当前所有带标记文件的标记。 NETRW 浏 览 器 变 量 *netrw-browser-options* *netrw-browser-var* {{{2 (如果你对 netrw 文件传输设置感兴趣,见 |netrw-options|)<netrw.vim>浏览器提供你可以修改的以变量形式出现的设置。把这些设置放在<.vimrc>里,你就可以定制浏览的偏好。(另见: |netrw-settings|)---- ----变量 解释---- ----*g:netrw_alto* 置位此变量后,分割后的新窗口出现在下方而不是上 方 (见 |netrw-o|) 缺省: =&sb (见 |'sb'|) *g:netrw_altv* 置位此变量后,分割后的新窗口出现在右方而不是左 方 (见 |netrw-v|) 缺省: =&spr (见 |'spr'|) *g:netrw_browse_split* 浏览时,<cr>这样打开文件: =0: 重用同一个窗口 =1: 先水平分割窗口 =2: 先垂直分割窗口 =3: 在新标签页中打开文件 =4: 等同于 "P" (即打开前次窗口) *g:netrw_browsex_viewer* 指定查阅器的用户偏好:"kfmclient exec""gnome-open"如果使用了"-"那么 netrwFileHandler() 将寻找处理该扩展名的脚 本/函数 (见 |netrw_filehandler|)。 *g:netrw_compress* ="gzip" 用此命令压缩带标记文件 *g:netrw_ctags* ="ctags" 建立标签使用的缺省外部程序 *g:netrw_decompress* = { ".gz" : "gunzip" , ".bz2" : "bunzip2" , ".zip" : "unzip" , ".tar" : "tar -xf"} 映射后缀到解压程序的字典。 *g:netrw_fastbrowse* =0: 慢速浏览; 不会重用目录列表, 总是重新获取目录列表。 =1: 中速浏览; 只有远程浏览才重用目录列表。 (缺省值) =2: 快速目录浏览; 只获取没有浏览过的目录列表 (或在用 |netrw-ctrl-l| 时)。 快速浏览意味着保留旧目录列表的缓冲区,这样就不 需要重新获取了。该特性对远程浏览特别有意义。不 过,如果加入或者删除文件,旧的目录列表就不再是 最新的。此时可用 |netrw-ctrl-l| 刷新目录列表。 本选项提供用户机会来选择准确性 (即最新的列表) 和速度的权衡。 *g:netrw_fname_escape* =' ?&;%' 远程读取/写入前用于文件名。 *g:netrw_ftp_browse_reject* ftp 可能会生成一些错误和警告信息,它们会作为 "目录" 和 "文件" 出现在列表里。使用本模式来删 除这些内嵌的消息。缺省值为: '^total\s\+\d\+$\| ^Trying\s\+\d\+.*$\| ^KERBEROS_V\d rejected\| ^Security extensions not\| No such file\| : connect to address [0-9a-fA-F:]* : No route to host$' *g:netrw_ftp_list_cmd* 传递给 ftp 用于列出目录的选项。缺省为: unix 或置位 g:netrw_cygwin 时: "ls -lF" 否则 "dir" *g:netrw_ftp_sizelist_cmd* 传递给 ftp 用于列出目录并按文件大小排序的选 项。 缺省: unix 或置位 g:netrw_cygwin 时: "ls -slF" 否则 "dir" *g:netrw_ftp_timelist_cmd* 传递给 ftp 用于列出目录并按文件最后修改时间排 序的选项。 缺省: unix 或置位 g:netrw_cygwin 时: "ls -tlF" 否则 "dir" *g:netrw_glob_escape* ='[]*?`{~$' 应用 glob() 前,目录名中的这些字符被转义 *g:netrw_hide* 如果为真,使用隐藏列表 缺省: =0 *g:netrw_keepdir* =1 (缺省) 浏览目录时不影响当前目录。 =0 浏览目录时设置当前目录为该目录。 当前的浏览目录保存在 b:netrw_curdir 里 (另见 |netrw-c|) *g:netrw_list_cmd* 列出远程目录的命令 缺省: (如果 ssh 可执行) "ssh USEPORT HOSTNAME ls -FLa" *g:netrw_liststyle* 设置缺省的列表风格: = 0: 瘦列表 (每个文件一行) = 1: 长列表 (每个文件一行,带有时间信息和文件 长度) = 2: 宽列表 (多个文件,分列显示) = 3: 树型风格列表 *g:netrw_list_hide* 逗号分隔的隐藏文件的模式列表 模式是正规表达式 (见 |regexp|) 示例: let g:netrw_list_hide= '.*\.swp$' 缺省: "" *g:netrw_localcopycmd* ="cp" Linux/Unix/MacOS/Cygwin ="copy" Windows 把带标记文件 (|netrw-mf|) 复制到目标目录 (|netrw-mt|、|netrw-mc|) *g:netrw_localmovecmd* ="mv" Linux/Unix/MacOS/Cygwin ="move" Windows 把带标记文件 (|netrw-mf|) 移动到目标目录 (|netrw-mt|、|netrw-mm|) *g:netrw_local_mkdir* 建立本地目录的命令 缺省: "mkdir" *g:netrw_local_rmdir* 删除目录的命令 (rmdir) 缺省: "rmdir" *g:netrw_maxfilenamelen* =32 缺省之所以选为该值,使为了使长列表能在 80 列内显示。如果你的屏幕更宽或者文件或目录名可能 长于 32 个字节,可以设置此选项使列表按列排列 *g:netrw_mkdir_cmd* 建立远程目录的命令 缺省: "ssh USEPORT HOSTNAME mkdir" *g:netrw_retmap* 如果存在且为一,那么<2-leftmouse>会被映射以 方便地回到 netrw 浏览器窗口。 (示例: 点击一次,选择并打开文件,双击返回) 缺省: =0 *g:netrw_rm_cmd* 删除文件的命令 缺省: "ssh USEPORT HOSTNAME rm" *g:netrw_rmdir_cmd* 删除目录的命令 缺省: "ssh USEPORT HOSTNAME rmdir" *g:netrw_rmf_cmd* 删除软链接的命令 缺省: "ssh USEPORT HOSTNAME rm -f" *g:netrw_sort_by* 按 "name" (名字)、"time" (时间) 或 "size" (大 小) 排序 缺省: "name" *g:netrw_sort_direction* 排序方向: "normal" (普通) 或 "reverse" (反转) 缺省: "normal" *g:netrw_sort_options* 排序是通过 |:sort| 命令进行的;此变量的值会附 加到排序命令之后。例如,在 .vimrc 里加上以下内 容就可以忽略大小写:let g:netrw_sort_options="i"缺省: "" *g:netrw_sort_sequence* 按名字排序时,先按逗号分隔的此模式序列排序 缺省: '[\/]$,*,\.bak$,\.o$,\.h$, \.info$,\.swp$,\.obj$' *g:netrw_special_syntax* 如果为真,特定文件会以特殊语法出现在浏览器中: netrwBak : *.bak netrwCompress: *.gz *.bz2 *.Z *.zip netrwData : *.dat netrwHdr : *.h netrwLib : *.a *.so *.lib *.dll netrwMakefile: [mM]akefile *.mak netrwObj : *.o *.obj netrwTags : tags ANmenu ANtagsnetrwTilde : *netrwTmp : tmp* *tmp 这些语法高亮组缺省被链接到 Folded 或 DiffChange (见 |hl-Folded| 和 |hl-DiffChange|),但你可以在<.vimrc>放上这样 的行hi link netrwCompress Visual来定义自己的偏好。 *g:netrw_ssh_cmd* 可以用此值代替 ssh,用于执行列表,删除文件等这 些远程动作的可执行命令。 缺省: ssh *g:netrw_ssh_browse_reject* ssh 有时产生你不想要的行、消息、标题和任何你不 希望看作是 "目录" 和 "文件" 的内容。 此模式可用于删除这些内嵌的信息。缺省值为: '^total\s\+\d\+$' *g:netrw_tmpfile_escape* =' &;' 对所有的临时文件使用 escape() 来转义这些字符。 *g:netrw_timefmt* 指定代替 %c 的 strftime() 的格式字符串 缺省值 "%c",根据我的 strftime() 项目的 man 页 面,是 "建议使用的本地 locale 日期时间的表现方 式";不过,不是所有人都满意。一些选择: "%a %d %b %Y %T"、 " %a %Y-%m-%d %I-%M-%S %p" 缺省: "%c" *g:netrw_use_noswf* netrw 通常避免给浏览器缓冲区写入交换文件。不 过,在有些系统上,看来这么做引起讨厌的 ml_get 错误;如果你看到 ml_get 错误,尝试在 .vimrc 中 放入 let g:netrw_use_noswf= 0 *g:netrw_winsize* 指定 "o" (见 |netrw-o|)、"v" (见 |netrw-v|)、 |:Hexplore| 或 |:Vexplore| 建立的新窗口的初始 大小。 缺省: "" *g:netrw_xstrlen* 控制 netrw 如何计算包含多字节字符的字符串的长 度 (来自 N Weibull、T Mechelynck) =0: 使用 Vim 的内建 strlen() =1: 代码点的个数 (Latin + 组合用 circumflex 是 两个代码点) (DEFAULT) =2: 占空间的代码点个数 (Latin + 组合用 circumflex 是一个占空间的代码点;硬制表符 是一个;宽和窄的 CJK 都是一个;等等) =3: 虚拟长度 (制表符在 1 到 |'tabstop'| 之间, 宽 CJK 是 2 而不是 1,阿拉伯 alif 在 lam 之前是零,否则为 1,等等) *g:NetrwTopLvlMenu* 指定顶层子菜单名;缺省为 "Netrw."。 如果你想改变,在 .vimrc 里进行。 NETRW 浏 览 和 选 项 不 兼 容 性 *netrw-incompatible* {{{2 netrw 的设计中,对用户选项的处理是先保存它们,设置和 netrw 需要兼容的选项值, 然后恢复原有的值。但 autochdir 选项::set acd是有问题的。autochdir 设置当前目录为编辑文件所在的目录;这显然也适用于目录。换 而言之,autochdir 设置当前目录为包含该 "文件" 的目录 (即使该 "文件" 本身也是目 录)。 NETRW 设 置 *netrw-settings* {{{2 使用 NetrwSettings.vim 插件,:NetrwSettings会弹出一个窗口来显示用作 netrw 设置的许多变量。你可以修改这里列出的所有值;保 存文件时,设置的值就会被应用。在任何行上按 "?" 就可以得到每个变量功能的帮助。 (另见: |netrw-browser-var| |netrw-protocol| |netrw-var| |netrw-variables|) 获 取 文 件 *netrw-O* {{{2 如果没有带标记文件: 浏览远程目录时,用户可用 O 键获取光标所在的文件 (即在本地机器上保存备份, 但不编辑)。 如果有带标记文件: 获取带标记文件 (即传输一个备份到本地机器,但不用来编辑)。 此操作只支持 ftp 和 scp (既然只有它们能用作浏览,这应该不是问题)。这时 状态行的右侧会显示 "Obtaining filename" 这样的消息。传输完成后,状态行复原。 netrw 也可以用本地浏览器 "获得" 文件。netrw 显示的目录不一定和 Vim 的 "当前目 录" 一致,除非用户的<.vimrc>里把 |g:netrw_keepdir| 设为 0。在本地浏览器里选 择文件 (光标移动到该文件名上) 然后按 "O" 就可以 "获得" 该文件;也就是把它复制 到 Vim 的当前目录。 相关主题: * 察看当前目录可用 |:pwd| * 使得当前浏览目录成为当前目录可见 |netrw-c| * 要自动使得当前浏览目录总成为当前目录可见 |g:netrw_keepdir|。 在 NETRW 当 前 目 录 打 开 新 文 件 *netrw-%* 要在 netrw 当前目录打开一个新文件,按 "%"。此映射询问用户新的文件名;然后在 netrw 当前目录 (即 b:netrw_curdir) 就会建立以此命名的的空文件。 预 览 窗 口 *netrw-p* *netrw-preview* {{{2 用 "p" 键可以使用预览窗口来预览光标所在的文件名。屏幕会被分割以同时显示浏览器 (光标还在那里) 和文件 (见 |:pedit|)。缺省,进行水平分割;如果先设置好 |g:netrw_preview| 就可以进行垂直分割。 前 次 窗 口 *netrw-P* *netrw-prvwin* {{{2 要使用上次使用 (最近访问) 的窗口编辑文件或目录 (见 :he |CTRL-W_P|),按 "P"。如 果只有一个窗口,该窗口被水平分割 (上/下分割由 |g:netrw_alto| 控制,初始大小由 |g:netrw_winsize| 控制)。 如果多于一个窗口,重用上次使用的窗口以显示选择的文件/目录。如果前次窗口相关联 的缓冲区被修改而且该缓冲区只有这个窗口,用户会被询问是否要先保存该缓冲区 (yes (是)、no (否) 或 cancel (取消))。 刷 新 列 表 *netrw-ctrl-l* *netrw-ctrl_l* {{{2 要刷新本地或远程目录列表,按 ctrl-l (<c-l>) 或在列表的 ./ 目录项上按<cr>。用 ":e ." 也可以刷新本地目录。 给 文 件 或 目 录 换 名 *netrw-move* *netrw-rename* *netrw-R* {{{2 如果没有用 |netrw-mf| 标记过文件: 换名/移动文件和目录涉及以下操作: 移动光标到要移动 (换名) 的文件/目录,然后 按 "R"。你会被询问要把文件/目录移动到那里。用 "V" 命令 (可视选择) 然后按 "R" 可以选择行范围。 如果用 |netrw-mf| 标记过文件: 带标记文件会被移动 (换名);和上面一样,你会被询问文件/目录要移动到的位置。警 告:注意移动文件是一个危险的操作;复制更安全。因为远程文件的 "移动" 实际上是 复制 + 删除 -- 如果复制失败但删除成功,该文件就会丢失。 g:netrw_rename_cmd 变量实现换名。缺省值为: ssh HOSTNAME mv 用 V (|linewise-visual|) 可以给若干文件和目录同时换名。 反 转 排 序 顺 序 *netrw-r* *netrw-reverse* {{{2 用 "r" 键可以在正常和反转两种排序顺序之间切换。 相关主题: |netrw-s| 相关设置变量: |g:netrw_sort_direction| 选 择 排 序 风 格 *netrw-s* *netrw-sort* {{{2 可以选择排序风格,使之按 name (名字)、time (时间) 或 size (文件大小) 排序。 "s" 映射允许你在这三个选择之间循环;目录列表会自动更新以反映选择的风格。 相关主题: |netrw-r| |netrw-S| 相关设置变量: |g:netrw_sort_by| |g:netrw_sort_sequence|
10. 问题和修正 *netrw-problems* {{{1
(本节可能会不断增长,视乎我得到的反馈而定) (另见 |netrw-debug|) *netrw-p1* P1. 我用 windows 95,我的 ftp 每次读取之后多了额外的四个空行。 见 |netrw-fixup|,在<.vimrc>文件里加入下行: let g:netrw_win95ftp= 1 *netrw-p2* P2. 我用 windows,用 ftp 进行网络浏览不能按时间或大小排序 -或- 远程系 统是 Windows 服务器;为什么我不能按时间或大小排序? Windows 的 ftp 只有基本的 ls 的支持 (即,不支持排序的选项)。它 也不支持 -F 以给出类型字符 (ABC/ 代表 "ABC 是目录")。 netrw 使用 dir 得到的短长两种列表。如果你认为自己的 ftp 支持完 整功能的 ls,在<.vimrc>加入下行:let g:netrw_ftp_list_cmd= "ls -lF"let g:netrw_ftp_timelist_cmd= "ls -tlF"let g:netrw_ftp_sizelist_cmd= "ls -slF"还有一个办法,如果你在 Windows 上安装了 cygwin,在<.vimrc>加 入下行:let g:netrw_cygwin= 1如果远端系统使用 Windows,这个问题也会出现。在此情形下, g:netrw_ftp_[time|size]list_cmds 诸命令如上所示,但远端系统不 会因而正确地修改它的列表方式。 *netrw-p3* P3. 我尝试 rcp://user@host/ (或任何不是 ftp 的协议) 但 netrw 使用 ssh!我不要这样... netrw 有两个方法进行远程目录浏览: ssh 和 ftp。除非你指定 ftp, 使用的只能是 ssh。 如果你需要下载文件 (不是目录列表),netrw 会使用你要求的任何协 议。 *netrw-p4* P4. 我喜欢缺省使用长格式的列表。 在 |.vimrc| 里放入:let g:netrw_liststyle=1|netrw-browser-var| 说明你可以改变的更多设置。 *netrw-p5* P5. 本地浏览时,时间显示不正常 你系统的 strftime() 是否接受 "%c" 以产生类似于下面的格式: "Sun Apr 27 11:49:23 1997"?如果不是,执行 "man strftime" 寻找 什么选项可以完成类似的功能。然后在 |.vimrc| 里放入:let g:netrw_timefmt= "%X" (其中 X 是找到的选项)*netrw-p6* P6. 我想让当前目录和我的浏览同步。如何进行? 在 |.vimrc| 里放入:let g:netrw_keepdir= 0*netrw-p7* P7. 我在文件名中使用中文 (或其它非 ascii) 字符,netrw (Explore、 Sexplore、Hexplore 等) 却不能显示这些文件名! (取自 Wu Yongwei 在 Vim 邮件列表上的回答) 我现在明白你的问题了。你的代码页不是 936,对么?Vim 看来只能打 开在当前代码页中合法的文件名,这和许多其它不使用 Unicode 版本 的 Windows API 的应用程序一样。这是操作系统上的问题。如果系统 locale 使用 UTF-8 就不应该有这个问题,例如现代的 Linux 的各种 发布就是如此。 (...又多一个理由鼓励大家使用 utf-8!) *netrw-p8* P8. 我看到错误 "你的系统无法执行 ssh" -- 我该怎么办? (Dudley Fox) 我知道的多数人在 windows 上 用 putty 的 ssh。这是 一个免费的 ssh/telnet 应用。更多的情况可见: http://www.chiark.greenend.org.uk/~sgtatham/putty/ 还有: (Marlin Unruh) 我也用这个程序。它是一个单独的可执行文件,所以 可以复制到 Windows\System32 文件夹并建立一个快捷方式。 (Dudley Fox) 你也可以考虑 plink,听起来它和你要找的很接近。 plink 是 putty 程序包中的一个应用。 http://the.earth.li/~sgtatham/putty/0.58/htmldoc/Chapter7.html#plink (Vissale Neang) 你可以试试 OpenSSH 的 windows 版本,可以在这里 得到: http://sshwindows.sourceforge.net/ 它并不需要 Cygwin 包。 (Antoine Mechelynck) 对于单独需要在直接的 Windows 环境工作的 Unix 风格的程序,我推荐从 sourceforge 的 GnuWin32 项目获取,如 果有的话: http://gnuwin32.sourceforge.net/ 和 Cygwin 不同,后者建立一个在 Windows 之上的 Unix 风格的模拟 机,而 GnuWin32 使用 Windows 系统调用来重写 Unix 工具,它的程序 也能在 cmd.exe "Dos 窗口" 中正常运行。 (dave) 下载 WinSCP并用它连到服务器上。Preferences > Editors 选 项里设置 gvim 为你的编辑器: - 点击 "Add..." - 设置外部编辑器 (如果需要,调整实际的路径并加上引号和 最后的 !.!): "c:\Program Files\Vim\vim70\gvim.exe" !.! - 确认下面框中的文件类型为{asterisk}.{asterisk}(即所 有文件),或任何你期望的类型 (cec: 把{asterisk}换成 * ;我这么写是因为不然的话,helptags 系统认为它是一 个标签) - 确认它在列表框的顶端 (如若不然,点击它再点击 ”Up") 如果使用 Norton Commander 风格,你只要按<F4>来使用本地的 gvim 来编辑文件。 (Vit Gottwald) 如何生成公钥/私钥并把公钥存在服务器上:http://www.tartarus.org/~simon/puttydoc/Chapter8.html#pubkey-gettingready8.3 Getting ready for public key authentication'pscp' 如何使用私钥:http://www.tartarus.org/~simon/puttydoc/Chapter5.html5.2.4 Using public key authentication with PSCP(Ben Schmidt) 我发现 cwRsync 所带的 ssh 太好了,现在我在自己用 的大多数 Windows 系统上都安装了 cwRsync 或 cwRsyncServer。对只 需要在 Windows 上 ssh 的人来说,我推测同一作者提供的 COPSSH 可 能更好,而且它还带有 cwRsync 没有的 sftp 等等工具。虽然它可能 ... (译者注: 下文缺) (cec) 要正确地使用的以上的建议,你需要在 .vimrc 中修改以下用户 可设的变量: |g:netrw_ssh_cmd| |g:netrw_list_cmd| |g:netrw_mkdir_cmd| |g:netrw_rm_cmd| |g:netrw_rmdir_cmd| |g:netrw_rmf_cmd| 第一个 (|g:netrw_ssh_cmd|) 是最重要的;多数其它的变量在缺省情 况下使用和 g:netrw_ssh_cmd 相同的值。 *netrw-p9* *netrw-ml_get* P9. 我在浏览,切换目录,哦!出现了 ml_get 错误,我不得不杀掉 vim。有什 么解决方法? netrw 通常避免给临时目录缓冲区写入交换文件。不过,在有些系统 上,看来这么做引起 ml_get 错误;尝试在<.vimrc>中设置 |g:netrw_use_noswf| 为零:let g:netrw_use_noswf= 0*netrw-p10* P10. "[something] is a directory" 和 "Press ENTER or type command to continue" 这些提示烦死我了... "[something] is a directory" 提示是 Vim 发出的,不是 netrw,看 来没有办法绕过它。再加上缺省的 cmdHeight 为 1,此消息导致了 "Press ENTER..." 提示。所以: 阅读 |hit-enter|; 我也建议你在<.vimrc>文件里设置 |'cmdheight'| 为 2 (或更高)。 *netrw-p11* P11. 我想要有两个窗口;一个瘦的在左边,我的编辑窗口在右边。应该怎么 做? * 在<.vimrc>放入: let g:netrw_altv = 1 * 编辑当前目录: :e . * 选择某个文件,按 v * 按照自己需要调整窗口大小 (见 |CTRL-W_<| 和 |CTRL-W_>|)。如果 使用 gvim,可用鼠标拖动分割栏。 * 想编辑新文件时,用 ctrl-w h 回到 netrw 浏览器,选择文件,然 后按 P (见 |CTRL-W_h| 和 |netrw-P|)。如果使用 gvim,在浏览器 窗口按<leftmouse>然后用<middlemouse>来选择文件。
11. 调试 netrw 自身 *netrw-debug* {{{1
通常可以这样得到<netrw.vim>脚本:/usr/local/share/vim/vim6x/plugin/netrw.vim/usr/local/share/vim/vim6x/autoload/netrw.vim-或-/usr/local/share/vim/vim7x/plugin/netrw.vim/usr/local/share/vim/vim7x/autoload/netrw.vim在启动时自动被加载 (假设 :set nocp)。 1. 先从这里取得<Decho.vim>脚本: http://mysite.verizon.net/astronaut/vim/index.html#DECHO 或者 http://vim.sourceforge.net/scripts/script.php?script_id=120 现在它以 "vimball" 形式出现;如果你使用 vim 7.0 或更早版本,请同时更 新 vimball。见 http://mysite.verizon.net/astronaut/vim/index.html#VIMBALL 2. 修改<netrw.vim>文件如下:vim netrw.vim:DechoOn:wq要恢复到正常的非调试行为,修改<netrw.vim>如下:vim netrw.vim:DechoOff:wq此命令由<Decho.vim>提供,它会注释掉所有 Decho 调试语句 (Dfunc()、 Dret()、Decho()、Dredir())。 3. 然后启动 vim 进行文件传输或者进行浏览以重现错误。一系列消息应该在一 个单独的标签页出现,提示<netrw.vim>进行网络文件读写的一系列步骤。 要保存文件,用:wincmd j:set bt=:w! DBG请把该信息发送到<netrw.vim>的维护者。NdrOchip at ScampbellPfamily.AbizM - NOSPAM
12. 历史 (英文) *netrw-history* {{{1
v132: Aug 06, 2008 * Fixed marked file-based obtain Aug 08, 2008 * sourcing a file via ftp from a netrw-generated buffer (or any buffer with |'nobl'|) left an empty no-name buffer in its wake. Fixed. v130: Jul 31, 2008 * trying out elinks/links for http://host/ requests. One problem: in-page links (such as with ...#LABEL) are not supported * verified that Bram's modified netrwPlugin works Aug 01, 2008 * fixed a bug: when sourcing a file via ftp, the "filter window" was left behind. v129: Jul 31, 2008 * bug found in non-mouse enabled vim and some local maps v128: Jul 30, 2008 * much work done in using shellescape() and fnameescape() v126: Jun 30, 2008 * after having gone to a remote directory,<f1>was no longer taking one to the correct entry in the help (|netrw-quickhelp|). Fixed. Jul 01, 2008 * extracting the last filename from a wide listing missed the last letter when |'virtualedit'| not enabled. Jul 01, 2008 * vim foo/bar was creating [Scratch] buffers, where bar was also a directory Jul 01, 2008 * numerous additional changes were made to netrw to use fnameescape() and shellescape() instead of escape(). Not all changes have been tested as yet... Jul 01, 2008 * (James Vega reported) some problems with :NetrwSettings (due to no longer used setting variables). Jul 07, 2008 * Additional numerous changes to support security; shellescape(arg,1), etc. v125: Apr 07, 2008 * (Cristian Rigamonti) CR provides a patch; he noted that gx was failing since its call to netrw#NetBrowseX() wasn't updated to netrw#NetrwBrowseX(). * (Stanis Trendelenburg) ST provides a patch to supports davs: (dav + ssl) * (Rick Choi) noted that directory names comprised of three digits were not being displayed by the internal browser. Fixed. * (Erik Falor) provided a patch to handle problems with changing directory and |'acd'| option. * (James Vega, Teemu Likonen) noted that netrw wasn't handling multi-byte filenames/directories correctly. Fixed. * (Rick) found problem with g:netrw_maxfilenamelen being overridden. * (James Vega) pointed out that netrw was misidentifying all files in a symbolically linked directory as being symbolically linked themselves. This particular problem was fixed; however, there are now situations where symbolically linked files will not be detected. Really need an internal vim function to do this identification. Apr 17, 2008 * When g:netrw_keepdir==0, current directory doesn't necessarily equal b:netrw_curdir initially. Problem is due to the patch directly above. * Fixed qf to handle case where b:netrw_curdir isn't the same as the current directory under linux/macosx. * New: |netrw-mg| (apply vimgrep to marked files) May 05, 2008 * (Rick) pointed out that a "setlocal ts=32" was interfering with g:netrw_maxfilenamelen May 05, 2008 * (James Vega) a file inside a linked directory was showing up as a symbolic link itself. May 22, 2008 * symbolic links, fifos, and sockets are now indicated by a trailing @, |, or =, respectively. Jun 06, 2008 * Removed numerous bugs from the marked file move and copy. Tested these changes under Unix only thus far. * :Rexplore returns to the screen position in the netrw listing from whence the file was edited v124: Apr 02, 2008 * (Adrian Rollett) change the line supporting the "x" action for mac to use g:netrw_shq v123: Feb 27, 2008 * Marked files now keeps a "global" marked file list. The global marked file list is used to support tag processing and vimdiff'ing (|netrw-md| |netrw-mt|) * Been insuring that mm and mc works with various combinations of local and remote directories * (Stefan Bittner) http://.../ should always have filetype "html" -- fixed. * (Stefan Bittner) a "?" in a http://.../ request wasn't being handled correctly. Fixed by removing ? from default |g:netrw_tmpfile_escape|. * (Nico Weber) % codes in http://.../ requests weren't being handled correctly. Fixed by including % in default |g:netrw_fname_escape|. * (Stefan Bittner) attempts to update Buffers.Refresh were failing because locale use changed the menu names. I implemented a workaround. v122: Feb 12, 2008 * bugfix - first sorting sequence match now has priority Feb 14, 2008 * bugfix - sorting sequence was effectively ignoring sequencing priority of anything following '*' * toggling a marked file was showing incorrect list (list was correct, but displayed matches weren't) * |g:netrw_special_syntax| implemented v121: Feb 11, 2008 * Bram M reported that :e file ... :e . would not retain the alternate file. Fixed -- I hope! * bugfix -- apparently v120 broke an explicit :Explore dirname v120: Jan 21, 2008 * |netrw-mt| changed to allow for target selection based on whether or not word under cursor is a directory or file, or if cursor is in banner area. * |netrw-mh| included (hiding by marked-file suffix) * functions moved about a bit (improved categorization) * executable files now displayed with trailing (*) * symbolically linked files now displayed with trailing (@) * Somewhen, s:NetrwMarkFileMove() got damaged. Its now restored (missing an endif, for example). * |netrw-mu| implemented (unmarking marked files) * many bugs have been removed from the marked file system (tnx to Mark S. for feedback) * |netrw-ms| implemented (sourcing marked files) * fixed use of P with tree listing style * multiple tree listing now supported * ./ suppressed * changed q -> qb (query bookmarks) * implemented |netrw-qf| * Explore now has four special list-generation modes: */filepat **/filepat *//pattern **//pattern * gh (|netrw-gh|) is a shortcut for toggling the hiding of files and directories beginning with a dot v119: Jan 10, 2008 * When g:netrw_keepdir is false, NetrwOptionsRestore() had a problem (Bill McCarthy) Jan 11, 2008 * Netrw now shows symbolic links with a trailing "@" and special highlighting. Jan 15, 2008 * Changed g:netrw_noretmap -> |g:netrw_retmap|. Changed: disabled by default at Bram's preference. v118: Jan 02, 2008 * Fixed a problem with Windows; :Explore c:/path/ would not work, but :Explore c:/path would. * Fixed a bug in s:NetrwOptionRestore() - lcd's argument wasn't being properly escaped so it wouldn't handle spaces in directory names. (Gary Johnson) v117: Jan 02, 2008 * Fixed a problem with P; had to include a b:netrw_curdir bypass (Bram Moolenaar) v116: Nov 27, 2007 * netrw#LocalBrowseCheck() has &ft=="netrw" check to prevent doing a directory listing (was getting unexpected directory refreshes in the middle of some function calls) * NetrwOptionRestore moved after e! filename in order to retain user options for editing in s:NetrwBrowseChgDir() Dec 12, 2007 * Bug fix -- netrw does a better job of retaining user options when editing files under the aegis of the browser v115: Oct 04, 2007 * Erik Remmelzwaal pointed out that the use of shellslash in s:GetTempfile() was incorrect Oct 11, 2007 * Tracked down and eliminated a bug with editing remote *.tar.gz and *.tar.bz2 files Oct 11, 2007 * g:netrw_localmovecmd wasn't being initialized properly, and g:netrw_localcopycmd was being overwritten. Oct 12, 2007 * Placed all :Rexplore and<2-leftmouse>setup in a new support function (s:SetRexDir()). Oct 15, 2007 * new: g:netrw_browse_split == 4; means<cr>based selection will use previous window Oct 20, 2007 * also checks on |'shellxquote'| to set g:netrw_shq Oct 24, 2007 * Explore handles path/**/filename Oct 27, 2007 * sourcing remote files often didn't work with ftp, turns out that b:netrw_method was undefined, so s:SaveBufVars and s:RestoreBufVars() fixed it. v114: Sep 28, 2007 * mT, the map that invokes tags, has been improved to support use of remote tags files. Oct 02, 2007 * changed Netrw menu to use more submenus v113: Sep 07, 2007 * worked out why the cursor position wasn't being saved and restored as intended after doing such things as deleting and renaming files. Sep 11, 2007 * Fixed bug which effectively disabled<c-l>and<c-h>maps Sep 18, 2007 * there used to be one NetrwOptionRestore() call at the end of the s:NetrwBrowseChgDir() function; they're now at the end of every if..elseif..else block. The edit-a-file one is not quite at the end of its block; instead, its just before the edit. Restores user options, then this new placement allows ftplugins, autocmds, etc to change settings (ex. ftplugin/cpp.vim sets cindent). Sep 19, 2007 * changed all strlen() calls to use s:Strlen(), a function which handles utf-8 wide characters correctly. Sep 20, 2007 * (Nico Weber) the "x" command has been extended to Mac's OS/X (macunix); it now uses open to handle |netrw-x| browsing with special files. Sep 22, 2007 * Added g:netrw_noretmap to netrw at Tony M's request. * Included path to NetrwRemoteRmFile() v112: Aug 18, 2007 * added mx (|netrw-mx|) for executing arbitrary commands on marked files Aug 22, 2007 * more option save/restore work for s:NetrwBrowseChgDir(); s:NetrwOptionSave() and s:NetrwOptionRestore() now take a parameter specifying the type of variables to be used for saving and restoring (either "w:" or "s:") Sep 04, 2007 * added the :NetrwClean[!] command v111: Jul 25, 2007 * using Windows but not using Cygwin, netrw does a "file bufname" where the bufname uses /s instead of \s; Vim "fixes" it by changing the bufname to use \s anyway. This meant that NetrwGetBuffer() didn't find the appropriately named buffer, and so would generate a new buffer listing; hence the cursor would appear to have been moved when doing a preview. * added<2-leftmouse>map to return to netrw's browser display Aug 16, 2007 * added the mark-file system, including maps for mf mp mt mz and mu. Modifications made to maps for a D O and R to support marked files. v110: May 10, 2007 * added [ and ] maps to NetrwTreeListing May 25, 2007 * |g:netrw_preview| included May 29, 2007 * modifed netrw#NetBrowseX to consistently use g:netrw_shq instead of hardcoded quotes, and modified the snippet that sets up redir so Windows machines use "nul" instead of "/dev/null". Jun 01, 2007 * fixed bug -- NetGetBuffer() wasn't always recognizing a buffer name match when it should, thus resulting in [Scratch] buffers. Jun 04, 2007 * Gary Johnson found a bugfix for the "c" mapping when the directory is to be made current but the name contains spaces. v109: Mar 26, 2007 * if a directory name includes a "$" character, Explore() will use expand() in an attempt to decipher the name. May 07, 2007 * g:netrw_use_errorwindow now allows one to have error messages go to a reliable window or to use a less reliable but recallable echoerr method May 07, 2007 * g:netrw_scpport and g:netrw_sshport support use of -P and -p, respectively, to set port for scp/ssh. v108: Jan 03, 2007 * included preview map (|netrw-p|), supporting remote browsing * netrw can now source remote files Jan 26, 2007 * Colton Jamieson noted that remote directory browsing did not support alternate port selection. This feature has now been extended to apply to all remote browsing commands via ssh. (list, remove/delete, rename) Jan 31, 2007 * Luis Florit reported that @* was an invalid register. The @* register is now only saved and restored if |'guioptions'| contains "a". Feb 02, 2007 * Fixed a bug that cropped up when writing files via scp using cygwin Feb 08, 2007 * tree listing mode managed to stop working again; fixed again! Feb 15, 2007 * Guido Van Hoecke reported that netrw didn't handle browsing well with M$ ftp servers. He even set up a temporary account for me to test with (thanks!). Netrw now can browse M$ ftp servers. v107: Oct 12, 2006 * bypassed the autowrite option Oct 24, 2006 * handles automatic decompression of *.gz and *.bz2 files Nov 03, 2006 * Explore will highlight matching files when **/pattern is used (and if the |'hls'| option is set) Nov 09, 2006 * a debugging line, when enabled, was inadvertently bringing up help instead of simply reporting on list contents Nov 21, 2006 * tree listing improved (cursor remains put) Nov 27, 2006 * fixed b:netrw_curdir bug when repeated "i"s were pressed. Dec 15, 2006 * considerable qty of changes, mostly to share more code between local and remote browsing. Includes support for tree-style listing for both remote and local browsing. Dec 15, 2006 * Included Peter Bengtsson's modifications to support the Amiga. v106: Sep 21, 2006 * removed old v:version<700 code as netrw now requires vim 7.0 * worked around a bug where register * was overwritten during local browsing v104: Sep 05, 2006 * as suggested by Rodolfo Borges, :Explore and variants will position the cursor on the file just having been edited * changed default |g:netrw_sort_sequence| order * changed b, Nb to simply mb (see |netrw-mb|) * changed B, NB to simply gb (see |netrw-gb|) * tree listing style (see |g:netrw_liststyle|) * attempts to retain the alternate file v103: Jul 26, 2006 * used Yakov Lerner's tip#1289 to improve netrw error message display * wide listings didn't handle files with backslashes in their names properly. A symptom was an inability to open files. Aug 09, 2006 * included "t" mapping for opening tabbed windows, both for remote and local browsing * changed netrw_longlist to netrw_liststyle Aug 15, 2006 * fixed one of the NB maps Aug 22, 2006 * changed *Explore commands to use -nargs=* instead of -nargs=?. Allows both -complete=dir _and_ the starstar arguments to work (-nargs=? seems to require one or the other). Aug 23, 2006 * copied all w:.. variables across splits to new windows Aug 25, 2006 * when g:netrw_browsex_viewer was '-' (see |g:netrw_browsex_viewer|) it wasn't causing netrwFileHandlers#Invoke() to be called as it was expected to. (tnx Steve Dugaro) Aug 29, 2006 * changed NetBrowseX() to use "setlocal ... noswf" instead of "set ... noswf" (tnx Benji Fisher) Aug 31, 2006 * tabs and fastbrowse<=1 didn't work together. v102: Jun 15, 2006 * chgd netrwPlugin to call netrw#LocalBrowseCheck() * bugfix: g:netrw_keepdir==0 had stopped working Jul 06, 2006 * bugfix: NetOptionSave/Restore now saves/restores the unnamed register (|registers|) Jul 07, 2006 * |g:netrw_menu| support included Jul 13, 2006 * :Texplore command implemented Jul 17, 2006 * NetSplit and (Local|Net)BrowseChgDir() were both splitting windows. This affected o, v, and g:netrw_browse_split. Jul 20, 2006 * works around wildignore setting (was causing netrw's local browser not to list wildignore'd files) Jul 24, 2006 *<leftmouse>acts as a<cr>for selecting a file<rightmouse>acts as a<del>for deleting a file v100: May 14, 2006 * when using Windows and shell==cmd.exe, the default for g:netrw_ignorenetrc is now 1 * bugfix: unwanted ^Ms now removed (affected shell==cmd.exe - Windows) * added Bookmarks and History to the menu * an error message about non-existing w:netrw_longlist was appearing during attempts to Explore (fixed) * g:netrw_shq now available to make netrw use specified style of quotes for commands May 29, 2006 * user NFH_*() functions were inadvertently being ignored * fixed a Windows non-cygwin ftp handling problem. * hiding pattern candidate separators included some characters it shouldn't have (tnx to Osei Poku) Jun 01, 2006 * for browsing, netrw was supposed to use "dir" instead of "ls -lF" when using ftp+non-cygwin+windows. Fixed. * an inadvertently left-in-place debugging statement was preventing use of the "x" key with browsing. Jun 05, 2006 * g:netrw_nogx available to prevent making the gx map (see |g:netrw_nogx|) * bugfix, Explore wouldn't change directory properly (vim ., :Explore subdirname) Jun 06, 2006 * moved history to 2nd line in Netrw menu * fixed delete for unix-based systems Jun 07, 2006 * x key now works for windows-noncygwin-ftp Jun 08, 2006 * Explore */pat and **//pat now wraps v99: May 09, 2006 * g:netrw_browse_split=3 for opening files in new tabs implemented. May 12, 2006 * deletes temporary file at end of NetRead() * visual mode based Obtain implemented * added -complete=dir to the various Explore commands v98: May 02, 2006 * the "p" key didn't work properly when the browsing directory name had spaces in it. v97: May 01, 2006 * exists("&acd") now used to determine if the 'acd' option exists * "obtain" now works again under Windows v96: * bugfix - the |'acd'| option is not always defined but is now bypassed only when it is v95: * bugfix - Hiding mode worked correctly (don't show any file matching any of the g:netrw_hide patterns), but showing mode was showing only those files that didn't match any of the g:netrw_hide patterns. Instead, it now shows all files that match any of the g:netrw_hide patterns (the difference between a logical and and logical or). v94: * bugfix - a Decho() had a missing quote; only affects things when debugging was enabled. v93: * bugfix - removed FocusGained event from causing a slow-browser refresh for Windows v92: * :Explore **//pattern implemented (**/filepattern was already taken) v91: * :Explore */pattern implemented * |'acd'| option bypassed v90: * mark ', as suggested by Yegappan Lakshmanan, used to help guarantee entry into the jump list when appropriate. *<s-down>and<s-up>are no longer defined until a :Explore **/pattern is used (if the user already has a map for them). They will be defined for new browser windows from that point forward. v89: * A<s-down>,<s-up>, :Nexplore, or a :Pexplore without having first done an :Explore **/pattern (see |netrw-starstar|) caused a lot of unhelpful error messages to appear v88: * moved DrChip.Netrw menu to Netrw. Now has priority 80 by default. g:NetrwTopLvlMenu == "Netrw" and can be changed by the user to suit. The priority is given by g:NetrwMenuPriority. * Changed filetype for browser displays from netrwlist to netrw. v87: * bug fix -- menus were partially disappearing v85: * bug fix -- missing an endif * bug fix -- handles spaces in names and directories when using ftp-based browsing v83: * disabled stop-acd handling; the change in directory handling may allow acd to be used again. * D was refusing to delete remote files/directories in wide listing mode. v81: * FocusGained also used to refresh/wipe local browser directory buffers * (bugfix) netrw was leaving [Scratch] buffers behind when the user had the "hidden" option set. The 'hidden' option is now bypassed. v80: * ShellCmdPost event used in conjunction with g:netrw_fastbrowse to refresh/wipe local browser directory buffers. v79: * directories are now displayed with nowrap * (bugfix) if the column width was smaller than the largest file's name, then netrw would hang when using wide-listing mode - fixed * g:netrw_fastbrowse introduced v78: * progress has been made on allowing spaces inside directory names for remote work (reading, writing, browsing). (scp) v77: * Mikolaj Machowski fixed a bug in a substitute cmd * g:netrw_browsex_viewer implemented * Mikolaj Machowski pointed out that gnome-open is often executable under KDE systems, although it is effectively not functional. NetBrowseX now looks for "kicker" as a running process to determine if KDE is actually running. * Explorer's O functionality was inadvertently left out. Netrw now does the same thing, but with the "P" key. * added g:netrw_browse_split option * fixed a bug where the directory contained a "." but the file didn't (was treating the dirname from "." onwards as a suffix) v76: * "directory is missing" error message now restores echo highlighting v75: * file://... now conforms to RFC2396 (thanks to S. Zacchiroli) * if the binary option is set, then NetWrite() will only write the whole file (line numbers don't make sense with this). Supports writing of tar and zip files. v74: * bugfix (vim, then :Explore) now works * ctrl-L keeps cursor at same screen location (both local and remote browsing) * netrw now can read remote zip and tar files * Obtain now uses WinXP ftp+.netrc successfully v73: * bugfix -- scp://host/path/file was getting named incorrectly * netrw detects use of earlier-than-7.0 version of vim and issues a pertinent error message. * netrwSettings.vim is now uses autoloading. Only<netrwPlugin.vim>is needed as a pure plugin (ie. always loaded). v72: * bugfix -- formerly, one could prevent the loading of netrw by "let g:loaded_netrw=1"; when autoloading became supported, this feature was lost. It is now restored. v71: * bugfix -- made some "set nomodifiable"s into setlocal variants (allows :e somenewfile to be modifiable as usual) * NetrwSettings calls a netrw function, thereby assuring that netrw has loaded. However, if netrw does not load for whatever reason, then NetrwSettings will now issue a warning message. * For what reason I don't recall, when wget and fetch are both not present, and an attempt to read a http://... url is made, netrw exited. It now only returns. * When ch=1, on the second and subsequent uses of browsing Netrw would issue a blank line to clear the echo'd messages. This caused an annoying "Hit-Enter" prompt; now a blank line message is echo'd only if &ch>1. v70: * when using |netrw-O|, the "Obtaining filename" message is now shown using |hl-User9|. If User9 has not been defined, netrw itself will define it. v69: * Bugfix: win95/98 machines were experiencing a "E121: Undefined variable: g:netrw_win95ftp" message v68: * double-click-leftmouse selects word under mouse v67: * Passwords which contain blanks will now be surrounded by double-quotes automatically (Yongwei) v66: * Netrw now seems to work with a few more Windows situations * O now obtains a file: remote browsing file -> local copy, locally browsing file -> current directory (see :pwd) * i now cycles between thin, long, and wide listing styles * NB and Nb are maps that are always available; corresponding B and b maps are only available when not using wide listing in order to allow them to be used for motions v65: * Browser functions now use NetOptionSave/Restore; in particular, netrw now works around the report setting v64: * Bugfix - browsing a "/" directory (Unix) yielded buffers named "[Scratch]" instead of "/" * Bugfix - remote browsing with ftp was omitting the ./ and ../ v63: * netrw now takes advantage of autoload (needs 7.0) * Bugfix - using r (to reverse sort) working again v62: * Bugfix - spaces allowed again in directory names with g:netrw_keepdir=0. In fact, I've tested netrw with most ANSI punctuation marks for directory names. * Bugfix - NetrwSettings gave errors when g:netrw_silent had not be set. v61: * Document upgrade -- netrw variable-based settings all should have tags. Supports NetrwSettings cmd. * Several important variables are window-oriented. Netrw has to transfer these across a window split. See s:BufWinVars() and s:UseBufWinVars(). v60: * When using the i map to switch between long and short listings, netrw will now keep cursor on same line * "Match # of #" now uses status line * :Explore **/*.c will now work from a non-netrw-browser window * :Explore **/patterns can now be run in separate browser windows * active banner (hit<cr>will cause various things to happen) v59: * bugfix -- another keepalt work-around installed (for vim6.3) * "Match # of #" for Explore **/pattern matches v58: * Explore and relatives can now handle **/somefilepattern (v7) * Nexplore and Pexplore introduced (v7). shift-down and shift-up cursor keys will invoke Nexplore and Pexplore, respectively. * bug fixed with o and v * autochdir only worked around for vim when it has been compiled with either |+netbeans_intg| or |+sun_workshop| * Under Windows, all directories and files were being preceded with a "/" when local browsing. Fixed. * When: syntax highlighting is off, laststatus=2, and remote browsing is used, sometimes the laststatus highlighting bleeds into the entire display. Work around - do an extra redraw in that case. * Bugfix: when g:netrw_keepdir=0, due to re-use of buffers, netrw didn't change the directory when it should've * Bugfix: D and R commands work again v57: * Explore and relatives can now handle RO files * reverse sort restored with vim7's sort command * g:netrw_keepdir now being used to keep the current directory unchanged as intended (sense change) * vim 6.3 still supported v56: * LocalBrowse now saves autochdir setting, unsets it, and restores it before returning. * using vim's rename() instead of system + local_rename variable * avoids changing directory when g:netrw_keepdir is false v55: * -bar used with :Explore :Sexplore etc to allow multiple commands to be separated by |s * browser listings now use the "nowrap" option * browser: some unuseful error messages now suppressed v54: * For backwards compatibility, Explore and Sexplore have been implemented. In addition, Hexplore and Vexplore commands are available, too. *<amatch>used instead of<afile>in the transparency support (BufReadCmd, FileReadCmd, FileWriteCmd) * ***netrw*** prepended to various error messages netrw may emit * g:netrw_port used instead of b:netrw_port for scp * any leading [:#] is removed from port numbers v53: * backslashes as well as slashes placed in various patterns (ex. g:netrw_sort_sequence) to better support Windows v52: * nonumber'ing now set for browsing buffers * when the hiding list hid all files, error messages ensued. Fixed * when browsing, swf is set, but directory is not set, when netrw was attempting to restore options, vim wanted to save a swapfile to a local directory using an url-style path. Fixed v51: * cygwin detection now automated (using windows and &shell is bash) * customizable browser "file" rejection patterns * directory history * :[range]w url now supported (ie. netrw uses a FileWriteCmd event) * error messages have a "Press<cr>to continue" to allow them to be seen * directory browser displays no longer bother the swapfile * u/U commands to go up and down the history stack * history stack may be saved with viminfo with it's "!" option * bugfixes associated with unwanted [No Files] entries v50: * directories now displayed using buftype=nofile; should keep the directory names as-is * attempts to remove empty "[No File]" buffers leftover from :file ..name.. commands * bugfix: a "caps-lock" editing difficulty left in v49 was fixed * syntax highlighting for "Showing:" the hiding list included * bookmarks can now be retained if "!" is in the viminfo option v49: * will use ftp for http://.../ browsing v48: * One may use ftp to do remote host file browsing * (windows and !cygwin) remote browsing with ftp can now use the "dir" command internally to provide listings * g:netrw_keepdir now allows one to keep the initial current directory as the current directory (normally the local file browser makes the currently viewed directory the current directory) * g:netrw_alto and g:netrw_altv now support alternate placement of windows started with o or v * Nread ? and Nwrite ? now uses echomsg (instead of echo) so :messages can repeat showing the help * bugfix: avoids problems with partial matches of directory names to prior buffers with longer names * one can suppress error messages with g:netrw_quiet ctrl-h used * instead of<Leader>h for editing hiding list one may edit the sorting sequence with the S map, which now allows confirmation of deletion with [y(es) n(o) a(ll) q(uit)] * the "x" map now handles special file viewing with: (windows) rundll32 url.dll (gnome) gnome-open (kde) kfmclient If none of these are on the executable path, then netrwFileHandlers.vim is used. * directory bookmarking during both local and remote browsing implemented * one may view all, use the hiding list to suppress, or use the hiding list to show-only remote and local file/directory listings * improved unusual file and directory name handling preview window support v47: * now handles local browsing. v46: * now handles remote browsing * g:netrw_silent (if 1) will cause all transfers to be silent v45: * made the [user@]hostname:path form a bit more restrictive to better handle errors in using protocols (e.g. scp:usr@host:file was being recognized as an rcp request) v44: * changed from "rsync -a" to just "rsync" * somehow an editing error messed up the test to recognize use of the fetch method for NetRead. * more debugging statements included v43: * moved "Explanation" comments to<pi_netrw.txt>help file as "Network Reference" (|netrw-ref|) *<netrw.vim>now uses Dfunc() Decho() and Dret() for debugging * removed superfluous NetRestorePosn() calls v42: * now does BufReadPre and BufReadPost events on file:///* and file://localhost/* v41: * installed file:///* and file://localhost/* handling v40: * prevents redraw when a protocol error occurs so that the user may see it v39: * sftp support v38: * Now uses NetRestorePosn() calls with Nread/Nwrite commands * Temporary files now removed via bwipe! instead of bwipe (thanks to Dave Roberts) v37: * Claar's modifications which test if ftp is successful, otherwise give an error message * After a read, the alternate file was pointing to the temp file. The temp file buffer is now wiped out. * removed silent from transfer methods so user can see what's happening
13. 鸣谢 *netrw-credits* {{{1
Vim editor by Bram Moolenaar (谢了,Bram!) dav 提供支持: C Campbell fetch 提供支持: Bram Moolenaar 和 C Campbell ftp 提供支持: C Campbell<NdrOchip@ScampbellPfamily.AbizM>http 提供支持: Bram Moolenaar<bram@moolenaar.net>rcp rsync 提供支持: C Campbell (Erik Warendorph 提供建议) scp 提供支持: raf<raf@comdyn.com.au>sftp 提供支持: C Campbell inputsecret()、BufReadCmd、BufWriteCmd 由 C Campbell 提供 Jérôme Augé -- 也使用新的缓冲区方法操作 ftp+.netrc Bram Moolenaar -- 显然写了 vim 本身,还有 :e 和 v:cmdarg 的使 用, fetch 等 Yasuhiro Matsumoto -- 指出 undo+0r 的问题和解决方法 Erik Warendorph -- 提供若干建议 (g:netrw_..._cmd 变量,rsync 等) Doug Claar -- 提供能成功通过 ftp 操作的测试的修改
模式行: {{{1
vim:tw=78:ts=8:ft=help:norl:fdm=marker
Generated by vim2html on Sat Nov 15 18:15:11 UTC 2008