Re: run make! from subdirs
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
Re: run make! from subdirs
Hello, 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. You can use plugins like project.vim or local_vimrc [1] to set your 'makeprg' when the current path is under your ProjectDir. The typical setting for &makeprg would be cd /abs/path/to/ProjectDir ; make $* [1] http://hermitte.free.fr/vim/ressources/vimfiles/plugin/local_vimrc.vim HTH, -- Luc Hermitte http://hermitte.free.fr/vim/
Re: run make! from subdirs
Hi Ilia, to me it looks like you always want to compile using the Makefile in ProjectDir. I don't know if this helps much, but I would recommend to open the Makefile in one buffer, then hide it: :hid and do your source editing. When you want to compile your files, use :sb Mak to switch to the Makefile in a split window and start :make as usual. After compilation, you can hide the Makefile again and continue working. An alternate way would be to change your make command as James proposed. Or you could write a macro to change to the directory and run make :help macro Cheers, Wolfgang 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...
Re: run make! from subdirs
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
run make! from subdirs
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... -- God bless you! Ilia 2.6.19-gentoo-r5 AMD Athlon(tm) XP 2600+ mailto: [EMAIL PROTECTED] icq: 198233378 VegaTrek Developer: http://wcuniverse.sourceforge.net/vegatrek/ VegaTrek Forum Moderator: http://vegastrike.sourceforge.net/forums/viewforum.php?f=13 You know you're using the computer too much when: you almost every night have a dream about an neverending emerge, and you dont have a clue about what's beeing emerged. -- geniux $gpg --keyserver cryptonomicon.mit.edu --search-keys tillias