2

Is there a way that I can have the :make command output itself to a terminal window in vim? In the 8.1 release, they added the :term command, which allows you to run an external program in a vim window. I was wondering if there's some way to combine the two.

I want this because i use vim-latex for compiling my .tex files (which compiles using :make), and it would actually be helpful for me to be able to deal with errors and stuff while still in vim.

5
  • 3
    "it would actually be helpful for me to be able to deal with errors and stuff while still in vim." Do you know that that quickfix list is populated with the output of :make? You can bring up the quickfix window via :copen. See :h quickfix for more information. Jun 28, 2018 at 13:14
  • @PeterRincker tex has you deal with errors interactively
    – A Gold Man
    Jun 28, 2018 at 14:15
  • are you using -interaction=nonstopmode? does vim-latex not set this by default?
    – Mass
    Jun 28, 2018 at 15:22
  • 1
    Even though this is old: the answer to the comment of @mass is: vim-latex sets -interaction=nonstopmode. This can be checked with :verbose set makeprg which returns makeprg=pdflatex -synctex=1 -interaction=nonstopmode -file-line-error-style $* Last set from ~/.vim/pack/manual/start/vim-latex/ftplugin/latex-suite/compiler.vim. So the comment of Peter Rincker is also helpful.
    – Hotschke
    Oct 1, 2018 at 16:13
  • 1
    @AGoldMan: Have you noticed this paragraph in the help file of vim-latex?
    – Hotschke
    Oct 1, 2018 at 16:15

3 Answers 3

1

On windows gvim only, you can use set guioptions+=! to run make in a terminal. This isn't yet supported on other platforms so you will have to find an alternative.

If you want to create a new terminal each time,

command -nargs=* Make execute 'terminal' &makeprg.(empty(<q-args>)?'':' '.<q-args>)
2
  • Does your second suggestion still populate the quickfix list?
    – A Gold Man
    Jun 28, 2018 at 14:58
  • No, that would take some work. I'm a bit confused whether you want interactivity like in the terminal or non-interactivity like in the quickfix.
    – Mass
    Jun 28, 2018 at 15:21
1

Not exactly what you asked for (using the terminal new vim 8.1 feature) but you should check asyncrun plugin which let you execute whatever you want asynchronously and get the output in quick fix (using errorformat to parse the output...). asyncrun.vim

0

Assuming you have a bash-like shell, you can put this in your .vimrc:

command! -nargs=? MakeInTerminal silent call s:MakeInTerminal(<q-args>)

function s:MakeInTerminal(args)
  const l:cmd = expandcmd(&makeprg) .. (a:args == '' ? '' : ' ' .. a:args)
  const l:options = {'term_name': '!' .. l:cmd}
  call term_start([&g:shell, &g:shellcmdflag, l:cmd], l:options)
endfunction

Then you can run make in a terminal with :MakeInTerminal. See also a more complete solution.

Your Answer

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

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