I'm doing some work that has to be developed remotely, so I wanted a way to edit locally instead of doing everything in a terminal window. I tried using MacFUSE and sshfs
to make the remote directory appear on my own desktop, and it worked after I figured out the options I needed, but opening files in gvim
was very slow.
So I took my friend Ed Marshall's advice and tried Vim 7's netrw support. Bingo! It works via scp
(which is (almost?) always available when there's ssh
access) and is dreamy.
To edit a file /path/to/file.rb
owned by a user joe
on a machine example.com
:
vim scp://joe@example.com/path/to/file.rb
Brief pause while the file gets retrieved, but then it's copied to your /tmp
directory and everything's full speed. The only downside I ran into was that inter-file navigation wasn't as good. To get a file browser for the files in ~/path/to
, I could then do:
:sp %:h
or to edit ~/path/other_file.rb
(again from a window opened on ~/path/to/file.rb
):
:sp %:h:h/other_file.rb
:sp
means "split window". %
means "the current file". :h
means "the parent directory of the preceding file path", and can be repeated.
I'd love to hear more about navigating in Vim + netrw—I haven't even gotten my feet wet yet. I just wanted to share the nice experience I had right out of the box.