How to edit FTP files with VIM and avoid typing the hostname everytime

ftpsyncvim

I need to edit remote files with vim, that are on a FTP server. THere's no SSH or SFTP access. Just FTP. I've tried syncing via curlftpfs, the files appeared in a local dir, but i cannot write to them, i get all sorts of errors, and when i manage to write files with random endings are generated on the server. index.php writes on server as index.phz, index.phy, etc…

I had sublime text 2 installed but cannot run it anymore after i installed new drivers for my graphic card. I've also tried n++ with WINE but no luck in openeing FTP files that are in a deeper directory level.

I've seen there are various approaches with vim to edit files on the FTP, but every single one needs typing like :e http://[user@]machine/path (with netrw plugin). I would really like to avoid anykind of repetition, rather set up a relative mapping. It's strange that there's not solution for vim since its a developer's tool mostly, sublime and npp already have that solved in a simple manner. typing on and on the same hostname/path etc. would break a simple DRY principle.

Idealy would be if i could cache the files locally with some syncing tool, and upload them to ftp mapping the path local -> remote, right after vim writes to a file, or i issue an upload command etc (without having to type file opened every time). There are plenty of files on the server so i cannot memorize them, It's important for me to have them cached locally so that i can access them fast and upload with a simple command.

I'm running Slackware 13.37 x64

Best Answer

You can use netrw to display the content of a remote directory with:

:e ftp://user@domain.com/ <-- note the slash at the end.

from there you can open a file in another window with P or in the current window with <CR>.

Don't panic if you loose the file listing: it's still there and you can get it back with :Rex.


Or simply use a GUI FTP client like Filezilla or gFTP and its "Edit in…" feature.

Related Question