vim - 如何让vim用正确的缩进格式化项目符号列表

标签 vim

在 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/

相关文章:

vim - 在vim中进行垂直编辑-替换文本

macros - 如何在 Vim 上重复某些操作特定时间?

php - 从终端使用 XDebug(仅获得 SSH 访问权限)

vim - 如何删除 Vim 中前两列周围的引号?

bash - 在许多文件中用制表符空格替换逗号

Vim 在最后一行或 eof 没有行尾

Vim 和 snipMate(插件)——添加新代码片段不起作用

vim - 强制自己掌握 vi 的最佳方法是什么?

linux - Vim 窗口沿左边缘填充

vim - 操作拆分时忽略 NerdTree 缓冲区