多线段上的Vim格式化程序(=)双缩进?

时间:2013-10-22 22:54:30

标签: vim vi

我有一些代码:

    Vector3 targetCoords = this.GetFiringSolution(
        targetObject,
        targetObject.root.rigidbody.velocity,
        muzzle,
        verticalRotator.root.rigidbody.velocity,
        projectileForce 
    )

但是当我在vim中使用(gg + G)时,它会变成

    Vector3 targetCoords = this.GetFiringSolution(
            targetObject,
            targetObject.root.rigidbody.velocity,
            muzzle,
            verticalRotator.root.rigidbody.velocity,
            projectileForce 
    )

这是我的:设置输出:

--- Options ---
  autoindent          cindent             fileformat=unix     history=50          modified            scroll=28           smartindent       notextmode
  background=dark     diffexpr=MyDiff()   filetype=cs         hlsearch            number              shiftwidth=4        syntax=cs           visualbell
  backup              expandtab           helplang=en         incsearch           ruler               showmatch           tabstop=4           window=57
  backspace=indent,eol,start
  comments=sO:* -,mO:*  ,exO:*/,s1:/*,mb:*,ex:*/,:///,://
  formatoptions=croql
  keymodel=startsel,stopsel
  selection=exclusive
  selectmode=mouse,key
  viminfo=%,'100,<50,s10,h,rA:,rB:
  whichwrap=b,s,<,>,[,]
  wildignore=*.meta,*.swp

反正有没有阻止这种行为?我试着调查cimoptions但没有完全理解。这适用于C#和PHP中的多行函数调用(以及类似的东西) - 可能是其他函数。

我也试过打开si / ai和两者,但没有帮助。

提前致谢。

1 个答案:

答案 0 :(得分:1)

来自cinoptions-values的vim帮助:

    +N    Indent a continuation line (a line that spills onto the next)
          inside a function N additional characters.  (default
          'shiftwidth').
          Outside of a function, when the previous line ended in a
          backslash, the 2 * N is used.

所以看起来你可以完全禁用cindent,或者你必须在函数之外使用双缩进。