On 2/20/07, Ilia N Ternovich <[EMAIL PROTECTED]> wrote:
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...
Setting VIMINIT to something like:
source $HOME/.vimrc | autocmd BufEnter * :cd $PROJECTROOT
should do the trick. You can either define a shell function to
turn this on and off, or use an alias (or a simple shell script)
to invoke vim with something like:
VIMINIT="source $HOME/.vimrc | autocmd BufEnter * :cd $PROJECTROOT" vim $@
so you have a general command vim, and a project specific
command projectvim (or whatever).
Alternatively, you can define a shell script pmake (for project
make) which does the cd, then executes the real make. Then set
makeprg=pmake.
--
James Kanze (GABI Software) email:[EMAIL PROTECTED]
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34