我想找到一种在 Vim 中轻松格式化列表的方法。
我检查了 PAR 和 Vim 的默认格式化程序。
p.e.
1. this is my text this is my text this is my text 2. this is my text this is my text this is my text 3. this is my text this is my text this is my text 4. this is my text this is my text this is my text
还有这个
- this is my text this is my text this is my text - this is my text this is my text this is my text - this is my text this is my text this is my text - this is my text this is my text this is my text
当我选择行并使用 PAR 和 VIM 将默认格式设置为 42 时,结果如下:
编号列表
用 par 格式化:
标准错误:
(42) <= (0) + (50)
用 vim 格式化:
1. this is my text this is my text this ismy text 2. this is my text this is my text this ismy text 3. this is my text this is my text this ismy text 4. this is my text this is my text this is my text
带有'-'的列表
用 par 格式化:
过滤了 4 行(无变化)
用 vim 格式化:
- this is my text this is my text this is my text - this is my text this is my text this is my text - this is my text this is my text this is my text - this is my text this is my text this is my text
Vim 在格式化列表方面做得更好,但在编号列表中也不正确。
即使我像这样使用前缀 ("p") 选项,Par 在格式化列表时也会遇到很多麻烦:
'<,'>!par w42p4dh 或 '<,'>!par w42p3dh
有没有人知道如何毫无问题地格式化列表的好方法?
尝试设置fo+=n
。来自 :help fo-table
:
n When formatting text, recognize numbered lists. This actually uses
the 'formatlistpat' option, thus any kind of list can be used. The
indent of the text after the number is used for the next line. The
default is to find a number, optionally followed by '.', ':', ')',
']' or '}'. Note that 'autoindent' must be set too. Doesn't work
well together with "2".
Example:
1. the first item
wraps
2. the second item
我是一名优秀的程序员,十分优秀!