Install vimrc makeprg in custom script if no Makefile

I want the command to :make

run fine if present Makefile

. Otherwise, I want it to execute a custom script, say called compile

. If no file is present I would like it to fail gracefully (ideally not leaving the edit screen).

I am aware of this thread which presents a bash expression that I was able to adapt to suit my needs. EXCEPT I sometimes need to start a shell other than bash. Is there a shell-independent way to do this?


source to share

1 answer


the name of any executable file can be given. Create a shell script that runs make

if there is a Makefile, runs compile

or returns otherwise .



All Articles