On 2/20/07, Ilia N Ternovich <[EMAIL PROTECTED]> wrote:
Hi!

Someone noticed that if I add this line into .vimrc:
autocmd BufEnter * :cd %:p:h

I'll be able to run :make and vim will automatically look at the directory
where currently opened file is located for Makefile.

But if I have directory structure like this:

[d]ProjectDir
  main.cpp
  Makefile
  [dir]SrcDir1
         file1.cpp
  [dir]SrcDir2
         file2.cpp

this command do not work. Makefile is located in root ProjectDir and if I
open for example file1.cpp from SrcDir1, vim can't locate Makefile and I
HAVE TO SWITCH TO ANOTHER BUFFER which contains some source from
ProjectDir in order to compile program...

Is there any opportunity to solve this situation. I have to recompile
project very often while debug sessions, and there is really huge dir
hierarchy...

You can map a key to the sequence   'cd PROJDIR | make '
I think this is the simplest solution.

Alternatively, I have in my vimrc a mapping that unsets 'acd'
(which is equivalent of 'autocmd BufEnter * :cd %:p:h') and chdirs
to the directory that was current when vim started (in all windows).

Yakov

Reply via email to