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 have a large project, and I have to work in and switch between a few directories often. My solution was to symlink all the files that I want to get to quickly into a sandbox directory.

I just used the command:

mklink sandbox/myfile.py somerealdirectory/myfile.py

I want to simply be able to use vim's

:e myfile

without having to worry about the directory structure.

If I open sandbox/myfile.py in vim, make some edits, and save, the changes propigate as expected.

However, when I try to write a second time, vim complains that the file is readonly, and now it no longer will write to the correct file. It looks like the symlink was destroyed during the writing process.

I've seen some other issues about this, but no satisfactory answers.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You shouldn't need to do that kind of horrible hack.

Vim uses a special wildcard for "any subdirectory": **. Supposing your working directory is /path/to/project and you don't have autochdir on, you can list and choose any file containing foo in its filename, wherever it is under the working directory, with:

:e **/foo<Tab>

which would propose:

/path/to/project/dir1/dirb/foo.js
/path/to/project/dir1/dirb/dir5/dirx/barfoo.js
…
share|improve this answer
    
Wow, how useful. Thanks. –  Erotemic Apr 14 '13 at 19:58

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.