I'm trying to edit a remote file with vim 7.2 using this command ":e scp://username@host//home/oracle/filename.ksh". But I get this error "scp: not found". Then I placed the scp file in home/oracle. But still I get the same error. What am I missing?
Vim/NeoVim is just an editor but it relies on scp and ssh to provide access to remote files. So whenever you can ssh into any Linux box, you can also locally edit the file, while remotely saving that file into the remote server.
Since Vim 6.x the netrw plugin is installed as a standard plugin. So you can edit files via ftp, rcp, scp or http.
For scp
actions is useful to open the file as follows:
vim scp://[email protected]//path/to/document
You get a bunch of information on Vim tips pages.
Depending of your OS software configuration, you can alternately use fuse and sshfs in order to accomplish this.
Packaged as sshfs in most distributions, this makes possible for users (depending on your user permissions policy) to actually mount a ssh location somewhere in the local filesystem.
The command looks something like this (assuming you already installed sshfs):
sshfs <user>@<host>:<remote_location> <local_path>
An example:
sshfs [email protected]:/var/www /mnt/sshfsmounts/www
Doing that, you can safely edit remote files as if they made part of your local filesystem, using
vim /mnt/sshfsmounts/www/index.php
for example.
Some useful links here:
[1] - http://en.wikipedia.org/wiki/SSHFS
[2] - http://fuse.sourceforge.net/sshfs.html
[3] - http://www.linuxjournal.com/article/8904
Be aware of the fact that permissions you will have on mounted ssh filesystem are those applied for the user specified inthe sshfs
command, completed by permissions you have on the local file system for the mount point. This means you basically need to have write access on both the mount point and on the ssh host under specified sshfs user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With