2012-04-06 106 views
5

我在vim 7.3中使用「語法」foldmethod。在的.vimrc:VIM語法摺疊:禁用摺疊多行註釋

set foldmethod=syntax 

當我打開Test.cpp的,含有:

/* A function with a multi-line 
* comment. This takes at least 
* four lines and I want to be 
* able to read all of them. 
*/ 
void TheFunction() 
{ 
    DoStuff(); 
} 

我看到摺疊時執行以下操作:

+-- 5 lines: A function with a multi-line--------------------------------------------- 
void TheFunction() 
+-- 3 lines: {------------------------------------------------------------------------ 

我喜歡的功能體的摺疊,但不評論摺疊。我想禁用它,所以它看起來像這樣:

/* A function with a multi-line 
* comment. This takes at least 
* four lines and I want to be 
* able to read all of them. 
*/ 
void TheFunction() 
+-- 3 lines: {------------------------------------------------------------------------ 

我該怎麼做?我可以看到語法組的相關搭配:SYN列表cComment

cComment  xxx matchgroup=cCommentStart start=+/\*+ end=+\*/+ extend fold contains 
[email protected],cCommentStartError,cSpaceError,@Spell 
        links to Comment 

但模具周圍與Vim文檔一個小時,谷歌還沒有告訴我如何從該組刪除「摺疊」屬性。

我唯一的辦法就是編輯語言語法文件嗎?我認爲複製系統語法文件並使用它不太難看,但我應該能夠使用.vimrc中的命令關閉特定的組。

+0

kev的答案完美的作品。這可以在文檔':help ft-c-syntax'的syn-file-remark部分找到。您還可以用'let c_no_if0_fold = 1'來摺疊'#if 0'樣式註釋。 – reasgt 2012-04-06 18:15:23

回答

5

'foldmethod'設置爲"syntax"然後/* */ comments{ } blocks將 成爲摺疊。如果你不想讓評論成爲摺疊使用:

:let c_no_comment_fold = 1