Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running :make from gVim in Background

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.

like image 719
Amjith Avatar asked Mar 20 '09 14:03

Amjith


4 Answers

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

like image 63
Mykola Golubyev Avatar answered Nov 20 '22 00:11

Mykola Golubyev


Have a look at @tpope's dispatch.vim

https://github.com/tpope/vim-dispatch#readme

Video Trailer: http://vimeo.com/63116209

like image 8
noahlz Avatar answered Nov 20 '22 00:11

noahlz


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.

like image 7
idbrii Avatar answered Nov 20 '22 00:11

idbrii


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).

like image 4
Rook Avatar answered Nov 20 '22 01:11

Rook