I am trying to get VIM to run the right makefile for a specific source file. For example, if the current file is ui8_c_buff_test.cpp
and if I use the makeprg
configuration below and run make
,
let &makeprg = 'make -f '.fnameescape(substitute(expand('%'), '\m_test\.cpp$', '.makefile', ''))
the system should run against the ui8_c_buff_test.cpp
and execute make -f dispatcher/unittest/ui8_c_buff.makefile
, but it is running against the .vimrc
file where the makeprg
is set, and I get the following result:
/home/sporty/.vimrc:1: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.
But if I run the following command,
:echo 'make -f '.fnameescape(substitute(expand('%'), '\m_test\.cpp$', '.makefile', ''))
I get a correct result, which is:
make -f dispatcher/unittest/ui8_c_buff.makefile
So how can I get the makeprg to run against the current file instead of .vimrc?
I asked a question here: Determining makefile based on source file name, and got an answer, but most of the time it does not work.