I’m a recent vim convert (from fancy IDEs like eclipse.)
I love the :make command in vim and use it extensively; however I also like to edit multiple projects (with separate makefiles.)
So usually to edit more than one project I will do
pushd project1
vim project1.cpp
[suspend signal]
pushd ../project2
vim project2.cpp
and now I can switch between the two projects with ctrl+z i.e. suspend signal, and fg.
When this becomes an issue is when I want to open one project in the context of another so I can do copy/pasting. So if instead in the above I do
pushd project1
vim project1.cpp
:vsp ../project2/project2.cpp
I can edit both concurrently in the same vim process, however I can’t effectively build one or the other with the :make command, it will only build project 1.
Does anyone have some kind of scheme that gives them the best of both worlds: being able to edit concurrently while still being able to build multiple projects with the :make command all from the same vim process?
Are the make commands you want to execute the same for each? So the problem is just the current directory? You can use
:lcdto change the directory only for the current window, so that it will run in the appropriate directory for each. To make this more automatic, you could set up an autocommand (onBufWinEnter, I think) for when you create that split window to run:lcd expand('%:h'), or just map a key to that if you don’t want to always do it.(You could also map a key/create a custom command for a combination of the
lcdandmake, probably saving keystrokes but then unnecessarily cd’ing before each make. Not that that takes long.)P.S. The reason I asked if the make commands were the same is that you can actually set
makeprgand other associated options locally (use:setlocalinstead of:set).