在不退出Vim的情况下在不同目录中调用Makefile

Shi*_*bli 4 vim makefile

参考下面的结构,假设我在/test目录中,我打开了vim main.cpp.运行:make会调用/test/Makefile.现在我也做了,:edit ../src/foo.cpp并在这里做了改变.我想运行make/Makefile创建共享库/lib.如何make/Makefile不退出Vim的情况下继续运行?

project
|  Makefile
|+ lib
|+ include
|- src
    |  foo.cpp
|- test
    |  main.cpp
    |  Makefile
Run Code Online (Sandbox Code Playgroud)

Daw*_*ski 6

赶紧跑:

:make -C path_to_dir_with_your_makefile
Run Code Online (Sandbox Code Playgroud)

地点-C:

-C dir, --directory=dir
        Change to directory dir before reading the makefiles or doing anything else.  If multiple -C options are specified, each is interpreted relative to the previous one: -C / -C etc  is
        equivalent to -C /etc.  This is typically used with recursive invocations of make.
Run Code Online (Sandbox Code Playgroud)