Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

migrated from stackoverflow.com Nov 7 '12 at 20:56

This question came from our site for professional and enthusiast programmers.

add comment

5 Answers

up vote 3 down vote accepted

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.

share|improve this answer
    
I've tried the vim and filezilla method, and the filezilla is much faster than the vim, however if i open more files many new vim windows just makes too much mess. Will give gFTP a try. I just wish i could run sublime again since it beats any of the other ancient methods which make me counter productive :( –  Keeper Hood Nov 7 '12 at 11:21
    
gFTP works like Filezilla: the windows mess is Vim's fault. In both FTP clients, you need to set this command as "editor": "/usr/bin/gvim" --servername filezilla --remote-tab. –  romainl Nov 7 '12 at 11:31
    
Why can't you run Sublime? It works very well on Linux. –  romainl Nov 7 '12 at 11:32
    
It did work, but I've updated some graphics drivers and it crashes on start now, don't wanna go into offtopic. –  Keeper Hood Nov 7 '12 at 11:45
    
The --remote-tab works much better, wondering how can i set the command to add a buffer instead of a tab if i need to? – –  Keeper Hood Nov 7 '12 at 11:54
show 2 more comments

Though you cannot simple use relative filenames (because the local working directory is different), you can use the filename-modifiers to refer to files relatively:

:edit %:h/another.html
share|improve this answer
add comment

I feel you pain, I love to use vim, and with the ftp client, it is almost like you have ssh. The workflow that I use is

  1. Log into the ftp server using the open command :e ftp://username@server/
  2. Create a new tab of the current selection :tab split
  3. Move to the new tab :tabn
  4. Navigate to the file in vim
  5. When you are done editing the file, close the tab :wq
  6. Repeat from step 2

I have found that this works the best.

The tabs in Vim are great, they can allow you to have a number of files and you can even yank y and delete d lines between open files in the same session. Very cool.

share|improve this answer
add comment

If you use vim ftp://hostname/path/ you'll get a directory listing. If you work with this host often, you might want to bookmark it. With netrw v153j, you can use :NetrwMB filename(s); you can use mb to bookmark the current directory; and you can use qb to list the current bookmarks (and history). Bookmarks and whatnot are available via the menu with gvim, too. To go to a bookmark, use gb.

So, I'm suggesting that you bookmark the directory, return to the directory listing via :Rex or gb, and edit the files so listed.

share|improve this answer
add comment

I know this is old, but another option is to use e.g. curlftpfs (Slackware build here) to mount the FTP server to a mount point, then use your local text editor of choice.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.