Is it possible to pipe an unsaved buffer to an external command and then replace the buffer by the command’s output?
You can use the "filter" command,
:!, which like most commands can be prefixed with a range:
If you prefix this with a range, it will pipe those lines to the command's stdin, and replace those lines with the program's output. In this case you want to use
% as the range, which means the entire buffer. For example:
You can find the Vim documentation with