在 vim 中,我可以设置 textwidth 选项,然后将新文本格式化为换行。我还可以使用“gq”命令显式换行文本。但是,项目符号列表的行为对我来说有点出乎意料。 vim 文档讨论了使用带连字符的项目符号列表作为项目符号。当我尝试这样做时,它开始正常:
- This is a bulleted list item that
has been wrapped. It looks good.
但是,如果我继续到第三行,它将放弃缩进:
- This is a bulleted list item that
has been wrapped over more than
two lines. The indentation for lines
after the second is unexpected.
这发生在:
formatoptions=tcq
comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-
为了清楚起见,我想要这样的缩进:
- This is a bulleted list item that
has been wrapped over more than
two lines. I want every line after
the first to get the same indent.
最佳答案
经过进一步调查,看起来我只需要执行“设置自动缩进”即可获得预期的行为。这似乎适用于在输入文本时换行和使用“gq”命令换行。
关于vim - 如何让vim用正确的缩进格式化项目符号列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7282355/