commit 1aeba880373725a833187f7c955404af9610768e (patch)
Author: Alex Karle <email@example.com>
Date: Wed, 1 Dec 2021 00:16:51 -0500
gopher: Add phlog post on fmt(1) and vi(1)
Maybe this is common knowledge? I don't think so..
There's even a vim(1) tip in there as a bonus!
2 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/gopher/phlog/015.txt b/gopher/phlog/015.txt
@@ -0,0 +1,42 @@
+Using fmt(1) to Wrap Lines in vi(1)
+Wed Dec 1 00:00:50 EST 2021
+There's several types of text that I really like to hard-wrap.
+Phlog posts, personal notes, git messages, and emails to name
+This can be done in vim(1) by setting `textwidth` to 60 and
+then using the `gq<motion>` command to format (example: `gqip`
+formats *i*nside *p*aragraph).
+However, I really like using OpenBSD's vi(1) as my $EDITOR due
+to its blazingly fast startup time (and the whole point of the
+$EDITOR is that it is executed by other programs!).
+To achieve the same automated formatting, I make use of a
+lesser known feature:
+ ! <motion> command ...
+Will replace the lines in <motion> with the output of the shell
+command (which receives the lines as standard input).
+Better yet, this repeats with the dot command. So, as a final
+action before publishing, I go to the top of the first paragraph
+and hit `!}fmt 60`, then go down the post with `}.}.}.` until
+all paragraphs are wrapped.
+How cool is that? It even works in vim(1) (one of the perks of
+learning plain-vi(1) is discovering deeper vim(1) features!)
+Note that you can also use:
+ range ! command
+Such as `%!fmt 60` to filter the whole document, but I find
+there's usually bits and pieces fmt(1) doesn't handle well
+(such as title underlines or ascii art), so I prefer to
+quickly format each paragraph by hand.
diff --git a/gopher/phlog/index.gph b/gopher/phlog/index.gph
@@ -14,6 +14,7 @@
+[0|[2021-12-01] Using fmt(1) to Wrap Lines in vi(1)|/phlog/015.txt|server|port]
[0|[2021-11-30] Screen Time|/phlog/014.txt|server|port]
[0|[2021-11-25] Gopher-First Feeds|/phlog/013.txt|server|port]
[0|[2021-11-21] Optimizing for Archival|/phlog/012.txt|server|port]