2013-05-05 71 views
0

所以我有一個問題(顯然)。我讀了一個interesting article about "Smart Tabs",我已經在Emacs中測試過了,它工作得很好。Vim:壓痕/對齊問題

因此,目前我使用的是Emacs,因爲我在vim中嘗試了這一點,我無法完成它的工作。這裏是我的.vimrc中我認爲與縮進相關的行。

set autoindent    " auto/smart indentation 
set cindent 
set preserveindent 
set copyindent 
set smarttab     " tab and backspace are smart 
set tabstop=4     " 4 spaces 
set softtabstop=4 

如果你想別的東西可能會導致如下概述,my vimrc is here for you意外的行爲。

預期的行爲

我希望有一個示例程序看起來像這樣,我只鍵入代碼並按下回車鍵每次那麼頻繁。 ( - 「」每個「>」表示標籤,各自表示一個空格)

#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 

int main (int argc, char *argv[]) 
{ 
-> printf ("%s\n", 
-> ........teststring); 
-> function_with_many_arguments (bacon, 
-> ..............................indentation, 
-> ..............................problems); 
-> return 0; 
} 
</pre> 

即,我希望Vim使用標籤僅針對壓痕; 從不對齊。 這是因爲如果有人減少了他們的標籤大小,我希望函數調用和多行參數集合正確對齊,無論標籤等於多少個字符。

當前行爲

我看了所有我能找到的資源,這就是我把我的的vimrc。 現在,而不是做預期的行爲,這是什麼代碼看起來像代替:

#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 

int main (int argc, char *argv[]) 
{ 
-> printf ("%s\n", 
-> -> -> teststring); 
-> function_with_many_arguments (bacon, 
-> -> -> indentation, 
-> -> -> problems); 
-> return 0; 
} 

我在做什麼錯?它看起來像我一樣,所有的對齊只是兩個製表符,不管它們碰巧是什麼,我希望它用空格縮進右列。

+1

':set cino =(0' taken form [here](http://stackoverflow.com/questions/88931/lining-up-function-parameter-lists-with-vim) – FDinoff 2013-05-05 20:57:32

+0

鏈接的副本沒有回答(混合製表符/空格)縮進部分,不幸的是,在Vim中很難自動實現。 – 2013-05-06 06:53:53

回答

0

我覺得這個問題離我而去,當我開始使用YouCompleteMe插件與鐺完成。順便說一句,它是最好的插件之一,如果你真的想在Vim開發C語言。