💾 Archived View for bbs.geminispace.org › u › oldernow › 13097 captured on 2023-12-28 at 16:09:18. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
@stack Here be the Lua scripts. You'll see they're not well documented, but read from stdin and write to stdout, making the perfect to run against lines in a vim session a la:
NOTE: The source code below contains tab characters.
Looks like "center" takes a couple optional arguments related to some kind of additional padding.
Let's say you start with this on lines 1 through 4 in a vim session:
this is a test to see what happens
running ":1,4!center" leads to:
this is a test to see what happens
running ":1,4!center @" leads to:
@@@@this@@@@ @is a test@@ @@@to see@@@ what happens
(see how it used argument one as a padding character?)
running ":1,4!center @ x" leads to:
@@@@this @is a test @@@to see what happens
So apparently the second argument (which can be anything) leads to the padding occurring only at the front of lines.
#! /usr/bin/env lua local pad = ' ' if arg[1] then pad = arg[1] end t = {} max = 0 for line in io.stdin:lines() do line = string.gsub(line, '^%s*', '') line = string.gsub(line, '%s*