This is a draft, quarantined as a subpage of my own userpage until (and if) it is ready to face the world. Feel free to edit it.
This tip is based on an ongoing mailing list discussion. It will not reach maturity until this discussion is ended.
The aim of this tip is to allow you to do the following (copied from mailing list):
- From vim, run :shell .
- Find the files you're after.
- Open these in the vim session you ran :shell from.
A server-based approach Edit
If you have a client-server enabled vim (run vim --version and look for '+clientserver'), you should be able to do the following:
- Start vim using the following command: vim --servername VIM1
- During your vim session, type :shell to get a shell (or C-z to send vim to the background).
- Add files using vim --servername VIM1 --remote [files]
- Exit shell (or use fg to send vim to the foreground).
An example session:
$ vim --servername VIM1 $ :shell $ cd foo/ $ vim --servername VIM1 --remote *.txt $ exit
Note: I did not really get this to work on my computer, but it is copied from the mailing list, and probably should. Experiment and let me know.
A simple file-based approach Edit
If you can create a file containing a list of the files you need, you can easily open them in vim using any of the commands described in the "Open files from list file" tip.
If the files are in a directory other than vim's working directory, you will need the files to be listed using their full paths. In *nix environments, the command to get a file's full path is readlink -f.
The procedure for getting a shell is as above, and an example session might be:
$ cd foo/ $ >~/.x readlink -f bar.txt $ >>~/.x readlink -f bar2.txt $ cd ../foo2/ $ for f in *.txt ; do >>~/.x readlink -f $f; done $ exit
(The '>>~.x readlink -f' bit can be made much simpler using an alias. Also, note that we first use '>' to overwrite a file already in existence, and then '>>' to append to it.)
Back in vim, you may open the files you've used using a file-list opening command (see tip mentioned above), for instance:
A script-based approach Edit