Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When using the delightful netrw support in vim to open a file, opening directly works well, as in

:e scp://hostname//path/to/file

however, you can't change the working directory via

:cd scp://hostname//path/

Is there a way of getting this or equivalent behavior? Key part is I want to be able to use a relative path to edit files.

Please feel free to use scripts or plugins in your answer.

share|improve this question

migrated from stackoverflow.com Aug 28 '11 at 10:00

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

    
what's up with the closes? I thought we'd well established that only us programmers use vim. this question may very well involve scripting in its answer too! – Peter Aug 27 '11 at 17:06
2  
don't worry, from time to time people vote to close on Vim questions. If closed, we'll reopen it. And for reference, here is the link to the Vim discussion on meta. – sidyll Aug 27 '11 at 17:11
up vote 3 down vote accepted

The concept of current directory is a property of a process. Since your vim process and the process at the other end of the scp are different, there is no way to effect its notion of the current directory. That said,

  • scp likely starts with a current working directory of the user's home directory. Things like scp user@host:txt/foo.txt . usually do the right thing.
  • Set a vim or environment variable to scp://hostname//path/ and then use :e $var/file. Details how to do this left as an exercise :-)
  • Folks on usenet newsgroups like comp.editors know all about vim.
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .