在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