在 vim(例如 7.3)中,我如何使用/修改cindent
orsmartindent
选项,或以其他方式增加 my .vimrc
,以便在开括号内自动缩进大括号以与直接在开头之前的第一个“单词”(稍后定义)对齐(
?
该选项似乎很有希望,但在开括号内时fN
似乎被该选项覆盖。(N
来自:help cinoptions-values
:
fN Place the first opening brace of a function or other block in
column N. This applies only for an opening brace that is not
inside other braces and is at the start of the line. What comes
after the brace is put relative to this brace. (default 0).
cino= cino=f.5s cino=f1s
func() func() func()
{ { {
int foo; int foo; int foo;
当前行为:
func (// no closing )
// (N behavior, here N=0
{ // (N behavior overrides fN ?
int foo; // >N behavior, here N=2
虽然我希望:
func (// no closing )
// (N behavior as before
{ // desired behavior
int foo; // >N behavior still works
我所要求的不同于因为与普遍缩进对齐,并且我想与直接在开头之前的任何 C++fN
对齐,例如fN
nested-name-specifier
(
code; f::g<T> ( instead of code; f::g<T> (
{ {
如果没有nested-name-specifier
,我希望它与(
自身匹配。也许匹配 anested-name-specifier
太复杂了,或者语法的另一部分更适合这种情况。无论如何,对于我的典型用例,我认为如果{
与最里面的 unclosed (
(包括在内)不包含任何分号或左花括号的最大字符序列的第一个非空白字符对齐,我会感到满意}
。
顺便说一句,我在尝试std::for_each(b,e,[]{});
在 vim7.3 中自动缩进各种结构时遇到了这个问题。谢谢你的帮助!