4

Thanks to @muru I was able to run and output the data to QuickRun by the :make command and this setting in my .vimrc:

set makeprg=/vagrant/my_project/app/Console/cake\ test\ app\ Console/Command/FeedParseShell

But I have to press Enter several times to get back to the vim editor and open the output by typing :copen. Is there a way to skip this steps and get the output without typing :copen?

  • 4
    Separate questions, separate posts, please. What happens if you do :silent! make | copen? – muru Feb 16 '16 at 11:06
  • 1
    @muru +1 Again, thank you mate :) silent & pipe does the trick. Only one question remain - how can I run it with FindRootDirectory()? I did create separate question vi.stackexchange.com/questions/6508/… ^^ – whitesiroi Feb 16 '16 at 11:09
2

If you are ok with no stdin functionality, you could use this entry in the Vim wikia page.

command! -complete=shellcmd -nargs=+ Shell call RunShellCommand(<q-args>)
function! RunShellCommand(cmdline)
  let isfirst = 1
  let words = []
  for word in split(a:cmdline)
    if isfirst
      let isfirst = 0
    else
      if word[0] =~ '\v[%#<]'
        let word = expand(word)
      endif
      let word = shellescape(word, 1)
    endif
    call add(words, word)
  endfor
  let expand_cmdline = join(words)
  botright new
  setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
  call setline(1, 'You entered: ' . a:cmdline)
  call setline(2, 'Expanded to: ' . expand_cmdline)
  call append(line('$'), substitute(getline(2), '.', '=', 'g'))
  silent execute '$read !'. expand_cmdline
  1
endfunction

This command is great for running an autonomous command and getting the response in its own scratch buffer. :RunShellCommand cmake test app Console/CommandFeedParserShell I use this for all the other non-make situations when I don't want to write the output to my current buffer (a la :!command).

2

If you are using vim 8 / neovim, maybe you can try asyncrun:

https://github.com/skywind3000/asyncrun.vim

as a replacement to vim-dispatch/quickrun with better user experience and expansibility.

enter image description here

  • Easy to use, just start your background command by :AsyncRun (just like old "!" cmd).
  • Command is done in the background, no need to wait for the entire process to finish.
  • Output are displayed in the quickfix window, errors are matched with errorformat.
  • You can explore the error output immediately or keep working in vim while executing.
  • Ring the bell or play a sound to notify you job finished while you're focusing on editing.
  • Fast and lightweight, just a single self-contained asyncrun.vim source file.
  • Provide corresponding user experience in vim, neovim, gvim and macvim.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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