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 compilation is complete. How can I do :make asynchronously and still get the benefits of reading the errors back into Vim and jump to the errors in source code? Bonus points if I get to see the make process in real time. Right now the :make redirects the output into a file, hence I don't get to see the progress of make.
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
Have a look at @tpope's dispatch.vim
https://github.com/tpope/vim-dispatch#readme
Video Trailer: http://vimeo.com/63116209
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With