RedditPP Mascot

RedditPP

r/vim • … • u/EgZvor

Tempfile pattern for more Unix philosophy points

Vim usually composes well with Unix utilities. However some tools, like paste and comm accept two file arguments and there is only one stdin. So it requires file saving in some capacity.

The pattern is “use stdin for one file and save an alternate file to a tempfile”. Some of this can be automated, of course. Then utilize :h :_# placeholder for an alternate file and :help :range! to replace current buffer with the result of the CLI utility.

Here's an asciinema with an example https://asciinema.org/a/857466

Edit: I guess there is another pattern here that's more interesting. Delete lines that prevent you from making your edit into another file, perform an edit, place the removed lines back.

— 0