By default, makeprg is set to just make. However, I’ve got a lot of projects where different build configurations and targets reside in the same directory.
This of course necessitates that I specify a target when invoking make.
For example, I’ve got a project that’s set up to build a source file <foo>.cpp by invoking make foo, and the project contains a number of such source files.
How can I achieve that when I’m editing said <foo>.cpp in Vim, makeprg is set to make <foo>? I thought of modelines in each file, but setting makeprg via the modeline is forbidden (due to security concerns?).
Notice that this setting is only appropriate for some projects so I don’t want to modify the general value of make – otherwise I’d just
set makeprg=make\ expand("%:t:r")
(or something like that) in my .gvimrc.
I’m using a plugin of mine that enables project-specific settings to tune that kind of things.
This way my
.vimrcis not cluttered with project-specific things. Instead, in each project root directory I have a_vimrc_local.vimfile that contains my various settings.Another solution would be to encapsulate
:makecall into a another command or a mapping that in turn calls:makewith a variable that you could set with another plugin: let-modeline.PS: the
.gvimrcis meant to contain things specific to the graphical version of vim. By putting your settings into your.gvimrc, plain vim won’t be configured.