Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?


Hello all,

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?

Thanks!

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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

It seems like your makefile (stdout/stderr) output triggers the default quickfix mode of your vim.

Perhaps /some/other/dir/source.his compiled by your recursive make call and a warning is produced and the quickfix mode jumps to its location. Or the filename is part of other makefile output and the quickfix mode mistakes it for a warning/error message of the compiler.

You can try to disable the quickfix mode for your session (if you don't need it), change the error format or change your makefile to generate less output.

share|improve this answer
    
Hmm, well /some/other/dir/source.h is definitely compiled by the make, and warnings are common so I will look into it. I'll be sure to report back. Thanks! –  Mr. Shickadance Mar 2 '11 at 15:00
    
Looks like you are correct, I just tried a make and it opened up my copied header file right at the line of the first warning. I like the features, like :cl to list build errors, however I find automatically bringing up the infringing file cumbersome. Now I need to see if I can disable this single feature, because I believe things like :cl are part of quickfix, no? –  Mr. Shickadance Mar 3 '11 at 13:52
    
Marking this answer -- looks like I need to simply read more into quickfix, as I think it will be difficult to get the behavior I want. Thanks! –  Mr. Shickadance Mar 3 '11 at 14:14
    
@Mr. Schickadance, after doing a bit checking on your own, you can post a new question regarding this specific behavior –  maxschlepzig Mar 3 '11 at 20:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.