How to efficiently “make” with Vim

后端 未结 6 400
栀梦
栀梦 2020-12-06 05:07

What I am trying to do seems a very basic stuff, but I can\'t find anything about it. I am working on a project built as usual:

project
|-- bin
|-- inc
`-- s         


        
6条回答
  •  攒了一身酷
    2020-12-06 05:16

    Slight modification of what Adam said:

     :set makeprg=[[\ -f\ Makefile\ ]]\ &&\ make\ \\\|\\\|\ make\ -C\ ..  
    

    Unescaped, this is

     [[ -f Makefile ]] && make || make -C ..
    

    which means, pseudo code style

     if file-exists(Makefile) 
     then make
     else make -C ..
    

    This only goes one directory up. If you'd like a more general solution that will go as many directories up as necessary, you'll need to be able to search ancestor directories until a Makefile is found, and I'm not sure how to do that simply from the command line. But writing a script (in whatever language you prefer) and then calling it from your makeprg shouldn't be hard.

提交回复
热议问题