OK, I posted this question before I knew the extent of what was happening. Suppose I have a mix of Python and C++ code. I use a simple makefile which copies the files from my editing directory to where they are compiled (with a separate makefile.
my_stuff: cp source.c source.h /some/other/dir pushd /some/other/dir; make && su -c "make install"; popd
Originally I was editing source.c, running :make, and then a new buffer opened in my current window (replacing source.c) with /some/other/dir/source.h. I then tried this again while editing some_python.py and running :make and yet again it opened /some/other/dir/source.h. Can anyone explain this? Am I going crazy?
I am having this annoying issue with Vim. I like the fact that I can be editing a file and then type :make to automatically execute a Makefile in the same directory. However, Vim is changing my directory after it is executed. For example, if my source file is /some/dir/source.c and it needs to be compiled in /some/dir/library/, my makefile first copies the file to the library folder and then executes another makefile.
move_files: cp /some/dir/source.c /some/dir/library/ pushd /some/dir/libary/; make && su -c "make install"; popd
The problem happens after compilation finishes. If I launch vim as 'vim /some/dir/source.c' and then use :make, when the compile finishes I am looking at '/some/dir/libary/source.c'. I would like to be looking at the file in the original location.
Does this make sense? What can I do to disable this behavior?
UPDATE I was mistaken before -- when the make completes, a new buffer is opened in my window which has the copied header file (even if I was editing the .c before the compile). So I open /some/dir/source.c, then do :make, then in my current window a new buffer is opened with /some/dir/library/source.h. Weird? The original buffer is still open, but I need to switch back to it since its now in the background.