以与 format=flowed 兼容的方式包装电子邮件文本,例如使用 par

以与 format=flowed 兼容的方式包装电子邮件文本,例如使用 par

我想使用命令行程序将电子邮件文本包装为 72 个字符(以便重新格式化可以与 集成vim)。使用的报价>需要妥善处理。

超过 72 个字符的行以及短于 72 个字符并以空格结尾的行都应该换行。不以空格结尾的行应该单独保留,以便您可以编写类似的内容

Best wishes,
Greg

(之后没有空格Best wishes,)而不将其换行成一行。

在换行的地方,应在末尾留一个尾随空格,以便在使用format=flowed Content-Type标头电子邮件客户端可以正确显示它。

这是一些示例文本:

This is an example text file that I would like to reformat using par. I would like this paragraph wrapped to 72 characters because at the moment it's just one long line of text.

> This paragraph should also be wrapped 
> to 72 characters because each line 
> except the last ends with a space. 
> The quotes should be handled nicely.

These lines shouldn't be wrapped
because they are shorter than 72 chars
and don't have any trailing spaces.

par w72q(下面的输出)接近,但不会在行尾留下尾随空格,并且不会在没有尾随空格的情况下换行:

This is an example text file that I would like to reformat using par. I
would like this paragraph wrapped to 72 characters because at the moment
it's just one long line of text.

> This paragraph should also be wrapped to 72 characters because each
> line except the last ends with a space. The quotes should be handled
> nicely.

These lines shouldn't be wrapped because they are shorter than 72 chars
and don't have any trailing spaces.

答案1

Vim 实际上可以很好地处理这个问题,而无需求助于其他程序。以下选项很有用:

setlocal comments=n:>
setlocal formatoptions+=aw
setlocal textwidth=72

请参阅:help format-comments:help fo-table了解更多信息。

相关内容