Putting Shell Output In The Current Buffer

I’ve long used 【Meta+|】 to pipe a region to a shell command. I use it all the time to pipe troff input to groff and display the results with gxditview. Recently I learned that if you specify a prefix arg it will place the results in the current buffer. The easiest way to do that is simply to type 【Meta+1 Meta+|】. The same trick works with 【Meta+!】. For example, if I want to insert a directory listing into the current buffer I could type 【Meta+1 Meta+!ls.

Summary of Key Sequences

  • Meta+|
    Pipe the highlighted region to a shell command and place the output in a ∗Shell Command Output∗ buffer.
  • Meta+1 Meta+|
    Pipe the highlight region to a shell command and place the output in the current buffer.
  • Meta+!
    Run a shell command and place the output in a ∗Shell Command Output∗ buffer.
  • Meta+1 Meta+!
    Run a shell command and place the output in the current buffer.

Update: prefix tag → prefix arg

This entry was posted in General and tagged . Bookmark the permalink.

3 Responses to Putting Shell Output In The Current Buffer

  1. marwy says:

    So useful. Thanks for posting!

  2. Phil says:

    Typo? “prefix tag” should surely be “prefix arg”.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>