vim - 标准 ML 注释格式在 vim 中是错误的

我尝试了以下命令来格式化 ~/.vim/after/indent/sml.vim

中的注释
set comments=s1:(*,mb:*,ex:*)
set comments=sr:(*,mb:*,ex:*)
set comments=s1:(*,mb:\ *,ex:*)
set comments=sr:(*,mb:*,ex:*)

等等各种组合。我似乎无法实现中间注释行缩进 1 个空格的 C 风格注释。而不是这个

(* Text
 * More text
 * even more text *)

我明白了

(*
* Some misaligned text
* etc. *)

有什么建议吗? :h format-options comments fo-table 不建议任何看起来有用的替代方案。

最佳答案

当我使用这些设置时,

set comments=s1:(*,mb:*,ex:*)
set comments=sr:(*,mb:*,ex:*)
set comments=s1:(*,mb:\ *,ex:*)
set comments=sr:(*,mb:*,ex:*)

我得到以下结果,

(* blah blah blah blah blah adsf blah blah blah blah blah blah blah blah
 * blah blah blah blah blah blah blah blah blah blah blah blah blah blah
 * blah blah blah blah blah blah ...

这不管我是不是都有效

  • set formatoptions+=tset textwidth=80 并超出该行,
  • 设置 formatoptions+=r 并按 Enter,
  • set formatoptions+=o 并在命令模式下点击 o/O,或者
  • 设置 formatoptions+=q 并点击 gq

在我的 ~/.vimrc 中使用 au Filetype sml source ~/.vim/after/indent/sml.vim

这是 Ubuntu 15.04 上的默认 Vim:

:version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan  2 2014 19:39:32)
Included patches: 1-52
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by buildd@
Huge version without GUI.  Features included (+) or not (-):
...

也许您有一些其他设置或插件会影响此行为。

https://stackoverflow.com/questions/31383892/

相关文章:

android - 在 Charles Proxy 中解码 RAW protobuf 数据

node.js - gulp 段错误 : 11 and Abort trap: 6 OSX Yose

javascript - 如何在 Google Maps API 中获取标记选项

objective-c - 动态计算自定义 UITableViewCell 的高度

java - 动态sql生成设计

javascript - 华丽的弹出式透明 png 为灰色

android - RecyclerView 项目有时无法正确显示,直到我滚动(仅在 Genymot

javascript - 强制 JSON.stringify 使用十进制表示法

c# - Entity Framework - 不支持列 'ColumnName' 的类型。类型是

.net - 自动更新 nuget 包 - 不添加程序集重定向