I would like to run :make in Vim, while also allowing the user to edit a file while we're waiting for the compilation to finish, then when the compilation is finished open the result in a split window (which I know by itself would be done with :make | copen) with how long it took for the make to run (preferably in a human-readable format, e.g., 5m 32s instead of 332s). Is this possible? I'm guessing using the UNIX time command I could edit my Makefile to do the time measurement, but does Vim have the ability to time the make command itself?

  • Vim cannot do things asynchronously, so AFAIK this is not possible without a heavy workaround. Something like call make manually in a background shell, output results to file, start a timer that continually looks for the file and opens it in in a new window. Even this won't have all the benefits of actually calling :make though (Like being able to jump to errors and such).
    – Tumbler41
    Commented Mar 29, 2017 at 16:58

1 Answer 1


It's possible, with Vim8.

  1. First you'll need to register the current time with reltime() function.
  2. Then, start a job that'll run the content of &makeprg with $* replaced with the target you wish to used (it may be an empty string). Don't forget to register a hook that'll listen for any line produced by the compilation. You'll certainly wish to add it to :caddexpr.
  3. And also, you'll have to register the close callback. In this one you'll know whether the compilation has succeeded, and you'll compare the new reltime() with the registered one.

Note: that while I don't display the compilation time in lh-vim-lib+build-tools-wrapper, it's easy to add (actually I display it when we put the lh/btw/job_build.vim autoload plugin in verbose mode).

  • 1
    I'm not an advanced Vim scripter, so I have no idea how to do step 1, 2 or 3. Could you boil it down to a set of commands or additions to my ~/.vimrc?
    – Josh Pinto
    Commented Mar 30, 2017 at 7:38
  • First hit in a Google search: github.com/djmoch/vim-makejob
    – Vitor
    Commented Mar 30, 2017 at 10:35
  • @Vitor That creates a split window during the build process but it doesn't show it after the build is completed (i.e., as soon as the build is completed it closes the compilation split window), nor does it show the compilation time.
    – Josh Pinto
    Commented Mar 30, 2017 at 10:45
  • @Brenton Horne. The thing is that a correct solution will take a couple hundred lines -- see my third link. This is not something that fits nicely in a vimrc. If you're not afraid of big plugins I can add an option in my build-tool-wrappers plugin to display the compilation time even in non verbose mode. Commented Mar 30, 2017 at 10:56
  • @LucHermitte That option in your plugin sounds great, please. If it works I'll be happy to accept this answer.
    – Josh Pinto
    Commented Mar 30, 2017 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.