Pi Netrw
Pi Netrw
------------------------------------------------
NETRW REFERENCE MANUAL by Charles E. Campbell
------------------------------------------------
Author: Charles E. Campbell <[email protected]>
(remove NOSPAM from Campbell's email first)
*netrw*
*dav* *ftp* *netrw-file* *rcp* *scp*
*davs* *http* *netrw.vim* *rsync* *sftp*
*fetch* *network*
==============================================================================
1. Contents *netrw-contents* {{{1
1. Contents..............................................|netrw-contents|
2. Starting With Netrw...................................|netrw-start|
3. Netrw Reference.......................................|netrw-ref|
EXTERNAL APPLICATIONS AND PROTOCOLS.................|netrw-externapp|
READING.............................................|netrw-read|
WRITING.............................................|netrw-write|
SOURCING............................................|netrw-source|
DIRECTORY LISTING...................................|netrw-dirlist|
CHANGING THE USERID AND PASSWORD....................|netrw-chgup|
VARIABLES AND SETTINGS..............................|netrw-variables|
PATHS...............................................|netrw-path|
4. Network-Oriented File Transfer........................|netrw-xfer|
NETRC...............................................|netrw-netrc|
PASSWORD............................................|netrw-passwd|
5. Activation............................................|netrw-activate|
6. Transparent Remote File Editing.......................|netrw-transparent|
7. Ex Commands...........................................|netrw-ex|
8. Variables and Options.................................|netrw-variables|
9. Browsing..............................................|netrw-browse|
Introduction To Browsing............................|netrw-intro-browse|
Quick Reference: Maps...............................|netrw-browse-maps|
Quick Reference: Commands...........................|netrw-browse-cmds|
Banner Display......................................|netrw-I|
Bookmarking A Directory.............................|netrw-mb|
Browsing............................................|netrw-cr|
Squeezing the Current Tree-Listing Directory........|netrw-s-cr|
Browsing With A Horizontally Split Window...........|netrw-o|
Browsing With A New Tab.............................|netrw-t|
Browsing With A Vertically Split Window.............|netrw-v|
Change File Permission..............................|netrw-gp|
Change Listing Style.(thin wide long tree)..........|netrw-i|
Changing To A Bookmarked Directory..................|netrw-gb|
Changing To A Predecessor Directory.................|netrw-u|
Changing To A Successor Directory...................|netrw-U|
Customizing Browsing With A Special Handler.........|netrw-x|
Deleting Bookmarks..................................|netrw-mB|
Deleting Files Or Directories.......................|netrw-D|
Directory Exploring Commands........................|netrw-explore|
Exploring With Stars and Patterns...................|netrw-star|
Displaying Information About File...................|netrw-qf|
Edit File Or Directory Hiding List..................|netrw-ctrl-h|
Editing The Sorting Sequence........................|netrw-S|
Forcing treatment as a file or directory............|netrw-gd| |netrw-gf|
Going Up............................................|netrw--|
Hiding Files Or Directories.........................|netrw-a|
Improving Browsing..................................|netrw-ssh-hack|
Listing Bookmarks And History.......................|netrw-qb|
Making A New Directory..............................|netrw-d|
Making The Browsing Directory The Current Directory.|netrw-cd|
Marking Files.......................................|netrw-mf|
Unmarking Files.....................................|netrw-mF|
Marking Files By Location List......................|netrw-qL|
Marking Files By QuickFix List......................|netrw-qF|
Marking Files By Regular Expression.................|netrw-mr|
Marked Files: Arbitrary Shell Command...............|netrw-mx|
Marked Files: Arbitrary Shell Command, En Bloc......|netrw-mX|
Marked Files: Arbitrary Vim Command.................|netrw-mv|
Marked Files: Argument List.........................|netrw-ma| |netrw-mA|
Marked Files: Buffer List...........................|netrw-cb| |netrw-cB|
Marked Files: Compression And Decompression.........|netrw-mz|
Marked Files: Copying...............................|netrw-mc|
Marked Files: Diff..................................|netrw-md|
Marked Files: Editing...............................|netrw-me|
Marked Files: Grep..................................|netrw-mg|
Marked Files: Hiding and Unhiding by Suffix.........|netrw-mh|
Marked Files: Moving................................|netrw-mm|
Marked Files: Printing..............................|netrw-mp|
Marked Files: Sourcing..............................|netrw-ms|
Marked Files: Setting the Target Directory..........|netrw-mt|
Marked Files: Tagging...............................|netrw-mT|
Marked Files: Target Directory Using Bookmarks......|netrw-Tb|
Marked Files: Target Directory Using History........|netrw-Th|
Marked Files: Unmarking.............................|netrw-mu|
Netrw Browser Variables.............................|netrw-browser-var|
Netrw Browsing And Option Incompatibilities.........|netrw-incompatible|
Netrw Settings Window...............................|netrw-settings-window|
Obtaining A File....................................|netrw-O|
Preview Window......................................|netrw-p|
Previous Window.....................................|netrw-P|
Refreshing The Listing..............................|netrw-ctrl-l|
Reversing Sorting Order.............................|netrw-r|
Renaming Files Or Directories.......................|netrw-R|
Selecting Sorting Style.............................|netrw-s|
Setting Editing Window..............................|netrw-C|
10. Problems and Fixes....................................|netrw-problems|
11. Debugging Netrw Itself................................|netrw-debug|
12. History...............................................|netrw-history|
13. Todo..................................................|netrw-todo|
14. Credits...............................................|netrw-credits|
==============================================================================
2. Starting With Netrw *netrw-start* {{{1
Netrw makes reading files, writing files, browsing over a network, and
local browsing easy! First, make sure that you have plugins enabled, so
you'll need to have at least the following in your <.vimrc>:
(or see |netrw-activate|) >
vim scp://hostname/path/to/file
<
Want to make ssh/scp easier to use? Check out |netrw-ssh-hack|!
So, what if you have ftp, not ssh/scp? That's easy, too; try >
vim ftp://hostname/path/to/file
<
Want to make ftp simpler to use? See if your ftp supports a file called
<.netrc> -- typically it goes in your home directory, has read/write
permissions for only the user to read (ie. not group, world, other, etc),
and has lines resembling >
Now about browsing -- when you just want to look around before editing a
file. For browsing on your current host, just "edit" a directory: >
vim .
vim /home/userid/path
<
For browsing on a remote host, "edit" a directory (but make sure that
the directory name is followed by a "/"): >
vim scp://hostname/
vim ftp://hostname/path/to/dir/
<
See |netrw-browse| for more!
There are more protocols supported by netrw than just scp and ftp, too: see the
next section, |netrw-externapp|, on how to use these external applications with
netrw and vim.
If you want to use plugins, but for some reason don't wish to use netrw, then
you need to avoid loading both the plugin and the autoload portions of netrw.
You may do so by placing the following two lines in your <.vimrc>: >
:let g:loaded_netrw = 1
:let g:loaded_netrwPlugin = 1
<
==============================================================================
3. Netrw Reference *netrw-ref* {{{1
Generally, one may just use the URL notation with a normal editing
command, such as >
:e ftp://[user@]machine/path
<
Netrw also provides the Nread command:
One may just use the URL notation with a normal file writing
command, such as >
:w ftp://[user@]machine/path
<
Netrw also provides the Nwrite command:
One may just use the URL notation with the normal file sourcing
command, such as >
:so ftp://[user@]machine/path
<
Netrw also provides the Nsource command:
:e scp://[user]@hostname/path/
:e ftp://[user]@hostname/path/
<
For remote directory listings (ie. those using scp or ftp), that
trailing "/" is necessary (the slash tells netrw to treat the argument
as a directory to browse instead of as a file to download).
The Nread command may also be used to accomplish this (again, that
trailing slash is necessary): >
:Nread [protocol]://[user]@hostname/path/
<
*netrw-login* *netrw-password*
CHANGING USERID AND PASSWORD *netrw-chgup* *netrw-userpass* {{{2
Attempts to use ftp will prompt you for a user-id and a password.
These will be saved in global variables |g:netrw_uid| and
|s:netrw_passwd|; subsequent use of ftp will re-use those two strings,
thereby simplifying use of ftp. However, if you need to use a
different user id and/or password, you'll want to call |NetUserPass()|
first. To work around the need to enter passwords, check if your ftp
supports a <.netrc> file in your home directory. Also see
|netrw-passwd| (and if you're using ssh/scp hoping to figure out how
to not need to use passwords for scp, look at |netrw-ssh-hack|).
Netrw provides a lot of variables which allow you to customize netrw to your
preferences. One way to look at them is via the command :NetrwSettings (see
|netrw-settings|) which will display your current netrw settings. Most such
settings are described below, in |netrw-browser-options|, and in
|netrw-externapp|:
<
*g:Netrw_UserMaps* specifies a function or |List| of functions which can
be used to set up user-specified maps and functionality.
See |netrw-usermaps|
*g:netrw_nogx* if this variable exists, then the "gx" map will not
be available (see |netrw-gx|)
*g:netrw_sepchr* =\0xff
=\0x01 for enc == euc-jp (and perhaps it should be for
others, too, please let me know)
Separates priority codes from filenames internally.
See |netrw-p12|.
==============================================================================
4. Network-Oriented File Transfer *netrw-xfer* {{{1
<netrw.vim> is a standard plugin which acts as glue between Vim and the
various file transfer programs. It uses autocommand events (BufReadCmd,
FileReadCmd, BufWriteCmd) to intercept reads/writes with url-like filenames. >
Now, a word about Jan Minář's "FTP User Name and Password Disclosure"; first,
ftp is not a secure protocol. User names and passwords are transmitted "in
the clear" over the internet; any snooper tool can pick these up; this is not
a netrw thing, this is a ftp thing. If you're concerned about this, please
try to use scp or sftp instead.
Netrw re-uses the user id and password during the same vim session and so long
as the remote hostname remains the same.
Jan seems to be a bit confused about how netrw handles ftp; normally multiple
commands are performed in a "ftp session", and he seems to feel that the
uid/password should only be retained over one ftp session. However, netrw
does every ftp operation in a separate "ftp session"; so remembering the
uid/password for just one "ftp session" would be the same as not remembering
the uid/password at all. IMHO this would rapidly grow tiresome as one
browsed remote directories, for example.
On the other hand, thanks go to Jan M. for pointing out the many
vulnerabilities that netrw (and vim itself) had had in handling "crafted"
filenames. The |shellescape()| and |fnameescape()| functions were written in
response by Bram Moolenaar to handle these sort of problems, and netrw has
been modified to use them. Still, my advice is, if the "filename" looks like
a vim command that you aren't comfortable with having executed, don't open it.
For rcp, scp, sftp, and http, one may use network-oriented file transfers
transparently; ie.
>
vim rcp://[user@]machine/path
vim scp://[user@]machine/path
<
If your ftp supports <.netrc>, then it too can be transparently used
if the needed triad of machine name, user id, and password are present in
that file. Your ftp must be able to use the <.netrc> file on its own, however.
>
vim ftp://[user@]machine[[:#]portnumber]/path
<
Windows provides an ftp (typically c:\Windows\System32\ftp.exe) which uses
an option, -s:filename (filename can and probably should be a full path)
which contains ftp commands which will be automatically run whenever ftp
starts. You may use this feature to enter a user and password for one site: >
userid
password
< *netrw-windows-netrc* *netrw-windows-s*
If |g:netrw_ftp_cmd| contains -s:[path/]MACHINE, then (on Windows machines
only) netrw will substitute the current machine name requested for ftp
connections for MACHINE. Hence one can have multiple machine.ftp files
containing login and password for ftp. Example: >
C:\Users\Myself\myhost.ftp
<
Often, ftp will need to query the user for the userid and password.
The latter will be done "silently"; ie. asterisks will show up instead of
the actually-typed-in password. Netrw will retain the userid and password
for subsequent read/writes from the most recent transfer so subsequent
transfers (read/write) to or from that machine will take place without
additional prompting.
*netrw-urls*
+=================================+============================+============+
| Reading | Writing | Uses |
+=================================+============================+============+
| 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 | Not Available | 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 | Not Available | wget |
+---------------------------------+----------------------------+------------+
| HTTP: fetch is executable (*4) | | |
| http://[user@]host/path | Not Available | 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) |
+=================================+============================+============+
NETRC *netrw-netrc*
The <.netrc> file, typically located in your home directory, contains lines
therein which map a hostname (machine name) to the user id and password you
prefer to use with it.
The typical syntax for lines in a <.netrc> file is given as shown below.
Ftp under Unix usually supports <.netrc>; ftp under Windows usually doesn't.
>
machine {full machine name} login {user-id} password "{password}"
default login {user-id} password "{password}"
Your ftp client must handle the use of <.netrc> on its own, but if the
<.netrc> file exists, an ftp transfer will not ask for the user-id or
password.
Note:
Since this file contains passwords, make very sure nobody else can
read this file! Most programs will refuse to use a .netrc that is
readable for others. Don't forget that the system administrator can
still read the file! Ie. for Linux/Unix: chmod 600 .netrc
Even though Windows' ftp clients typically do not support .netrc, netrw has
a work-around: see |netrw-windows-s|.
PASSWORD *netrw-passwd*
The script attempts to get passwords for ftp invisibly using |inputsecret()|,
a built-in Vim function. See |netrw-userpass| for how to change the password
after one has set it.
==============================================================================
5. Activation *netrw-activate* {{{1
set nocp
if version >= 600
filetype plugin indent on
endif
<
By also including the following lines in your .vimrc, one may have netrw
immediately activate when using [g]vim without any filenames, showing the
current directory: >
==============================================================================
6. Transparent Remote File Editing *netrw-transparent* {{{1
vim ftp://[user@]machine/path
...
:wq
See |netrw-activate| for more on how to encourage your vim to use plugins
such as netrw.
==============================================================================
7. Ex Commands *netrw-ex* {{{1
The usual read/write commands are supported. There are also a few
additional commands available. Often you won't need to use Nwrite or
Nread as shown in |netrw-transparent| (ie. simply use >
:e URL
:r URL
:w URL
instead, as appropriate) -- see |netrw-urls|. In the explanations
below, a {netfile} is a URL to a remote file.
*:Nwrite* *:Nw*
:[range]Nw[rite] Write the specified lines to the current
file as specified in b:netrw_lastfile.
(related: |netrw-nwrite|)
*:Nread* *:Nr*
:Nr[ead] Read the lines from the file specified in b:netrw_lastfile
into the current buffer. (related: |netrw-nread|)
*:Nsource* *:Ns*
:Ns[ource] {netfile}
Source the {netfile}.
To start up vim using a remote .vimrc, one may use
the following (all on one line) (tnx to Antoine Mechelynck) >
vim -u NORC -N
--cmd "runtime plugin/netrwPlugin.vim"
--cmd "source scp://HOSTNAME/.vimrc"
< (related: |netrw-source|)
:call NetUserPass("userid")
This call will set the g:netrw_uid and, if
the password doesn't exist, will query the user for it.
(related: |netrw-userpass|)
:call NetUserPass("userid","passwd")
This call will set both the g:netrw_uid and s:netrw_passwd.
The user-id and password are used by ftp transfers. One may
effectively remove the user-id and password by using empty
strings (ie. "").
(related: |netrw-userpass|)
==============================================================================
8. Variables and Options *netrw-var* *netrw-settings* {{{1
Netrw supports a number of protocols. These protocols are invoked using the
variables listed below, and may be modified by the user.
>
------------------------
Protocol Control Options
------------------------
Option Type Setting Meaning
--------- -------- -------------- ---------------------------
< netrw_ftp variable =doesn't exist userid set by "user userid"
=0 userid set by "user userid"
=1 userid set by "userid"
NetReadFixup function =doesn't exist no change
=exists Allows user to have files
read via ftp automatically
transformed however they wish
by NetReadFixup()
g:netrw_dav_cmd var ="cadaver" if cadaver is executable
g:netrw_dav_cmd var ="curl -o" elseif curl is executable
g:netrw_fetch_cmd var ="fetch -o" if fetch is available
g:netrw_ftp_cmd var ="ftp"
g:netrw_http_cmd var ="fetch -o" if fetch is available
g:netrw_http_cmd var ="wget -O" else if wget is available
g:netrw_http_put_cmd var ="curl -T"
|g:netrw_list_cmd| var ="ssh USEPORT HOSTNAME ls -Fa"
g:netrw_rcp_cmd var ="rcp"
g:netrw_rsync_cmd var ="rsync"
*g:netrw_rsync_sep* var ="/" used to separate the hostname
from the file spec
g:netrw_scp_cmd var ="scp -q"
g:netrw_sftp_cmd var ="sftp" >
-------------------------------------------------------------------------
<
*netrw-ftp*
The g:netrw_..._cmd options (|g:netrw_ftp_cmd| and |g:netrw_sftp_cmd|)
specify the external program to use handle the ftp protocol. They may
include command line options (such as -p for passive mode). Example: >
Two options (|g:netrw_ftp| and |netrw-fixup|) both help with certain ftp's
that give trouble . In order to best understand how to use these options if
ftp is giving you troubles, a bit of discussion is provided on how netrw does
ftp reads.
For ftp, netrw typically builds up lines of one of the following formats in a
temporary file:
>
IF g:netrw_ftp !exists or is not 1 IF g:netrw_ftp exists and is 1
---------------------------------- ------------------------------
<
open machine [port] open machine [port]
user userid password userid password
[g:netrw_ftpmode] password
[g:netrw_ftpextracmd] [g:netrw_ftpmode]
get filename tempfile [g:netrw_extracmd]
get filename tempfile >
---------------------------------------------------------------------
<
The |g:netrw_ftpmode| and |g:netrw_ftpextracmd| are optional.
If <.netrc> exists it will be used to avoid having to query the user for
userid and password. The transferred file is put into a temporary file.
The temporary file is then read into the main editing session window that
requested it and the temporary file deleted.
If your ftp doesn't accept the "user" command and immediately just demands a
userid, then try putting "let netrw_ftp=1" in your <.vimrc>.
*netrw-cadaver*
To handle the SSL certificate dialog for untrusted servers, one may pull
down the certificate and place it into /usr/ssl/cert.pem. This operation
renders the server treatment as "trusted".
*netrw-fixup* *netreadfixup*
If your ftp for whatever reason generates unwanted lines (such as AUTH
messages) you may write a NetReadFixup() function:
>
function! NetReadFixup(method,line1,line2)
" a:line1: first new line in current file
" a:line2: last new line in current file
if a:method == 1 "rcp
elseif a:method == 2 "ftp + <.netrc>
elseif a:method == 3 "ftp + machine,uid,password,filename
elseif a:method == 4 "scp
elseif a:method == 5 "http/wget
elseif a:method == 6 "dav/cadaver
elseif a:method == 7 "rsync
elseif a:method == 8 "fetch
elseif a:method == 9 "sftp
else " complain
endif
endfunction
>
The NetReadFixup() function will be called if it exists and thus allows you to
customize your reading process. As a further example, <netrw.vim> contains
just such a function to handle Windows 95 ftp. For whatever reason, Windows
95's ftp dumps four blank lines at the end of a transfer, and so it is
desirable to automate their removal. Here's some code taken from <netrw.vim>
itself:
>
if has("win95") && g:netrw_win95ftp
fun! NetReadFixup(method, line1, line2)
if method == 3 " ftp (no <.netrc>)
let fourblanklines= line2 - 3
silent fourblanklines .. "," .. line2 .. "g/^\s*/d"
endif
endfunction
endif
>
(Related topics: |ftp| |netrw-userpass| |netrw-start|)
==============================================================================
9. Browsing *netrw-browsing* *netrw-browse* *netrw-help* {{{1
*netrw-browser* *netrw-dir* *netrw-list*
Netrw supports the browsing of directories on your local system and on remote
hosts; browsing includes listing files and directories, entering directories,
editing files therein, deleting files/directories, making new directories,
moving (renaming) files and directories, copying files and directories, etc.
One may mark files and execute any system command on them! The Netrw browser
generally implements the previous explorer's maps and commands for remote
directories, although details (such as pertinent global variable names)
necessarily differ. To browse a directory, simply "edit" it! >
vim /your/directory/
vim .
vim c:\your\directory\
<
(Related topics: |netrw-cr| |netrw-o| |netrw-p| |netrw-P| |netrw-t|
|netrw-mf| |netrw-mx| |netrw-D| |netrw-R| |netrw-v| )
The Netrw remote file and directory browser handles two protocols: ssh and
ftp. The protocol in the url, if it is ftp, will cause netrw also to use ftp
in its remote browsing. Specifying any other protocol will cause it to be
used for file transfers; but the ssh protocol will be used to do remote
browsing.
To use Netrw's remote directory browser, simply attempt to read a "file" with
a trailing slash and it will be interpreted as a request to list a directory:
>
vim [protocol]://[user@]hostname/path/
<
where [protocol] is typically scp or ftp. As an example, try: >
vim ftp://ftp.home.vim.org/pub/vim/
<
For local directories, the trailing slash is not required. Again, because it's
easy to miss: to browse remote directories, the URL must terminate with a
slash!
If you'd like to avoid entering the password repeatedly for remote directory
listings with ssh or scp, see |netrw-ssh-hack|. To avoid password entry with
ftp, see |netrw-netrc| (if your ftp supports it).
There are several things you can do to affect the browser's display of files:
* To hide files (don't want to see those xyz~ files anymore?) see
|netrw-ctrl-h|.
See |netrw-browse-cmds| for all the things you can do with netrw!
directory : /
executable : *
fifo : |
links : @
sockets : =
*netrw-quickmap* *netrw-quickmaps*
QUICK REFERENCE: MAPS *netrw-browse-maps* {{{2
>
--- ----------------- ----
Map Quick Explanation Link
--- ----------------- ----
< <F1> Causes Netrw to issue help
<cr> Netrw will enter the directory or read the file |netrw-cr|
<del> Netrw will attempt to remove the file/directory |netrw-del|
<c-h> Edit file hiding list |netrw-ctrl-
h|
<c-l> Causes Netrw to refresh the directory listing |netrw-ctrl-
l|
<c-r> Browse using a gvim server |netrw-ctrl-
r|
<c-tab> Shrink/expand a netrw/explore window |netrw-c-tab|
- Makes Netrw go up one directory |netrw--|
a Cycles between normal display, |netrw-a|
hiding (suppress display of files matching g:netrw_list_hide)
and showing (display only files which match g:netrw_list_hide)
cd Make browsing directory the current directory |netrw-cd|
C Setting the editing window |netrw-C|
d Make a directory |netrw-d|
D Attempt to remove the file(s)/directory(ies) |netrw-D|
gb Go to previous bookmarked directory |netrw-gb|
gd Force treatment as directory |netrw-gd|
gf Force treatment as file |netrw-gf|
gh Quick hide/unhide of dot-files |netrw-gh|
gn Make top of tree the directory below the cursor |netrw-gn|
gp Change local-only file permissions |netrw-gp|
i Cycle between thin, long, wide, and tree listings |netrw-i|
I Toggle the displaying of the banner |netrw-I|
mb Bookmark current directory |netrw-mb|
mc Copy marked files to marked-file target directory |netrw-mc|
md Apply diff to marked files (up to 3) |netrw-md|
me Place marked files on arg list and edit them |netrw-me|
mf Mark a file |netrw-mf|
mF Unmark files |netrw-mF|
mg Apply vimgrep to marked files |netrw-mg|
mh Toggle marked file suffices' presence on hiding list |netrw-mh|
mm Move marked files to marked-file target directory |netrw-mm|
mp Print marked files |netrw-mp|
mr Mark files using a shell-style |regexp| |netrw-mr|
mt Current browsing directory becomes markfile target |netrw-mt|
mT Apply ctags to marked files |netrw-mT|
mu Unmark all marked files |netrw-mu|
mv Apply arbitrary vim command to marked files |netrw-mv|
mx Apply arbitrary shell command to marked files |netrw-mx|
mX Apply arbitrary shell command to marked files en bloc|netrw-mX|
mz Compress/decompress marked files |netrw-mz|
o Enter the file/directory under the cursor in a new |netrw-o|
browser window. A horizontal split is used.
O Obtain a file specified by cursor |netrw-O|
p Preview the file |netrw-p|
P Browse in the previously used window |netrw-P|
qb List bookmarked directories and history |netrw-qb|
qf Display information on file |netrw-qf|
qF Mark files using a quickfix list |netrw-qF|
qL Mark files using a |location-list| |netrw-qL|
r Reverse sorting order |netrw-r|
R Rename the designated file(s)/directory(ies) |netrw-R|
s Select sorting style: by name, time, or file size |netrw-s|
S Specify suffix priority for name-sorting |netrw-S|
t Enter the file/directory under the cursor in a new tab|netrw-t|
u Change to recently-visited directory |netrw-u|
U Change to subsequently-visited directory |netrw-U|
v Enter the file/directory under the cursor in a new |netrw-v|
browser window. A vertical split is used.
x View file with an associated program |netrw-x|
X Execute filename under cursor via |system()| |netrw-X|
*netrw-quickcom* *netrw-quickcoms*
QUICK REFERENCE: COMMANDS *netrw-explore-cmds* *netrw-browse-cmds* {{{2
:NetrwClean[!]............................................|netrw-clean|
:NetrwSettings............................................|netrw-settings|
:Ntree....................................................|netrw-ntree|
:Explore[!] [dir] Explore directory of current file......|netrw-explore|
:Hexplore[!] [dir] Horizontal Split & Explore.............|netrw-explore|
:Lexplore[!] [dir] Left Explorer Toggle...................|netrw-explore|
:Nexplore[!] [dir] Vertical Split & Explore...............|netrw-explore|
:Pexplore[!] [dir] Vertical Split & Explore...............|netrw-explore|
:Rexplore Return to Explorer.....................|netrw-explore|
:Sexplore[!] [dir] Split & Explore directory .............|netrw-explore|
:Texplore[!] [dir] Tab & Explore..........................|netrw-explore|
:Vexplore[!] [dir] Vertical Split & Explore...............|netrw-explore|
BANNER DISPLAY *netrw-I*
One may easily "bookmark" the currently browsed directory by using >
mb
<
*.netrwbook*
Bookmarks are retained in between sessions of vim in a file called .netrwbook
as a |List|, which is typically stored in the first directory on the user's
'runtimepath'; entries are kept in sorted order.
If there are marked files and/or directories, mb will add them to the bookmark
list.
*netrw-:NetrwMB*
Additionally, one may use :NetrwMB to bookmark files or directories. >
:NetrwMB[!] [files/directories]
The :NetrwMB command is available outside of netrw buffers (once netrw has been
invoked in the session).
The file ".netrwbook" holds bookmarks when netrw (and vim) is not active. By
default, its stored on the first directory on the user's |'runtimepath'|.
Related Topics:
|netrw-gb| how to return (go) to a bookmark
|netrw-mB| how to delete bookmarks
|netrw-qb| how to list bookmarks
|g:netrw_home| controls where .netrwbook is kept
CAVEAT: There are four forms of listing (see |netrw-i|). Netrw assumes that
two or more spaces delimit filenames and directory names for the long and
wide listing formats. Thus, if your filename or directory name has two or
more sequential spaces embedded in it, or any trailing spaces, then you'll
need to use the "thin" format to select it.
When using the gui (gvim), one may select a file by pressing the <leftmouse>
button. In addition, if
Netrw attempts to speed up browsing, especially for remote browsing where one
may have to enter passwords, by keeping and re-using previously obtained
directory listing buffers. The |g:netrw_fastbrowse| variable is used to
control this behavior; one may have slow browsing (no buffer re-use), medium
speed browsing (re-use directory buffer listings only for remote directories),
and fast browsing (re-use directory buffer listings as often as possible).
The price for such re-use is that when changes are made (such as new files
are introduced into a directory), the listing may become out-of-date. One may
always refresh directory listing buffers by pressing ctrl-L (see
|netrw-ctrl-l|).
*netrw-s-cr*
Squeezing the Current Tree-Listing Directory~
When the tree listing style is enabled (see |netrw-i|) and one is using
gvim, then the <s-cr> mapping may be used to squeeze (close) the
directory currently containing the cursor.
Otherwise, one may remap a key combination of one's own choice to get
this effect: >
Related topics:
|netrw-ctrl-r| |netrw-o| |netrw-p|
|netrw-P| |netrw-t| |netrw-v|
Associated setting variables:
|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_browse_reject|
|g:netrw_ssh_cmd| |g:netrw_use_noswf|
Normally, the o key splits the window horizontally with the new window and
cursor at the top.
Related topics:
|netrw-ctrl-r| |netrw-o| |netrw-p|
|netrw-P| |netrw-t| |netrw-v|
Associated setting variables:
|g:netrw_alto| control above/below splitting
|g:netrw_winsize| control initial sizing
Normally one enters a file or directory using the <cr>. The "t" map
allows one to open a new window holding the new directory listing or file in
a new tab.
If you'd like to have the new listing in a background tab, use |gT|.
Related topics:
|netrw-ctrl-r| |netrw-o| |netrw-p|
|netrw-P| |netrw-t| |netrw-v|
Associated setting variables:
|g:netrw_winsize| control initial sizing
Normally one enters a file or directory using the <cr>. However, the "v" map
allows one to open a new window to hold the new directory listing or file. A
vertical split is used. (for horizontal splitting, see |netrw-o|)
Normally, the v key splits the window vertically with the new window and
cursor at the left.
There is only one tree listing buffer; using "v" on a displayed subdirectory
will split the screen, but the same buffer will be shown twice.
Related topics:
|netrw-ctrl-r| |netrw-o| |netrw-p|
|netrw-P| |netrw-t| |netrw-v|
Associated setting variables:
|g:netrw_altv| control right/left splitting
|g:netrw_winsize| control initial sizing
One may keep a browsing gvim separate from the gvim being used to edit.
Use the <c-r> map on a file (not a directory) in the netrw browser, and it
will use a gvim server (see |g:netrw_servername|). Subsequent use of <cr>
(see |netrw-cr|) will re-use that server for editing files.
Related topics:
|netrw-ctrl-r| |netrw-o| |netrw-p|
|netrw-P| |netrw-t| |netrw-v|
Associated setting variables:
|g:netrw_servername| : sets name of server
|g:netrw_browse_split| : controls how <cr> will open files
The "i" map cycles between the thin, long, wide, and tree listing formats.
The thin listing format gives just the files' and directories' names.
The long listing is either based on the "ls" command via ssh for remote
directories or displays the filename, file size (in bytes), and the time and
date of last modification for local directories. With the long listing
format, netrw is not able to recognize filenames which have trailing spaces.
Use the thin listing format for such files.
The wide listing format uses two or more contiguous spaces to delineate
filenames; when using that format, netrw won't be able to recognize or use
filenames which have two or more contiguous spaces embedded in the name or any
trailing spaces. The thin listing format will, however, work with such files.
The wide listing format is the most compact.
The tree listing format has a top directory followed by files and directories
preceded by one or more "|"s, which indicate the directory depth. One may
open and close directories by pressing the <cr> key while atop the directory
name.
One may make a preferred listing style your default; see |g:netrw_liststyle|.
As an example, by putting the following line in your .vimrc, >
let g:netrw_liststyle= 3
the tree style will become your default listing style.
One typical way to use the netrw tree display is to: >
vim .
(use i until a tree display shows)
navigate to a file
v (edit as desired in vertically split window)
ctrl-w h (to return to the netrw listing)
P (edit newly selected file in the previous window)
ctrl-w h (to return to the netrw listing)
P (edit newly selected file in the previous window)
...etc...
<
Associated setting variables: |g:netrw_liststyle| |g:netrw_maxfilenamelen|
|g:netrw_timefmt| |g:netrw_list_cmd|
"gp" will ask you for a new permission for the file named under the cursor.
Currently, this only works for local files.
{cnt}gb
Related Topics:
|netrw-mB| how to delete bookmarks
|netrw-mb| how to make a bookmark
|netrw-qb| how to list bookmarks
Every time you change to a new directory (new for the current session), netrw
will save the directory in a recently-visited directory history list (unless
|g:netrw_dirhistmax| is zero; by default, it holds ten entries). With the "u"
map, one can change to an earlier directory (predecessor). To do the
opposite, see |netrw-U|.
The "u" map also accepts counts to go back in the history several slots. For
your convenience, qb (see |netrw-qb|) lists the history number which may be
used in that count.
*.netrwhist*
See |g:netrw_dirhistmax| for how to control the quantity of history stack
slots. The file ".netrwhist" holds history when netrw (and vim) is not
active. By default, its stored on the first directory on the user's
|'runtimepath'|.
Related Topics:
|netrw-U| changing to a successor directory
|g:netrw_home| controls where .netrwhist is kept
With the "U" map, one can change to a later directory (successor).
This map is the opposite of the "u" map. (see |netrw-u|) Use the
qb map to list both the bookmarks and history. (see |netrw-qb|)
The "U" map also accepts counts to go forward in the history several slots.
One may specify a new tree top for tree listings using >
:Ntree [dirname]
Without a "dirname", the current line is used (and any leading depth
information is elided).
With a "dirname", the specified directory name is used.
The "gn" map will take the word below the cursor and use that for
changing the top of the tree listing.
With :NetrwClean one may easily remove netrw from one's home directory;
more precisely, from the first directory on your |'runtimepath'|.
With :NetrwClean!, netrw will attempt to remove netrw from all directories on
your |'runtimepath'|. Of course, you have to have write/delete permissions
correct to do this.
With either form of the command, netrw will first ask for confirmation
that the removal is in fact what you want to do. If netrw doesn't have
permission to remove a file, it will issue an error message.
*netrw-gx*
CUSTOMIZING BROWSING WITH A SPECIAL HANDLER *netrw-x* *netrw-handler* {{{2
(also see |netrw_filehandler|)
Certain files, such as html, gif, jpeg, (word/office) doc, etc, files, are
best seen with a special handler (ie. a tool provided with your computer's
operating system). Netrw allows one to invoke such special handlers by: >
If the viewer you wish to use does not support handling of a remote URL
directory, set |g:netrw_browsex_support_remote| to 0.
* for Windows 32 or 64, the URL and FileProtocolHandler dlls are used.
* for Gnome (with gnome-open): gnome-open is used.
* for KDE (with kfmclient) : kfmclient is used
* for Mac OS X : open is used.
* otherwise the netrwFileHandler plugin is used.
The gx mapping extends to all buffers; apply "gx" while atop a word and netrw
will apply a special handler to it (like "x" works when in a netrw buffer).
One may also use visual mode (see |visual-start|) to select the text that the
special handler will use. Normally gx uses expand("<cfile>") to pick up the
text under the cursor; one may change what |expand()| uses via the
|g:netrw_gx| variable (options include "<cword>", "<cWORD>"). Note that
expand("<cfile>") depends on the |'isfname'| setting. Alternatively, one may
select the text to be used by gx by making a visual selection (see
|visual-block|) and then pressing gx.
*netrw_filehandler*
< Users may write their own netrw File Handler functions to
support more suffixes with special handling. See
<autoload/netrwFileHandlers.vim> for examples on how to make
file handler functions. As an example: >
" NFH_suffix(filename)
fun! NFH_suffix(filename)
..do something special with filename..
endfun
<
These functions need to be defined in some file in your .vim/plugin
(vimfiles\plugin) directory. Vim's function names may not have punctuation
characters (except for the underscore) in them. To support suffices that
contain such characters, netrw will first convert the suffix using the
following table: >
*netrw-curdir*
DELETING BOOKMARKS *netrw-mB* {{{2
{cnt}mB
If there are marked files, then mB will remove them from the
bookmark list.
:NetrwMB! [files/directories]
Related Topics:
|netrw-gb| how to return (go) to a bookmark
|netrw-mb| how to make a bookmark
|netrw-qb| how to list bookmarks
If files have not been marked with |netrw-mf|: (local marked file list)
If files have been marked with |netrw-mf|: (local marked file list)
*netrw-:Explore*
:Explore will open the local-directory browser on the current file's
directory (or on directory [dir] if specified). The window will be
split only if the file has been modified and |'hidden'| is not set,
otherwise the browsing window will take over that window. Normally
the splitting is taken horizontally.
Also see: |netrw-:Rexplore|
:Explore! is like :Explore, but will use vertical splitting.
*netrw-:Hexplore*
:Hexplore [dir] does an :Explore with |:belowright| horizontal splitting.
:Hexplore! [dir] does an :Explore with |:aboveleft| horizontal splitting.
*netrw-:Lexplore*
:[N]Lexplore [dir] toggles a full height Explorer window on the left hand side
of the current tab. It will open a netrw window on the current
directory if [dir] is omitted; a :Lexplore [dir] will show the
specified directory in the left-hand side browser display no matter
from which window the command is issued.
Those who like this method often also like tree style displays;
see |g:netrw_liststyle|.
*netrw-:Texplore*
:Texplore [dir] does a |:tabnew| before generating the browser window
*netrw-:Vexplore*
:[N]Vexplore [dir] does an :Explore with |:leftabove| vertical splitting.
:[N]Vexplore! [dir] does an :Explore with |:rightbelow| vertical splitting.
[dir]: By default, these explorer commands use the current file's directory.
However, one may explicitly provide a directory (path) to use instead;
ie. >
:Explore /some/path
<
*netrw-:Rexplore*
:Rexplore This command is a little different from the other Explore commands
as it doesn't necessarily open an Explorer window.
Return to Explorer~
When one edits a file using netrw which can occur, for example,
when pressing <cr> while the cursor is atop a filename in a netrw
browser window, a :Rexplore issued while editing that file will
return the display to that of the last netrw browser display in
that window.
When Explore, Sexplore, Hexplore, or Vexplore are used with one of the
following four patterns Explore generates a list of files which satisfy the
request for the local file system. These exploration patterns will not work
with remote file browsing.
A plain >
:Explore
will clear the explore list.
As an example, consider
>
:Explore */*.c
:Nexplore
:Nexplore
:Pexplore
<
The status line will show, on the right hand side of the status line, a
message like "Match 3 of 20".
With the cursor atop a filename, pressing "qf" will reveal the file's size
and last modification timestamp. Currently this capability is only available
for local files.
The "<ctrl-h>" map brings up a requestor allowing the user to change the
file/directory hiding list contained in |g:netrw_list_hide|. The hiding list
consists of one or more patterns delimited by commas. Files and/or
directories satisfying these patterns will either be hidden (ie. not shown) or
be the only ones displayed (see |netrw-a|).
The "gh" mapping (see |netrw-gh|) quickly alternates between the usual
hiding list and the hiding of files or directories that begin with ".".
As an example, >
let g:netrw_list_hide= '\(^\|\s\s\)\zs\.\S\+'
Effectively, this makes the effect of a |netrw-gh| command the initial setting.
What it means:
*netrw-sort-sequence*
EDITING THE SORTING SEQUENCE *netrw-S* *netrw-sortsequence* {{{2
When "Sorted by" is name, one may specify priority via the sorting sequence
(g:netrw_sort_sequence). The sorting sequence typically prioritizes the
name-listing by suffix, although any pattern will do. Patterns are delimited
by commas. The default sorting sequence is (all one line):
Pressing X while the cursor is atop an executable file will yield a prompt
using the filename asking for any arguments. Upon pressing a [return], netrw
will then call |system()| with that command and arguments. The result will be
displayed by |:echomsg|, and so |:messages| will repeat display of the result.
Ansi escape sequences will be stripped out.
See |cmdline-window| for directions for more on how to edit the arguments.
Remote symbolic links (ie. those listed via ssh or ftp) are problematic
in that it is difficult to tell whether they link to a file or to a
directory.
To go up a directory, press "-" or press the <cr> when atop the ../ directory
entry in the listing.
Netrw's browsing facility allows one to use the hiding list in one of three
ways: ignore it, hide files which match, and show only those files which
match.
The "a" map allows the user to cycle through the three hiding modes.
Example: \.[ch]$
This hiding list command will hide/show all *.c and *.h files.
Example: \.c$,\.h$
This hiding list command will also hide/show all *.c and *.h
files.
Don't forget to use the "a" map to select the mode (normal/hiding/show) you
want!
If files have been marked using |netrw-mf|, then this command will:
*netrw-gitignore*
Netrw provides a helper function 'netrw_gitignore#Hide()' that, when used with
|g:netrw_list_hide| automatically hides all git-ignored files.
'./.gitignore'
'./.git/info/exclude'
global gitignore file: `git config --global core.excludesfile`
system gitignore file: `git config --system core.excludesfile`
<
Files that do not exist, are ignored.
Git-ignore patterns are taken from existing files, and converted to patterns for
hiding files. For example, if you had '*.log' in your '.gitignore' file, it
would be converted to '.*\.log'.
To use this function, simply assign its output to |g:netrw_list_hide| option. >
Especially with the remote directory browser, constantly entering the password
is tedious.
For Linux/Unix systems, the book "Linux Server Hacks - 100 industrial strength
tips & tools" by Rob Flickenger (O'Reilly, ISBN 0-596-00461-3) gives a tip
for setting up no-password ssh and scp and discusses associated security
issues. It used to be available at http://hacks.oreilly.com/pub/h/66 ,
but apparently that address is now being redirected to some "hackzine".
I'll attempt a summary based on that article and on a communication from
Ben Schmidt:
For Windows, folks on the vim mailing list have mentioned that Pageant helps
with avoiding the constant need to enter the password.
Kingston Fung wrote about another way to avoid constantly needing to enter
passwords:
In order to avoid the need to type in the password for scp each time, you
provide a hack in the docs to set up a non password ssh account. I found a
better way to do that: I can use a regular ssh account which uses a
password to access the material without the need to key-in the password
each time. It's good for security and convenience. I tried ssh public key
authorization + ssh-agent, implementing this, and it works! Here are two
links with instructions:
http://www.ibm.com/developerworks/library/l-keyc2/
http://sial.org/howto/openssh/publickey-auth/
Ssh hints:
Thomer Gil has provided a hint on how to speed up netrw+ssh:
http://thomer.com/howtos/netrw_ssh.html
Pressing "qb" (query bookmarks) will list both the bookmarked directories and
directory traversal history.
Related Topics:
|netrw-gb| how to return (go) to a bookmark
|netrw-mb| how to make a bookmark
|netrw-mB| how to delete bookmarks
|netrw-u| change to a predecessor directory via the history stack
|netrw-U| change to a successor directory via the history stack
With the "d" map one may make a new directory either remotely (which depends
on the global variable g:netrw_mkdir_cmd) or locally (which depends on the
global variable g:netrw_localmkdir). Netrw will issue a request for the new
directory's name. A bare <CR> at that point will abort the making of the
directory. Attempts to make a local directory that already exists (as either
a file or a directory) will be detected, reported on, and ignored.
|netrw-cd| : This map's name was changed from "c" to cd (see |netrw-cd|).
This change was done to allow for |netrw-cb| and |netrw-cB| maps.
:MF *.c
<
(Note that :MF uses |<f-args>| to break the line
at spaces)
One may unmark files one at a time the same way one marks them; ie. place
the cursor atop a marked file and press "mf". This process also works
with <s-leftmouse> using gvim. One may unmark all files by pressing
"mu" (see |netrw-mu|).
If the mouse is enabled and works with your vim, you may use <s-leftmouse> to
mark one or more files. You may mark multiple files by dragging the shifted
leftmouse. (see |netrw-mouse|)
The "mF" command will unmark all files in the current buffer. One may also use
mf (|netrw-mf|) on a specific, already marked, file to unmark just that file.
One may convert |location-list|s into a marked file list using "qL".
You may then proceed with commands such as me (|netrw-me|) to edit them.
One may convert |quickfix-error-lists| into a marked file list using "qF".
You may then proceed with commands such as me (|netrw-me|) to edit them.
Quickfix error lists are generated, for example, by calls to |:vimgrep|.
One may also mark files by pressing "mr"; netrw will then issue a prompt,
"Enter regexp: ". You may then enter a shell-style regular expression such
as *.c$ (see |glob()|). For remote systems, glob() doesn't work -- so netrw
converts "*" into ".*" (see |regexp|) and marks files based on that. In the
future I may make it possible to use |regexp|s instead of glob()-style
expressions (yet-another-option).
The "mv" map causes netrw to execute an arbitrary vim command on each file on
the local marked file list, individually:
* 1split
* sil! keepalt e file
* run vim command
* sil! keepalt wq!
A prompt, "Enter vim command: ", will be issued to elicit the vim command you
wish used. See |cmdline-window| for directions for more on how to edit the
command.
Upon activation of the "mx" map, netrw will query the user for some (external)
command to be applied to all marked files. All "%"s in the command will be
substituted with the name of each marked file in turn. If no "%"s are in the
command, then the command will be followed by a space and a marked filename.
Example:
(mark files)
mx
Enter command: cat
Upon activation of the 'mX' map, netrw will query the user for some (external)
command to be applied to all marked files on the global marked file list. The
"en bloc" means that one command will be executed on all the files at once: >
command files
This approach is useful, for example, to select files and make a tarball: >
(mark files)
mX
Enter command: tar cf mynewtarball.tar
<
The command that will be run with this example:
Using cb, one moves filenames from the marked file list to the buffer list.
Using cB, one copies filenames from the buffer list to the marked file list.
If any marked files are compressed, then "mz" will decompress them.
If any marked files are decompressed, then "mz" will compress them
using the command specified by |g:netrw_compress|; by default,
that's "gzip".
If one does not have a target directory set with |netrw-mt|, then netrw
will query you for a directory to copy to.
One may also copy directories and their contents (local only) to a target
directory.
The "me" command will place the marked files on the |arglist| and commence
editing them. One may return the to explorer window with |:Rexplore|.
(use |:n| and |:p| to edit next and previous files in the arglist)
/pattern/[g][j]
! /pattern/[g][j]
pattern
<
With /pattern/, editing will start with the first item on the |quickfix| list
that vimgrep sets up (see |:copen|, |:cnext|, |:cprevious|, |:cclose|). The
|:vimgrep|
command is in use, so without 'g' each line is added to quickfix list only
once; with 'g' every match is included.
With /pattern/j, "mg" will winnow the current marked file list to just those
marked files also possessing the specified pattern. Thus, one may use >
mr ...file-pattern...
mg /pattern/j
<
to have a marked file list satisfying the file-pattern but also restricted to
files containing some desired pattern.
The "mh" command extracts the suffices of the marked files and toggles their
presence on the hiding list. Please note that marking the same suffix
this way multiple times will result in the suffix's presence being toggled
for each file (so an even quantity of marked files having the same suffix
is the same as not having bothered to select them at all).
When "mp" is used, netrw will apply the |:hardcopy| command to marked files.
What netrw does is open each file in a one-line window, execute hardcopy, then
close the one-line window.
With "ms", netrw will source the marked files (using vim's |:source| command)
Set the marked file copy/move-to target (see |netrw-mc| and |netrw-mm|):
* If the cursor is atop a file name, then the netrw window's currently
displayed directory is used for the copy/move-to target.
* Also, if the cursor is in the banner, then the netrw window's currently
displayed directory is used for the copy/move-to target.
Unless the target already is the current directory. In which case,
typing "mf" clears the target.
* One may use the :MT [directory] command to set the target *netrw-:MT*
This command uses |<q-args>|, so spaces in the directory name are
permitted without escaping.
* With mouse-enabled vim or with gvim, one may select a target by using
<c-leftmouse>
There is only one copy/move-to target at a time in a vim session; ie. the
target is a script variable (see |s:var|) and is shared between all netrw
windows (in an instance of vim).
When using menus and gvim, netrw provides a "Targets" entry which allows one
to pick a target from the list of bookmarks and history.
Related topics:
Marking Files......................................|netrw-mf|
Marking Files by Regular Expression................|netrw-mr|
Marked Files: Target Directory Using Bookmarks.....|netrw-Tb|
Marked Files: Target Directory Using History.......|netrw-Th|
MARKED FILES: TAGGING *netrw-mT* {{{2
(See |netrw-mf| and |netrw-mr| for how to mark files)
(uses the global marked file list)
The "mT" mapping will apply the command in |g:netrw_ctags| (by default, it is
"ctags") to marked files. For remote browsing, in order to create a tags file
netrw will use ssh (see |g:netrw_ssh_cmd|), and so ssh must be available for
this to work on remote systems. For your local system, see |ctags| on how to
get a version. I myself use hdrtags, currently available at
http://www.drchip.org/astronaut/src/index.html , and have >
When a remote set of files are tagged, the resulting tags file is "obtained";
ie. a copy is transferred to the local system's directory. The now local tags
file is then modified so that one may use it through the network. The
modification made concerns the names of the files in the tags; each filename is
preceded by the netrw-compatible URL used to obtain it. When one subsequently
uses one of the go to tag actions (|tags|), the URL will be used by netrw to
edit the desired file and go to the tag.
The |netrw-qb| map will give you a list of bookmarks (and history).
One may choose one of the bookmarks to become your marked file
target by using [count]Tb (default count: 1).
Related topics:
Copying files to target............................|netrw-mc|
Listing Bookmarks and History......................|netrw-qb|
Marked Files: Setting The Target Directory.........|netrw-mt|
Marked Files: Target Directory Using History.......|netrw-Th|
Marking Files......................................|netrw-mf|
Marking Files by Regular Expression................|netrw-mr|
Moving files to target.............................|netrw-mm|
The |netrw-qb| map will give you a list of history (and bookmarks).
One may choose one of the history entries to become your marked file
target by using [count]Th (default count: 0; ie. the current directory).
Related topics:
Copying files to target............................|netrw-mc|
Listing Bookmarks and History......................|netrw-qb|
Marked Files: Setting The Target Directory.........|netrw-mt|
Marked Files: Target Directory Using Bookmarks.....|netrw-Tb|
Marking Files......................................|netrw-mf|
Marking Files by Regular Expression................|netrw-mr|
Moving files to target.............................|netrw-mm|
The "mu" mapping will unmark all currently marked files. This command differs
from "mF" as the latter only unmarks files in the current directory whereas
"mu" will unmark global and all buffer-local marked files.
(see |netrw-mF|)
*netrw-browser-settings*
NETRW BROWSER VARIABLES *netrw-browser-options* *netrw-browser-var* {{{2
(if you're interested in the netrw file transfer settings, see |netrw-options|
and |netrw-protocol|)
Related topics:
|g:netrw_alto| |g:netrw_altv|
|netrw-C| |netrw-cr|
|netrw-ctrl-r|
*g:netrw_browsex_support_remote*
specify if the specified viewer supports a
remote URL. (see |netrw-handler|).
*g:netrw_clipboard* =1
By default, netrw will attempt to insure that
the clipboard's values will remain unchanged.
However, some users report that they have
speed problems with this; consequently, this
option, when set to zero, lets such users
prevent netrw from saving and restoring the
clipboard (the latter is done only as needed).
That means that if the clipboard is changed
(inadvertently) by normal netrw operation that
it will not be restored to its prior state.
*g:netrw_compress* ="gzip"
Will compress marked files with this
command
*g:netrw_ctags* ="ctags"
The default external program used to create
tags
*g:netrw_cursor* = 2 (default)
This option controls the use of the
|'cursorline'| (cul) and |'cursorcolumn'|
(cuc) settings by netrw:
Where
u-cul : user's |'cursorline'| initial setting used
u-cuc : user's |'cursorcolumn'| initial setting used
U-cul : user's |'cursorline'| current setting used
U-cuc : user's |'cursorcolumn'| current setting used
cul : |'cursorline'| will be locally set
cuc : |'cursorcolumn'| will be locally set
Examples:
let g:netrw_list_hide= '.*\.swp$'
let g:netrw_list_hide= netrw_gitignore#Hide() ..
'.*\.swp$'
default: ""
default: =0
netrwBak : *.bak
netrwCompress: *.gz *.bz2 *.Z *.zip
netrwCoreDump: core.\d\+
netrwData : *.dat
netrwDoc : *.doc,*.txt,*.pdf,
*.pdf,*.docx
netrwHdr : *.h
netrwLex : *.l *.lex
netrwLib : *.a *.so *.lib *.dll
netrwMakefile: [mM]akefile *.mak
netrwObj : *.o *.obj
netrwPix : *.bmp,*.fit,*.fits,*.gif,
*.jpg,*.jpeg,*.pcx,*.ppc
*.pgm,*.png,*.psd,*.rgb
*.tif,*.xbm,*.xcf
netrwTags : tags ANmenu ANtags
netrwTilde : *
netrwTmp : tmp* *tmp
netrwYacc : *.y
Netrw has been designed to handle user options by saving them, setting the
options to something that's compatible with netrw's needs, and then restoring
them. However, the autochdir option: >
:set acd
is problematic. Autochdir sets the current directory to that containing the
file you edit; this apparently also applies to directories. In other words,
autochdir sets the current directory to that containing the "file" (even if
that "file" is itself a directory).
==============================================================================
OBTAINING A FILE *netrw-obtain* *netrw-O* {{{2
When browsing a remote directory, one may obtain a file under the cursor
(ie. get a copy on your local machine, but not edit it) by pressing the O
key.
The marked files will be obtained (ie. a copy will be transferred to your
local machine, but not set up for editing).
Only ftp and scp are supported for this operation (but since these two are
available for browsing, that shouldn't be a problem). The status bar will
then show, on its right hand side, a message like "Obtaining filename". The
statusline will be restored after the transfer is complete.
Netrw can also "obtain" a file using the local browser. Netrw's display
of a directory is not necessarily the same as Vim's "current directory",
unless |g:netrw_keepdir| is set to 0 in the user's <.vimrc>. One may select
a file using the local browser (by putting the cursor on it) and pressing
"O" will then "obtain" the file; ie. copy it to Vim's current directory.
Related topics:
* To see what the current directory is, use |:pwd|
* To make the currently browsed directory the current directory, see
|netrw-cd|
* To automatically make the currently browsed directory the current
directory, see |g:netrw_keepdir|.
*netrw-newfile* *netrw-createfile*
OPEN A NEW FILE IN NETRW'S CURRENT DIRECTORY *netrw-%* {{{2
To open a new file in netrw's current directory, press "%". This map
will query the user for a new filename; an empty file by that name will
be placed in the netrw's current directory (ie. b:netrw_curdir).
One may use a preview window by using the "p" key when the cursor is atop the
desired filename to be previewed. The display will then split to show both
the browser (where the cursor will remain) and the file (see |:pedit|). By
default, the split will be taken horizontally; one may use vertical splitting
if one has set |g:netrw_preview| first.
let g:netrw_preview = 1
let g:netrw_liststyle = 3
let g:netrw_winsize = 30
These will:
Related: if you like this idea, you may also find :Lexplore
(|netrw-:Lexplore|) or |g:netrw_chgwin| of interest
To edit a file or directory under the cursor in the previously used (last
accessed) window (see :he |CTRL-W_p|), press a "P". If there's only one
window, then the one window will be horizontally split (by default).
If there's more than one window, the previous window will be re-used on
the selected file/directory. If the previous window's associated buffer
has been modified, and there's only one window with that buffer, then
the user will be asked if s/he wishes to save the buffer first (yes,
no, or cancel).
One may toggle between normal and reverse sorting order by pressing the
"r" key.
The ctrl-X character has special meaning for renaming files: >
Note that moving files is a dangerous operation; copies are safer. That's
because a "move" for remote files is actually a copy + delete -- and if
the copy fails and the delete succeeds you may lose the file.
Use at your own risk.
ssh HOSTNAME mv
<
One may rename a block of files and directories by selecting them with
V (|linewise-visual|) when using thin style.
See |cmdline-editing| for more on how to edit the command line; in particular,
you'll find <ctrl-f> (initiates cmdline window editing) and <ctrl-c> (uses the
command line under the cursor) useful in conjunction with the R command.
One may select the sorting style by name, time, or (file) size. The "s" map
allows one to circulate amongst the three choices; the directory listing will
automatically be refreshed to reflect the selected style.
One may select a netrw window for editing with the "C" mapping, using the
:NetrwC [win#] command, or by setting |g:netrw_chgwin| to the selected window
number. Subsequent selection of a file to edit (|netrw-cr|) will use that
window.
Using >
let g:netrw_chgwin= -1
will restore the default editing behavior
(ie. subsequent editing will use the current window).
[["keymap-sequence","ExampleUserMapFunc"],...]
<
When netrw is setting up maps for a netrw buffer, if |g:Netrw_UserMaps|
exists, then the internal function netrw#UserMaps(islocal) is called.
This function goes through all the entries in the |g:Netrw_UserMaps| list:
fun! ExampleUserMapFunc(islocal)
<
where a:islocal is 1 if its a local-directory system call or 0 when
remote-directory system call.
call netrw#Modify("netrwmarkfilelist",[])
<
Example: Clear netrw's marked file list via a mapping on gu >
" ExampleUserMap: {{{2
fun! ExampleUserMap(islocal)
call netrw#Modify("netrwmarkfilelist",[])
call netrw#Modify('netrwmarkfilemtch_{bufnr("%")}',"")
let retval= ["refresh"]
return retval
endfun
let g:Netrw_UserMaps= [["gu","ExampleUserMap"]]
<
let g:netrw_win95ftp= 1
*netrw-p2*
P2. I use Windows, and my network browsing with ftp doesn't sort by {{{2
time or size! -or- The remote system is a Windows server; why
don't I get sorts by time or size?
let g:netrw_cygwin= 1
<
This problem also occurs when the remote system is Windows.
In this situation, the various g:netrw_ftp_[time|size]list_cmds
are as shown above, but the remote system will not correctly
modify its listing behavior.
*netrw-p3*
P3. I tried rcp://user@host/ (or protocol other than ftp) and netrw {{{2
used ssh! That wasn't what I asked for...
*netrw-p4*
P4. I would like long listings to be the default. {{{2
Put the following statement into your |.vimrc|: >
let g:netrw_liststyle= 1
<
Check out |netrw-browser-var| for more customizations that
you can set.
*netrw-p5*
P5. My times come up oddly in local browsing {{{2
*netrw-p8*
P8. I'm getting "ssh is not executable on your system" -- what do I {{{2
do?
(Dudley Fox) Most people I know use putty for windows ssh. It
is a free ssh/telnet application. You can read more about it
here:
http://www.chiark.greenend.org.uk/~sgtatham/putty/ Also:
(Marlin Unruh) This program also works for me. It's a single
executable, so he/she can copy it into the Windows\System32
folder and create a shortcut to it.
(Vissale Neang) Maybe you can try OpenSSH for windows, which
can be obtained from:
http://sshwindows.sourceforge.net/
http://gnuwin32.sourceforge.net/
- Click "Add..."
- Set External Editor (adjust path as needed, include
the quotes and !.! at the end):
"c:\Program Files\Vim\vim82\gvim.exe" !.!
- Check that the filetype in the box below is
{asterisk}.{asterisk} (all files), or whatever types
you want (cec: change {asterisk} to * ; I had to
write it that way because otherwise the helptags
system thinks it's a tag)
- Make sure it's at the top of the listbox (click it,
then click "Up" if it's not)
If using the Norton Commander style, you just have to hit <F4>
to edit a file in a local copy of gvim.
http://www.chiark.greenend.org.uk/~sgtatham/putty/0.60/htmldoc/Chapter8.html#pubkey
-gettingready
(8.3 Getting ready for public key authentication)
<
How to use a private key with 'pscp': >
http://www.chiark.greenend.org.uk/~sgtatham/putty/0.60/htmldoc/Chapter5.html
(5.2.4 Using public key authentication with PSCP)
<
(Ben Schmidt) I find the ssh included with cwRsync is
brilliant, and install cwRsync or cwRsyncServer on most
Windows systems I come across these days. I guess COPSSH,
packed by the same person, is probably even better for use as
just ssh on Windows, and probably includes sftp, etc. which I
suspect the cwRsync doesn't, though it might
*netrw-p9* *netrw-ml_get*
P9. I'm browsing, changing directory, and bang! ml_get errors {{{2
appear and I have to kill vim. Any way around this?
*netrw-p11*
P11. I want to have two windows; a thin one on the left and my {{{2
editing window on the right. How may I accomplish this?
Previous solution:
*netrw-p12*
P12. My directory isn't sorting correctly, or unwanted letters are {{{2
appearing in the listed filenames, or things aren't lining
up properly in the wide listing, ...
*netrw-p13*
P13. I'm a Windows + putty + ssh user, and when I attempt to {{{2
browse, the directories are missing trailing "/"s so netrw treats
them as file transfers instead of as attempts to browse
subdirectories. How may I fix this?
(mikeyao) If you want to use vim via ssh and putty under Windows,
try combining the use of pscp/psftp with plink. pscp/psftp will
be used to connect and plink will be used to execute commands on
the server, for example: list files and directory using 'ls'.
< Then create an ssh connection to the host and leave it running: >
ssh -N host.domain.com
< Now remotely open a file with Vim's Netrw and enjoy the
zippiness: >
vim scp://host.domain.com//home/user/.bashrc
<
*netrw-p15*
P15. How may I use a double-click instead of netrw's usual single {{{2
click to open a file or directory? (Ben Fritz)
First, disable netrw's mapping with >
let g:netrw_mousemaps= 0
< and then create a netrw buffer only mapping in
$HOME/.vim/after/ftplugin/netrw.vim: >
nmap <buffer> <2-leftmouse> <CR>
< Note that setting g:netrw_mousemaps to zero will turn off
all netrw's mouse mappings, not just the <leftmouse> one.
(see |g:netrw_mousemaps|)
*netrw-p16*
P16. When editing remote files (ex. :e ftp://hostname/path/file), {{{2
under Windows I get an |E303| message complaining that its unable
to open a swap file.
*netrw-p17*
P17. Netrw is closing buffers on its own. {{{2
What steps will reproduce the problem?
1. :Explore, navigate directories, open a file
2. :Explore, open another file
3. Buffer opened in step 1 will be closed. o
What is the expected output? What do you see instead?
I expect both buffers to exist, but only the last one does.
*netrw-P18*
P18. How to locally edit a file that's only available via {{{2
another server accessible via ssh?
See http://stackoverflow.com/questions/12469645/
"Using Vim to Remotely Edit A File on ServerB Only
Accessible From ServerA"
*netrw-P19*
P19. How do I get numbering on in directory listings? {{{2
With |g:netrw_bufsettings|, you can control netrw's buffer
settings; try putting >
let g:netrw_bufsettings="noma nomod nu nobl nowrap ro nornu"
< in your .vimrc. If you'd like to have relative numbering
instead, try >
let g:netrw_bufsettings="noma nomod nonu nobl nowrap ro rnu"
<
*netrw-P20*
P20. How may I have gvim start up showing a directory listing? {{{2
Try putting the following code snippet into your .vimrc: >
augroup VimStartup
au!
au VimEnter * if expand("%") == "" && argc() == 0 &&
\ (v:servername =~ 'GVIM\d*' || v:servername == "")
\ | e . | endif
augroup END
< You may use Lexplore instead of "e" if you're so inclined.
This snippet assumes that you have client-server enabled
(ie. a "huge" vim version).
*netrw-P21*
P21. I've made a directory (or file) with an accented character, {{{2
but netrw isn't letting me enter that directory/read that file:
What's wrong?
|g:netrw_localcopycmd|, |g:netrw_localmovecmd|,
|g:netrw_localrmdir|, |g:netrw_mkdir_cmd|).
You may need to adjust the default commands for one or more of
these commands by setting them properly in your .vimrc. Another
source of difficulty is that these commands use vim's local
directory, which may not be the same as the browsing directory
shown by netrw (see |g:netrw_keepdir|).
==============================================================================
11. Debugging Netrw Itself *netrw-debug* {{{1
Step 1: check that the problem you've encountered hasn't already been resolved
by obtaining a copy of the latest (often developmental) netrw at:
http://www.drchip.org/astronaut/vim/index.html#NETRW
$HOME/.vim/plugin/netrwPlugin.vim
$HOME/.vim/autoload/netrw.vim
<
Step 2: assuming that you've installed the latest version of netrw,
check that your problem is really due to netrw. Create a file
called netrw.vimrc with the following contents: >
set nocp
so $HOME/.vim/plugin/netrwPlugin.vim
<
Then run netrw as follows: >
Step 3: If the problem still is present, then get a debugging trace from
netrw:
http://www.drchip.org/astronaut/vim/index.html#DECHO
or
http://vim.sourceforge.net/scripts/script.php?script_id=120
vim Decho.vba.gz
:so %
:q
<
2. To turn on debug tracing in netrw, then edit the <netrw.vim>
file by typing: >
vim netrw.vim
:DechoOn
:wq
<
To restore to normal non-debugging behavior, re-edit <netrw.vim>
and type >
vim netrw.vim
:DechoOff
:wq
<
This command, provided by <Decho.vim>, will comment out all
Decho-debugging statements (Dfunc(), Dret(), Decho(), Dredir()).
set nocp
so $HOME/.vim/plugin/Decho.vim
so $HOME/.vim/plugin/netrwPlugin.vim
<
You should continue to run vim with >
:w! DBG
:tabnext
:set bt=
:w! DBG
<
Furthermore, it'd be helpful if you would type >
:Dsep <command>
[email protected]
<
==============================================================================
12. History *netrw-history* {{{1
==============================================================================
13. Todo *netrw-todo* {{{1
==============================================================================
14. Credits *netrw-credits* {{{1
==============================================================================
Modelines: {{{1
vim:tw=78:ts=8:ft=help:noet:norl:fdm=marker