Filtering text through a shell command in Emacs

Rohit picture Rohit · Oct 16, 2008 · Viewed 14.8k times · Source

In vi[m] there is the ! command which lets me pipe text through a shell command -- like sort or indent -- and get the filtered text back into the buffer. Is there an equivalent in emacs?

Answer

link0ff picture link0ff · Oct 16, 2008

You can select a region and type `C-u M-| command RET', and it replaces the region with the command output in the same buffer due to the interactive prefix argument of shell-command-on-region.