我不知道很多關於Emacs的,但一些谷歌搜索後,我編輯.emacs
文件如下:如何讓我的代碼使Emacs縮進我的//註釋?
(setq c-default-style "bsd" c-basic-offset 4)
我的目標是讓奧爾曼風格的縮進與4分開的突出部。它按預期工作,但現在我的//
註釋不會與我的代碼一起縮進。在我改變這個之前,當我輸入//
時,它會自動縮進以符合函數中其餘的代碼。我怎樣才能讓Emacs自動縮進//
評論?
我嘗試添加c-indent-comments-syntactically-p 1
上述.emacs
文件,但是這並沒有改變它...
例如:
int main()
{
// I'd like this line to be auto-indented to match the block
for (int i = 0; i < 10; ++i)
{
// And this line to be auto-indented to match the block
doStuff();
}
}
目前,TAB
不縮進我//
評論,它也不會自動縮進。
但是,如果它是一個嵌套塊? – Cornstalks
@Cornstalks偏移量是相對於周圍的偏移量。我添加了一個例子。 – pmr
太棒了。考慮到我上面的'.emacs'文件,添加這個文件的正確方法是什麼?把'(setq c-default-style「bsd」c-basic-offset 4(c-set-offset'comment-intro 4))'放在我的''中。emacs'文件使Emacs barf出現以下錯誤:'錯誤的類型參數:symbolp,(c-set-offset(quote comment-intro)4)' – Cornstalks