I am editing C source code in vim. I'd like to:

  1. Write current contents of the buffer (which is potentially a scratch buffer) to my favorite C compiler's stdin (essentially, pipe buffer to a command)
  2. Read from the pipe (that potentially reads stderr as well, because compilation may fail), and pipe compiler's stdout to a new buffer/split in vim
  3. (Optionally) set the new buffers filetype to whatever I specify (generally assembly)

I'd prefer vsplit, instead of a new buffer, but I don't know whether that's possible. I am not an expert in vim. I have found this, and this answers. The latter one is closest to what I desire. It uses a temporary buffer as far as I understood; is possible to do the same thing without temporary files, but directly dealing with stdio? If not, I'll go ahead and use it.


Like most things, there’s already a plugin for this.

You may be able to configure it to split vertically, but the output window is persistent, so you can just alter the window arrangement to your liking after the first run.

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.