:e ftp://ftp.example.net/directory/filename
...
:wq
should download your file from the remote server, edit it, and upload it
back where you got it from (if you have appropriate permissions, and
perhaps a username and password stored in a ~/.netrc file which MUST NOT
be world-readable).
Similarly, with the same permissions and possible username and password,
:enew webpage.htm
...
:saveas ftp://ftp.example.net/folder/webpage.htm
should _create_ a file on the remote site.
The above uses no mappings but a number of autocommands.
Saving the file without a pathname saves it in the _Vim current_
directory which is not necessarily the _latest browsed_ directory. To
save a file locally, you don't need to go through netrw, even if you
earlier browsed the directory using netrw. To check what is the "Vim
current" directory, use the ":pwd" command. (Don't use ":cd" with no
argument because it is not portable: on Windows it displays the current
directory, but on Unix it _changes_ to your home directory.)
When browsing a local directory using netrw, you can make that the
current directory for that window (and its possible future child
windows) using
:lcd %
since the netrw buffer name for the directory-browsing window is the
directory name. (Similarly :cd % to set the vim-global current
directory, which applies to all windows except those [if any] where the
":lcd" command has been used.)
Best regards,
Tony.
--
Am I ranting? I hope so. My ranting gets raves.
I experienced similar problem too. The main point is that if starting
vim with no document. Type something. then :Exp to another directory
and type "c". If :w somefile , then that file will *not* be written to
the directory just "c". Neither :lcd % works because there is no
current file.
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
After I use ":view ~/.build/vim/vim72/src" (which starts the netrw
browser on the src directory containing my Vim source files), ":lcd %"
sets the window's current directory to the directory currently being
browsed. The "current filename" is the name of the current _buffer_,
i.e. the ~/.build/vim/vim72/src directory.
If you are _editing a file_, not _browsing a directory_, then you need
":lcd %:h" if you want to set the current directory to the directory
_containing_ the current file. But netrw is not concerned since the
current window displays a file buffer, not a netrw directory window.
The only case when expand('%') is the empty string is when the current
window is on a [No Name] or [Scratch] buffer. It can never happen if the
_current_ window is a netrw directory browser.
Best regards,
Tony.
--
Equal bytes for women.
c -- this mapping sets vim's idea of the current directory to the
browsing directory. :help netrw-c
g:netrw_keepdir -- by default its 1, so vim's current directory does not
track the browsing directory. If you change it to zero, then that
tracking will occur. This separation between vim's current directory
and the browsing directory is a feature of vim 6.0's explorer and has
been retained because (a) backwards compatibility, and (b) there are
those who prefer it. I myself set g:netrw_keepdir to zero. :help
g:netrw_keepdir
Note that vim's current directory cannot be a remote directory; it must
be a local directory.
So, once you've made vim's current directory what you wish it to be
(there's also the :lcd and :cd commands), a normal :e filename will
suffice to create a file by the desired name in the current directory.
Of course, if you want to make a new file in a remote directory, you can
specify the whole path:
:e ftp://hostname/path/filename
In the most recent netrw (v133) I introduced the "%" command (but it
appears that I forgot to mention it in netrw's history). This command
will query for a filename and open a new file in vim's browsing
directory, including either local or remote directories. If your
version of netrw has it, :help netrw-% should explain it.
If your netrw doesn't have it, then you can get v133 from several
sources. I expect that Bram has updated the runtime files at
ftp.home.vim.org, its available at
http://vim.sourceforge.net/scripts/script.php?script_id=1075 , and its
available at my website,
http://mysite.verizon.net/astronaut/vim/index.html#NETRW .
Regards,
Chip Campbell
Regards,
Chip Campbell