vim - 为什么 Vim 不能正确缩进长 C 风格的注释?

标签 vim

我不明白为什么 vim(Ubuntu 14.04 LTS 上的 7.4.52)会缩进像这样的长 C 风格注释(见下文),而 emacs 却缩进正确。

/* looong comment
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
* <- wrong indentation begins at comment line 72
* and keeps being wrong until the end of comment
*/

/*
 * <- back to normal until line 72
 */

FWIW,这是 :setl 告诉我的:

  autoindent          cryptmethod=        expandtab           include=          nomodeline            shiftwidth=4        tags=
--autoread            define=             filetype=c          keywordprg=         path=               softtabstop=4
  cindent             errorformat=        grepprg=            makeprg=            scroll=22           syntax=c
  cinoptions=:0,(0,u0,U0
  comments=sO:* -,mO:*  ,exO:*/,s1:/*,mb:*,ex:*/,://
  fileencoding=utf-8
  formatoptions=croql
  omnifunc=ccomplete#Complete

知道为什么或如何纠正这种行为吗?这是 Vim 错误吗?

最佳答案

要允许更长的注释,您可以使用 cinoptions 指定它,如下所示:set cinoptions+=*200。默认值为 70。请参阅帮助 cino-star

关于vim - 为什么 Vim 不能正确缩进长 C 风格的注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29700965/

相关文章:

vim + CtrlP 插件 - 不区分大小写的搜索?

linux - 在 Ubuntu docker 容器上找不到 Vi 或 Vim

python - 在 vim 中阻止缩进/取消缩进 python 代码

bash - 为什么我不小心创建了名为 ":wq"的文件?

python - 如何在 Vim 插件输出中为单词着色

macos - 在 tmux 模式下丢失 vim 颜色方案

ruby-on-rails - rails.vim 安装但 :Rfind doesnt'work

VIM : go to new empty line, 光标停留在上一栏

vim - 崩溃前捕获Vim的错误输出

c# - 如何使用 vim 构建或编译 VS2010/XNA4 项目?