From 7e9e9df5b43e032fd0149f7c3238a663a868060c Mon Sep 17 00:00:00 2001 From: Mauro Scomparin Date: Mon, 26 Oct 2020 19:40:17 +0000 Subject: [PATCH] Added fmt post. --- content/posts/fmt.md | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 content/posts/fmt.md diff --git a/content/posts/fmt.md b/content/posts/fmt.md new file mode 100644 index 0000000..3128fe5 --- /dev/null +++ b/content/posts/fmt.md @@ -0,0 +1,52 @@ +--- +title: "fmt" +date: 2020-10-26T02:32:23Z +draft: false +tags: [blog, gnu, fmt] +--- + +Everybody loves [Markdown][md], it's pretty cool to get html from a text +file, there are tons of programs that understands is and display it with +nice CSS. +I personally like to have my markdown files readable from a terminal. +Let's say 80 char per line, let's say it's easier on my eyes. + +There's also some studies that says the average human being can focus +on a maximum of 50 to 60 characters, 75 at max. + +When writing I started to take a look at the current position of the +cursor in the line, manually breaking the row up to the next line if it +gets too long, but I'm not a machine and it's pretty annoying to manually +rearrange words when the paragraph changes. + +Like every boring task someone figured out a way to automate this tedious +and frankly pointless activity. + +There's a program called [fmt], it's part of [GNU coreutils][coreutils]. + +It's just brilliant. + +Just write the file with lines as long as you like, save it and run +something like: + + fmt -s file.md > file.md.formatted + delete file.md + mv file.md.formatted file.md + +Now you got your file formatted and nice to read. + +The `-s` option is the short version of `--split-only`, which is pretty +self explanatory and the man page says: + + Split lines only. Do not join short lines to form longer ones. + This prevents sample lines of code, and other such “formatted” + text from being unduly combined. + +Exactly what I wanted. + +Take a look at it if you need to format some text in general too, you +probably already have it installed as part of [coreutils]. + +[md]: https://daringfireball.net/projects/markdown/ +[fmt]:https://www.gnu.org/software/coreutils/manual/html_node/fmt-invocation.html +[coreutils]: https://www.gnu.org/software/coreutils/ -- 2.25.1