在vim(例如7.3)中,我如何使用/修改cindent
或smartindent
选项或以其他方式增加我的.vimrc
,以自动缩进大括号内的大括号,以便与第一个“单词“(后面定义)直接在开头(
之前?vim indentation括号内括号
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
我所要求的是不同从fN
因为fN
对齐到流行缩进,并且我想要对齐任何直接在op之前的C++ nested-name-specifier
付民(
,像
code; f::g<T> ( instead of code; f::g<T> (
{ {
如果没有nested-name-specifier
,我想它匹配(
本身。也许匹配一个nested-name-specifier
太复杂了,或者也许有另一个语法的部分,这更适合于这种情况。无论如何,对于我的典型用例,我认为如果{
与最内部未封闭的(
(含)之间的最大字符序列的第一个非空白字符对齐,该字符不包含任何分号或左卷大括号}
。
顺便说一句,我试图在vim7.3中自动缩进各种std::for_each(b,e,[]{});
构造时遇到了这个问题。谢谢你的帮助!
尝试'设置nocindent',为我工作 - !但我有还有smartident和autoindent开启 – Zaffy