Ex command output to buffer (from justinmkw)

3 Points

Raghu Raghu

10 years ago

Do you like dealing with Vim's in built pager? For all the power of Vim, that pager is probably the single most dysfunctional piece you'd find. Now you can do R excommand and the output is piped into a buffer for your editing and navigating pleasure!

PS: this is not original - I just found it on reddit via justinmkw

func! ReadExCommandOutput(newbuf, cmd)
  redir => l:message
  silent! execute a:cmd
  redir END
  if a:newbuf | wincmd n | endif
  silent put=l:message
endf
command! -nargs=+ -bang -complete=command R call ReadExCommandOutput(<bang>1, <q-args>)
inoremap <c-r>R <c-o>:<up><home>R! <cr>

eyalk5

eyalk5 6 years ago

Did something like that too!