V,54,50字节
¬ ~9ñ9É 11|á
ñ2ñ20lá
ñ$18é 9ñ^y|Ehé
Pf xxywk$hP>ñd
在线尝试!
与通常不同,此程序不包含任何不可打印的字符。
说明:
¬ ~ " Insert the entire printable ASCII range
9ñ ñ " 9 times:
9É " Insert 9 spaces at the beginning of this line
11| " Move to the 11'th column on this line
á<CR> " And append a newline after the 11'th column
现在缓冲区看起来像这样:
!
"#
$%
&'
()
*+
,-
./
01
23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
现在我们建立中间部分:
2ñ ñ " Two times:
20l " Move 20 characters to the right (because 'l' == 'right', duh)
á<CR> " Append a newline
这是有点奇怪的地方。
$ " Move to the end of this line
18é " Insert 18 spaces before the last character
9ñ " Repeat the following 9 times:
^ " Move to the first non-whitespace character
y| " Yank all the whitespace before the current character.
" We'll call this the "Leading whitespace register"
E " Move to the end of the current WORD (up to before a space)
h " Move back one character
é<CR> " And insert a newline before the current character
P " Paste the leading whitespace for indentation
f " Move forward to a space
xx " Delete two characters
" (Note how we are inbetween the two bottom branches right now)
yw " Yank everything upto the next branch (all spaces)
" We'll paste this on the line up so that we can yank it again later
" To keep track of how far apart the branches are
k$ " Move up a line and to the end of that line
hP " Move back a character and paste the whitespace we yanked
> " Indent this line by one space
ñ " End the loop
这是重要的注意事项。该>
命令实际上是一个运算符,这意味着它在没有参数的情况下不会执行任何操作,而要对文本进行操作。例如,
>_ "Indent the current line
>> "Indent the current line
>j "Indent the current and next line
>G "Indent every line
但是由于此命令是循环的,因此可以通过不给运算符来保存字符。在循环结束时,如果有任何运算符挂起,它将_
隐式填充(当前行)作为参数。
现在,我承认这个循环有点怪异,并且很难随时跟踪所有文本的外观。因此,您可以使用这个简单的程序查看N个循环后的外观。
如果将其设置为9,则可以看到我们还有一些多余的文字可以删除。(仅当前行)。
因此,我们使用删除当前行dd
。可是等等!您知道我怎么说操作员必须接受有时隐式填充的参数吗?在程序结束时,参数也会隐式填充。因此,我们可以简单地让V 代替,而不是dd
or d_
(等效)。d
_