Skip to main content
1 of 3
3N4N
  • 5.9k
  • 1
  • 21
  • 49

For completeness, I want to present this awesome functions that I collected (stole) from romainl.

" redirect the output of a Vim or external command into a scratch buffer
function! Redir(cmd)
  if a:cmd =~ '^!'
    execute "let output = system('" . substitute(a:cmd, '^!', '', '') . "')"
  else
    redir => output
    execute a:cmd
    redir END
  endif
  tabnew
  setlocal nobuflisted buftype=nofile bufhidden=wipe noswapfile
  call setline(1, split(output, "\n"))
  put! = a:cmd
  put = '----'
endfunction
command! -nargs=1 Redir silent call Redir(<f-args>)

This will take normal or system command output and put it in a new tab. Feel free to change the line tabnew to vsplit or split etc.

3N4N
  • 5.9k
  • 1
  • 21
  • 49