C++ Vim缩进C/C++;当类型和名称在不同的行中时,功能不好
下面的代码片段很好地解释了我的问题 我想要的是:C++ Vim缩进C/C++;当类型和名称在不同的行中时,功能不好,c++,templates,vim,indentation,C++,Templates,Vim,Indentation,下面的代码片段很好地解释了我的问题 我想要的是: template<class T> ostream& operator<<(ostream& out, const vector<T>& v) { ... } int main() { ... } 模板 ostream&operator您可以在.vimrc: “自动缩进 设置ai “智能缩进 设置si “C型缩进 设置cindent您看到的是cino-t(cinopt
template<class T>
ostream& operator<<(ostream& out, const vector<T>& v)
{
...
}
int
main()
{
...
}
模板
ostream&operator您可以在.vimrc:
“自动缩进
设置ai
“智能缩进
设置si
“C型缩进
设置cindent
您看到的是cino-t
(cinoptions设置t)的效果。您需要确保连接包含t0
,以使参数与左边距齐平
From:h cino-t
cino-t
tN Indent a function return type declaration N characters from the
margin. (default 'shiftwidth').
cino= cino=t0 cino=t7
int int int
func() func() func()
为此,您需要确保为cpp文件类型设置了它。(cindent
在默认cpp缩进文件中处于启用状态)
我认为只要将set cinoptions+=t0
添加到您的vimrc中就足够了。正如我所猜测的,这有一个非常简单的解决方案!在激励自己阅读:help'cinoptions values'
之后,以下配置就是解决此特定问题所需的全部配置
:set cino+=t0
从帮助文本中:
tN Indent a function return type declaration N characters from the
margin. (default 'shiftwidth').
cino= cino=t0 cino=t7
int int int
func() func() func()
这看起来更像是一个bug,你应该向vim报告,而不是在这里回答一个问题。看这里:即使它是bug,这肯定是成千上万的程序员都遇到过的。如果它是bug,我认为现在应该修复了。/你试过打开cindent
?在我的经验中,它在类似C的语言中工作得更好。在如果你的cinoptions
。我的是:g0、t0、h1s、i0
,我没有你观察到的奇怪缩进。你可能有一个(英尺)混乱其值的插件。你可以看到它在哪里被更改,使用:verbose set cinoptions?
@Kevin:我以为文件类型缩进
为C类型文件打开了cindent
。是的,我找到了答案,我自己刚刚发布了答案,碰巧与此答案几乎相同。:p
tN Indent a function return type declaration N characters from the
margin. (default 'shiftwidth').
cino= cino=t0 cino=t7
int int int
func() func() func()