I would like to have a keyboard shortcut to

  • run mypy on the current buffer
  • put the output in the QuickFix window

I only want mypy to run and populate the QF window on demand, not constantly. I do have ALE installed, but I've not been able to a) limit the QuickFix window to only mypy output b) be able to run it on demand and c) not have ALE populate the QF window with mypy comments when I'm using the QF window for other things.

Any help or pointers would be much appreciated.

  • Do you still have something open in your question? How can we help you further? Otherwise maybe could you accept one of the answer using the v button next to the arrow voting buttons. It allow the question to rest :-) Commented Feb 3 at 15:52

2 Answers 2


I would do:

Create a ~/.vim/compiler/mypy.vim file with the following content:

set makeprg=mypy

In your python session you can activate the compiler with the following command:

:compiler mypy

More information with :help :compiler`

The compiler mypy command will run the mypy.vim file and set the make options to use the mypy compiler.

To check the current file you can then do:

:make %

The make command run the tool configured in makeprg and populate the quickfix list based on the output using the errorformat to identify the relevant information (file name, line number, error message).

More information with:

Like @Friedrich mention you can associate the make % to a shortcut with:

nnoremap <F7> <cmd>make %<cr>
  • OP asked for a keyboard shortcut, that would be e.g :noremap <F7> <Cmd>make %<CR>
    – Friedrich
    Commented Jan 30 at 9:32

Thank you, really helpful. What I ended up doing, inspired by @Vivian De Smedt's answer, was:

In .vimrc

autocmd BufRead *.py set makeprg=mypy
nnoremap <leader>m :silent make %:S <Bar> copen<CR>

In pyproject.toml:

error_summary = "False"

That does exactly what I need. Thank you for the help.

  • 3
    If you found Vivian's answer helpful, consider upvoting it. That's how we say "thank you".
    – Friedrich
    Commented Jan 30 at 12:39
  • 2
    Welcome to Vi and Vim! Self-answering is 100% fine; when your self-answer builds substantially on another user's answer, it is best to link to that answer. Upvotes can and should be used to indicate technical accuracy and quality in the answer (the fact that you were able to make good use of the answer is a positive indicator). Please vote!
    – D. Ben Knoble
    Commented Jan 30 at 14:16

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.