Running :make from gVim in Background

后端 未结 7 1128
失恋的感觉
失恋的感觉 2020-12-01 00:46

I use gVim in windows to edit my code (mostly C++). I use :make in gVim to compile the project, but this is a blocking operation, that prevents me from using gVim until the

相关标签:
7条回答
  • 2020-12-01 01:15

    What I do is

    :!gvim -c 'MyMake'
    

    ( where MyMake is the custom command which can switch to appropriate dir, make, and copen 20. )

    and I am doing my job while build goes in the other window.

    Other option:
    You can redirect make progress to some file from the shell or within vim (:!make&). And then by using

    :cfile make_result_file
    
    :cw
     or
    :copen 20 
    

    Achieve the same result as you'd use :make

    0 讨论(0)
  • 2020-12-01 01:15

    Try using

    :!start make
    

    (more info on ":help !start") - that way vim doesn't have to wait for the process started to finish - you can just keep on going with your editing).

    0 讨论(0)
  • 2020-12-01 01:21

    see this script

    0 讨论(0)
  • 2020-12-01 01:22

    You won't be able to see the progress of make (within Vim) unless you install a very recent version of Vim (v7.4 and many patches, or simply Vim 8). Now there are a few plugins that've taken advantage of it. My BuildToolsWrapper is one of them. I've tested it successfully on linux and on windows.

    Before that we needed other tricks. I remember Marc Weber's plugin which was able to emulate background compilation on Windows. There was a few others. I let others list them.

    0 讨论(0)
  • 2020-12-01 01:24

    I would use your OS's inbuilt methods for running background tasks.

    On windows, try typing

    :!start make
    

    On linux / mac os x, try

    :!make > /dev/null 2>&1 &
    
    0 讨论(0)
  • 2020-12-01 01:29

    Have a look at my AsyncCommand plugin. It's just wraps the vim syntax required to execute something and load it with --remote. I've uploaded AsyncCommand 2.0 that includes an AsyncMake command.

    Add the script to your .vim/plugin and you can build with :AsyncMake or :AsyncMake target. Errors will be opened in your quickfix once the make completes.


    Responding to comment for more readable code:

    To see the build results on Windows, if you have cygwin/unxutils/something with tail in your path, then in asynccommand.vim, change

    call <SID>Async_Impl(tool_cmd, vim_cmd)
    

    to

    call <SID>Async_Impl(tool_cmd, vim_cmd)
    call <SID>Async_Impl("tail -f ". temp_file, "")
    

    That should change all Async commands to open up a second command window with the output.

    0 讨论(0)
提交回复
热议问题