sponsor Vim development Vim logo Vim Book Ad

netrw.vim : Network oriented reading, writing, and browsing (keywords: netrw ftp scp)

 script karma  Rating 854/284, Downloaded by 18796    Comments, bugs, improvements  Vim wiki

created by
Charles Campbell
script type
                STARTING WITH v66, NETRW REQUIRES VIM 7.0

Netrw supports reading and writing files across networks.  One may use urls for filenames or one may use netrw's Nread and Nwrite commands. Netrw as provided here supports remote and local directory browsing, and supports  editing files across the network using a variety of methods.  Please report any bugs to NdrOchip@ScampbellPfamily.AbizM - NOSPAM.

    Example:  vim ftp://user@machine/path

(the following table should be columnar if fixed-width fonts are used in your browser)

        :e dav://machine[:port]/path                      uses cadaver
        :e fetch://[user@]machine/path                  uses fetch
        :e ftp://[user@]machine[[:#]port]/path          uses ftp   autodetects <.netrc>
        :e http://[user@]machine/path                    uses http  uses wget
        :e rcp://[user@]machine/path                     uses rcp
        :e rsync://[user@]machine[:port]/path         uses rsync
        :e scp://[user@]machine[[:#]port]/path        uses scp
        :e sftp://[user@]machine/path                    uses sftp

        :Nread ?                                                     give help
        :Nread "machine:path"                                 uses rcp
        :Nread "machine path"                                 uses ftp   with <.netrc>
        :Nread "machine id password path"              uses ftp
        :Nread "dav://machine[:port]/path"                uses cadaver
        :Nread "fetch://[user@]machine/path"            uses fetch
        :Nread "ftp://[user@]machine[[:#]port]/path"    uses ftp   autodetects <.netrc>
        :Nread "http://[user@]machine/path"              uses http  uses wget
        :Nread "rcp://[user@]machine/path"               uses rcp
        :Nread "rsync://[user@]machine[:port]/path"   uses rsync
        :Nread "scp://[user@]machine[[:#]port]/path"  uses scp
        :Nread "sftp://[user@]machine/path"             uses sftp

        :Nwrite ?                                                      give help
        :Nwrite "machine:path"                                  uses rcp
        :Nwrite "machine path"                                  uses ftp   with <.netrc>
        :Nwrite "machine id password path"               uses ftp
        :Nwrite "dav://machine[:port]/path"                  uses cadaver
        :Nwrite "ftp://[user@]machine[[:#]port]/path"     uses ftp   autodetects <.netrc>
        :Nwrite "rcp://[user@]machine/path"                uses rcp
        :Nwrite "rsync://[user@]machine[:port]/path"    uses rsync
        :Nwrite "scp://[user@]machine[[:#]port]/path"   uses scp
        :Nwrite "sftp://[user@]machine/path"               uses sftp
        http: not supported!

        :e [protocol]://[user]@hostname/path/
        :Nread [protocol]://[user]@hostname/path/

        :e /some/path/to/a/directory

Netrw supports browsing both local and remote directories.  For remote directory browsing, one must include a trailing slash (/) on the path!  The interface resembles the file explorer that comes with vim v6.3 and earlier.  Variables which control netrw's optional behavior are named differently, however.

For remote directory browsing, the [protocol]://[user]@hostname/path/ is user-directory relative.  If you want to specify a full path, use another slash before the path: [protocol]://[user]@hostname//path/.

Netrw supports many file-explorer maps, such as o v d D etc.  Look at the help for netrw-o, for example.  One may also use :Explore and relatives to explore directories with the current file.

The netrw.vba.gz vimball supports the "x" key to execute a file handler for various filetypes.  The file-handling is done in various ways:

    * Under Windows, rundll32 is used with the FileProtocolHandler
    * If unix and kfmclient exists and is executable, it is used
    * If unix and gnome-open exists and is executable, it is used
    * Otherwise, the NetrwFileHandler.vim file handling script is used

With this feature, one may press the "x" key when the cursor is atop a filename and invoke an extension-based file handler to do things like display image files, invoke ghostscript on PostScript files, run OpenOffice or Word, etc.


