Timothy Knox wrote:
Somewhere on Shadow Earth, at Fri, Jan 12, 2007 at 03:45:26AM +0100, 
A.J.Mechelynck wrote:
<snip>
Alternately, you can use

        :autocmd BufWinEnter * lcd %:p:h

which will set a "local directory" for each buffer. This alternative only requires +autocmd, which is included in "Normal", "Big" and "Huge" builds of Vim.

Personally, I've tried it, and I've found that I don't like directory changes happening, so to speak, "behind my back". I prefer that directories only be changed when I use ":cd" or ":lcd" explicitly. (YMMV)

Whereas I added that to my .vimrc some time ago, and absolutely love it. On the
other hand, I work on a large software development project with many deep
directory hierarchies (the Real Networks media server, most of the code for
which is open source, so you can see what I mean), and I find it *very* handy to
do something like this:

$ cd server/protocol/transport/rdt/unittest
$ vim ut_rdttcptran.cpp
<from within vim>
:e ../../../tools/unittest/netio/ut_socket.cpp
<later>
:e ut_bufsock.cpp (which is in the same dir as ut_socket.cpp)
<still later, after flipping back to ut_rdttcptran.cpp>
:e ut_rdtudptran.cpp (which is in the same dir as ut_rdttcptran.cpp)

I find that far more convenient than having to constantly remember to preface my
:e with a bunch of "../"'s, but, as noted, YMMV.


I don't use auto-change-dir methods but I will, at times, use the ":lcd" command, either just before loading a new file, or in the form ":lcd %:p:h" after navigating to a new file. Since ":lcd" only applies to the current window, going back to the other window also goes back to the other directory.


Best regadrs,
Tony.

Reply via email to