11

我在 VIM 中写了一个项目符号列表,并设置了 textwidth=79 来硬换行。当我写这个列表时,我希望每个回车产生一个新的项目符号,并且换行没有项目符号。然而,VIM 的做法恰恰相反(换行上的项目符号,回车后没有项目符号)。我想:

* Item 1 - The text for this line is too long and
  so is wrapped to the next line.
* Item 2 - Typing a carriage return after item 1
  should produce the bullet for this item.

然而,VIM 这样做:

* Item 1 - The text for this line is too long and
* so is wrapped to the next line.
Item 2 - Typing a carriage return after item 1
should produce the bullet for this line.

我打开了自动缩进,关闭了 cindent,并且 formatexpr 是一个空字符串。我理解并喜欢 C 样式注释的自动插入“*”行为,但希望文本文件类型有不同的行为。有没有允许这样做的设置?

4

1 回答 1

1

尝试

set formatoptions=tn autoindent
let &formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|[*-]\s\)\s*'

formatoptions 中的n标志会触发您所追求的列表的格式设置,但 formatlistpat 的默认设置仅处理编号列表。上面的添加了*或的项目符号-

于 2014-03-28T03:07:13.447 回答