(alpha/beta version available at http://www.drchip.org/astronaut/vim/index.html#NETRW)
install details
netrw is now distributed as a vimball!  (see :help vimball)
You'll need a vimball plugin v18 or later (see vimscript#1502).
(if you have vim 7.1a or later, you probably can skip this step)

(if you're updating from the vim 7.0 distribution, please remove all runtime plugin/netrw*.vim and autoload/netrw*.vim first)

vim netrw.vba.gz
:so %

and that's it!

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
netrw.vba.gz 150 2014-02-04 7.3 Charles Campbell :Lexplore : toggles a netrw Explorer window on the left hand side of the display -
s-leftmouse : may be used to mark files -
for cygwin: g:netrw_cygdrive can be used to override default "/cygdrive" -
:Ntree : use this command to change the treetop in tree-style listings -
Many bug fixes.
netrw.vba.gz 147 2013-04-16 7.0 Charles Campbell More ways to choose targets for moving/copying files: a "Targets" entry for menus, [count]Th for count-th history, [count]Tb for count-th bookmark; u and U maps now take counts.   Various bug fixes (two fixes for windows users, for example).
netrw.vba.gz 142 2011-05-31 7.3 Charles Campbell g:netrw_winsize's meaning changed!  Now describes percentage of current netrw buffer window to be used for the new window.
Bug fix: NetrwRemoteListing() uses shellescape to handle subdirectories having spaces.
Bug fix: NetrwMethod() attempts to issue an error message when given a malformed url
netrw.vba.gz 141 2011-04-01 7.3 Charles Campbell included -s:... support for Windows ftp
restored 2-leftmouse for :Rex-like return
added balloon help for items in banner
g:netrw_cursor (g:netrw_cursorcolumn is deprecated) supports additional argument values for cursorline and cursorcolumn control in netrw directory listings.
:Texplore starts from netrw's idea of the current directory rather than pwd's
netrw.vba.gz 136 2009-12-29 7.0 Charles Campbell This one is mostly a bugfix release.  There's also
T:  (a new map)  puts the file or directory into a background tab
elinks now uses -source instead of -dump
netrw.vba.gz 135 2009-01-14 7.0 Charles Campbell A bugfix release -- see  :he netrw-history  --
netrw.vba.gz 134 2008-10-23 7.0 Charles Campbell * dav: will use curl if cadaver isn't available
* [N] added to various Explore commands
* bookmarks should now reliably be retained
* various bugfixes (x for remote jpgs, for example)
netrw.vba.gz 133 2008-09-03 7.0 Charles Campbell [*] security improvements (you'll need vim 7.2 for this version)
[*] uses cursorline for thin/long/tree listing styles
[*] currently trying elinks for http -- comments, please!  I have one dislike so far, so it may be changed back in the future.
[*] various bug fixes
netrw.vba.gz v128 2008-07-30 7.0 Charles Campbell Needs fnameescape() and shellescape(), so you'll need an up-to-date vim with this one: vim v7.2b or later.
netrw.vba.gz 123 2008-03-28 7.0 Charles Campbell Marked files now keeps a "global" marked file list.  The global marked file list is used to support tag processing and vimdiff'ing.
Several bugs fixed and security enhancements.
netrw.vba.gz 122 2008-02-26 7.0 Charles Campbell Mainly a bugfix release (sorting sequence improvements).
netrw.vba.gz 121 2008-02-12 7.0 Charles Campbell Bugfixes: netrw attempts to retain the alternate file.  v120 broke an explicit :Explore dirname ; fixed.
netrw.vba.gz 120 2008-02-09 7.0 Charles Campbell Marked file system extended (mt, mh, mu, ms) and bugs removed.  One may now have multiple tree listings.  Bugfix: P works with trees.  Changed q -> qb for query-bookmarks, qf added to provide information about file under cursor.  Explore now has four special listing modes: */filepat, *//filepat, **/pattern, and **//pattern.  gh is now a shortcut for toggling hiding of files and directories which begin with a dot.  The menu now includes entries for Explore.
netrw.vba.gz 118 2008-01-07 7.0 Charles Campbell Netrw has some bug fixes: with :Explore c:/path/, spaces in directory names with s:NetrwOptionRestore(), and with P
netrw.vba.gz 116 2007-12-12 7.0 Charles Campbell bug fixes -- removed some unnecessary directory refreshes, and this version does a better job of retaining user options when editing files under the aegis of netrw's browser
netrw.vba.gz 115 2007-11-08 7.0 Charles Campbell * New: :Explore handles path/**/filename
* Bugfixes: (shellslash use improved, remote editing of *.tar.gz and *.tar.bz2, sourcing remote files via ftp, etc)
netrw.vba.gz 114 2007-10-02 7.0 Charles Campbell mT now supports generating tags files for remote marked files
Netrw's menus are New&Improved!
netrw.vba.gz 113 2007-09-27 7.0 Charles Campbell New: the "x" command has been extended to use Mac OS/X's open facility

Bugfix: cursor position restored after deleting or renaming files
Bugfix: ftplugins, autocmds, etc can change settings after netrw opens a file
Bugfix: strlen() -> s:Strlen(), which handles utf-8 characters better
netrw.vba.gz 112 2007-09-04 7.0 Charles Campbell Added mx (|netrw-mx|) for executing arbitrary commands on marked files
Added the :NetrwClean[!] command
Bugfix: 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:").  The formatoptions, for example, is saved & restored.
netrw.vba.gz 111 2007-08-15 7.0 Charles Campbell Included a "marked file" system: one may mark files (with mf or shift-leftmouse); one may then rename, delete, obtain, compress/decompress, and create tags with the marked files.

A double-clicked leftmouse (in gvim) will return one from a file to the netrw browser buffer used to edit it.

And, some bug fixes!
netrw.vba.gz 110 2007-06-20 7.0 Charles Campbell New Features:
* added [ and ] maps to NetrwTreeListing (bounce across open directories)
* preview window may be shown vertically as well as the default horizontally

Bug Fixes:
* g:netrw_shq more consistently used to support "x" for special file browsing
* more [Scratch] buffers are now named properly
* c mapping now works when directory names have spaces
* options retained in original buffers after a split + :Explore
* Fixed remote file deletion/renaming (again)
* Using <leftmouse to a non-netrw window was causing an error message
netrw.vba.gz 109 2007-05-08 7.0 Charles Campbell One may select an error/message window vs echoerr messages
Various bug fixes (scp -P and ssh -p for ports, Explore attempts to expand $name)
netrw.vba.gz 108 2007-03-21 7.0 Charles Campbell Netrw now supports sourcing remote files and supports preview (with a "p").  Numerous bug fixes.  Works with Microsoft-based ftp servers.
netrw.vba.gz 107 2007-01-03 7.0 Charles Campbell (browser) tree display mode
(browser) amiga supported
numerous bug fixes
netrw.vba.gz 104 2006-09-14 7.0 Charles Campbell * NEW: netrw now has a tree listing style (see :help g:netrw_liststyle)
* MOD: as suggested by Rodolfo Borges, :Explore and variants will position the cursor on the file that had just been edited
* MOD: changed default g:netrw_sort_sequence order
* MOD: changed b, Nb to simply mb  (make bookmark)
* MOD: changed B, NB to simply gb  (goto bookmark)
* MOD: attempts to retain the alternate file
netrw.vba.gz 103 2006-08-31 7.0 Charles Campbell "t" now opens tabbed windows for the file under the cursor, plus numerous bug fixes!
netrw.vba.gz 102 2006-07-24 6.0 Charles Campbell new stuff: g:netrw_menu support included; :Texplore command implemented; <leftmouse> acts as a <cr> for selecting a file; <rightmouse> acts as a <del> for deleting a file
bugfixes : g:netrw_keepdir==0 had stopped working; NetOptionSave/Restore now saves/restores the unnamed register; NetSplit and (Local,Net)BrowseChgDir() were both splitting windows.  This affected o, v, and g:netrw_browse_split; works around wildignore setting
netrw.vba.gz 100 2006-06-08 7.0 Charles Campbell - numerous bug fixes addressing problems with Windows lacking cygwin
- user NFH_*() functions were being unused inadvertently
- [NP]Explore */pat and **//pat now wrap
- Bookmarks and History added to menu
- g:netrw_shq has a better default, and is tunable by the user
- bugfix: hiding pattern candidate separators included some characters it shouldn't have (tnx to Osei Poku)
netrw.vba.gz 99 2006-05-12 7.0 Charles Campbell Since the vim 7.0 release:
  g:netrw_browse_split=3 for opening files in new tabs implemented.
  deletes temporary file at end of NetRead()
  visual mode based Obtain implemented for remote systems.
added -complete=dir to the various Explore commands

netrw.vba.gz 93 2006-04-25 7.0 Charles Campbell :Explore */pattern implemented - search for files containing a pattern in the current directory
:Explore **//pattern implemented - search for files containing a pattern in the directory and subdirectories
Moved DrChip.Netrw menu to a top-level Netrw menu, with priority 80
bugfix - :Nexplore or :Pexplore, issued without first having done an Explore now gives an appropriate error message
bugfix - removed FocusGained event from causing a slow-browser refresh for Windows
bugfix - now handles spaces in filenames and directory names when using ftp-based browsing
netrw.tar.gz 81 2006-03-15 6.0 Charles Campbell ShellCmdPost and FocusGained used to refresh local browser directory listings when g:netrw_fastmode <= 1.
netrw.tar.gz 79 2006-03-09 7.0 Charles Campbell * directories now displayed with nowrap
* g:netrw_fastbrowse introduced, allows for control of speed vs always-obtain directory listing
* bugfix with wide listing, column width < largest filename hangup
* semi-colons should now work with temporary files
netrw.tar.gz 77 2006-01-26 6.0 Charles Campbell New stuff!
g:netrw_browsex_viewer implemented.  NetBrowseX does better at figuring out whether KDE or gnome is actually being used.
Use the "P" map to edit a file/directory in the previously used window (like Explorer's O)
Use g:netrw_browse_split to specify horizontal/vertical splitting of the window when editing a file from a browser window
Some bugfixes, too!
netrw.tar.gz 74 2005-10-19 6.0 Charles Campbell (vim v7.0 req'd)
* Reads remote zip&tar files.
* netrwSettings now uses autoloading
* Many bugfixes (ctrl-L, ch==1 Hit-Enter, W95's E121, etc).
* And more! (see :help netrw-history)
netrw.tar.gz 68 2005-09-01 6.0 Charles Campbell Netrw now takes advantage of autoload (and requires 7.0).
"i" now cycles between thin, long, and wide listing styles.
"O" now obtains a file: remote browsing file -> local copy.
Double-click-leftmouse selects word under mouse.
Netrw now works around the report setting.
Passwords which contain blanks will now be surrounded by double-quotes automatically.
Netrw now seems to work with a few more Windows situations.
netrw.tar.gz 62 2005-08-15 6.0 Charles Campbell Document upgrade - :NetrwSettings command allows easy editing and review of all netrw variable settings
Bugfix - Concurrent Explore **/pattern searches allowed

Last vim 6.3 release (unless a major problem appears); future ones will be 7.0 only
netrw.tar.gz 60 2005-08-11 6.0 Charles Campbell Vim 7.0 only:
* "Match # of #" indicator for Explore **/*.c
* :Explore **/*.c  will now work from a non-netrw-browser window
* :Explore **/patterns can now be run in separate browser windows

Vim6.3 and Vim7.0:
* active banner (hitting <cr> in banner region will cause various things to happen)
* bugfixes
netrw.tar.gz 58 2005-08-05 6.0 Charles Campbell * Explore and relatives can now handle **/pattern (v7)
* Nexplore and Pexplore introduced (v7)
* Various bugfixes
netrw.tar.gz 56 2005-08-01 6.0 Charles Campbell Netrw now avoids changing directory when g:netrw_keepdir is false
Netrw's LocalBrowse() now bypasses the autochdir option
Netrw now uses vim's rename() instead of system + local_rename variable
-bar used with :Explore :Sexplore etc to allow multiple commands to be separated by bars
browser listings now use the "nowrap" option
browser: some unuseful error messages now suppressed

If you're using vim7, you need to have an up-to-date one supporting the sort command.
netrw.tar.gz 54 2005-03-09 6.0 Charles Campbell * <amatch> used instead of <afile> in the transparency support (BufReadCmd, FileReadCmd, FileWriteCmd)
* For backwards compatibility, Explore and Sexplore have been implemented.  In addition, Hexplore and Vexplore commands are available, too.
* ***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
* backslashes as well as slashes placed in various patterns (ex. g:netrw_sort_sequence) to better support Windows
netrw.tar.gz 51 2004-10-08 6.0 Charles Campbell FileWriteCmd event used (supports :[range]w url) supports directory history stack, automatic cygwin use detected (windows), error messages remain visible, bug fixes
netrw.tar.gz 48 2004-09-10 6.0 Charles Campbell Many things (see :help netrw-history), including:
remote browsing with ftp, bookmarks, nrml/hide/show, improved x, bugfixes, alt-o/v, preview
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
SourceForge.net Logo