开发者

How to keep a command output window in vim

What I'm looking for is a different window than the current one containing the output of a command into the same buffer. So I can execute:

:!php %

And see the output in a bottom split window. That's commonly seen in most graphical editors I've used.

Notes:

  1. Not the current window. Don't want to have to switch back
  2. Not creating a new buffer each time. (have to reuse "output" buffer)
  3. I don't want that in a register, I want to be able to see the output straight away.

The flow would be:

  1. Open vim -S session ...
  2. Edit a file
  3. Execute a simple make-type command
  4. Look at command output in output window

without having hundreds of new buffers and ha开发者_JS百科ving to switch between windows.

What I've tried so far that is not satisfactory ... sending output to file, turning autoread on, opening a buffer on that file. That works but I have to turn autoread on for all files.. a bit annoying. Is there a way to turn autoread for a single buffer/file?

Thanks for your help.


It sounds like you are looking for Vim's "quickfix" window. I'd use 'makeprg', :make and :copen, like this:

:set makeprg=php\ %
:make
:copen

Additionally, you can use the 'errorformat' option to deliver the cursor to the first line containing an error.

:set errorformat=%m\ in\ %f\ on\ line\ %l

And for speed, I have F5 mapped to make:

:nnoremap <F5> :<C-U>make<CR>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