Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use GVIM to edit a remote file?

I use GVIM on Ubuntu 9.10. I'm looking for the right way to configure GVIM to be able to edit remote files (HTML, PHP, CSS) by for exemple ftp.

  • When i use :e scp://username@remotehost/./path/to/file i get: error detected while processing BufEnter Auto commands for "*":E472: Command failed.
  • When i open a file on remote via Dolphin or Nautilus, i cannot use other files with NERDTree.
  • Finally when i edit on remote a file via Dolphin the rights are changing to access interdit.

So how to use GVIM to edit remote files like on my localhost?

like image 577
LaTulipe Avatar asked Jan 25 '10 22:01

LaTulipe


1 Answers

I've found running the filesystem over ssh (by means of sshfs) a better option than having the editor handle that stuff or running the editor itself over an ssh tunnel.

So you need to

apt-get install sshfs 

and then

sshfs remoteuser@remotehost:/remote/path /local/mountpoint 

And that will let you edit your remote files as if they were on your local file system.

To make it even smoother you can add a line to /etc/fstab

sshfs#remoteusername@remotehost:/remote/path /local/mountpoint fuse user,noauto 

For some reason I find that I have to use fusermount -u /local/mountpoint rather then just umount /local/mountpoint when experimenting with this. Maybe that's just my distro.

Recently I've also noted that the mounting user must be in the fuse group. So:

sudo addgroup <username> fuse 

An other popular option of course, would be to run vim (rather then gvim) inside a GNU Screen session on one machine and connect to that session via ssh from wherever you happen to be. Code along all day at work and in the evening you ssh into your office computer, reattach to your gnu screen session and pick up exactly where you left off. I used find the richer color palette to be the only thing I really missed from gvim when using vim, but that can actually be fixed thanks to a fork of urxvt that will let you customize the entire 256 position color palette, not just the 16 first positions of the palette that most terminal emulators will let you customize.

like image 158
oivvio Avatar answered Oct 27 '22 10:10

oivvio