Is there any way to use an interactive interpreter as the makeprg? I want the interpreter to stay interactive after invoking :make.

For example, if I wanted to invoke python on the current file and stay in interactive mode, I would imagine that :set makeprg=python\ -i\ % would do what I wanted, the -i argument telling python to stay in interactive mode after running a script. However if I run a small python script like this vim just prints out the python command prompt (>>>) and then returns me to the editor.

  • 1
    I am not sure :make is going to be the proper fit here. Have you thought about using :terminal (NeoVim and Vim 8)? Commented Jan 15, 2018 at 15:08
  • ah, nice. I'm in neovim and :terminal python -i % does what I want.
    – felixgb
    Commented Jan 15, 2018 at 15:30
  • well, kind of. Still trying to compose it with the behavior of :make. In effect I want to run :make, and if the make command succeeds, run :terminal python -i %. If :make does not succeed, do the normal make behavior (quickfix list etc)
    – felixgb
    Commented Jan 15, 2018 at 15:37

1 Answer 1


You can run :make to lint and then run :terminal if there are no errors.

command! -nargs=* -bang -complete=file_in_path PythonMake call <SID>PythonMake("<bang>", <q-args>)
function! s:PythonMake(bang, args)
    execute 'make' . a:bang . ' ' . a:args
    if empty(filter(getqflist(), 'v:val.valid'))
        execute 'terminal python -i %'

Note: I have not tested this code in any way nor do I use NeoVim.

The idea is to use :make then check for any valid errors (valid key) which is returned by getqflist(). If no errors then run your :terminal command with the current buffer's filename, %.

For more help see:

:h :command
:h :make
:h getqflist()
:h filter()
:h empty()
:h :terminal

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.