Emacs C ++ - 模式不正确缩进? [英] Emacs C++-mode incorrect indentation?
本文介绍了Emacs C ++ - 模式不正确缩进?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我运行emacs 23与c ++ - 模式和有一些缩进问题。
假设我有这个代码:
I'm running emacs 23 with c++-mode and having some indentation problems. Suppose I have this code:
void foo()
{
if (cond)
{ <---
int i;
...
} <---
}
这似乎是自动缩进的默认行为。
但是我想改变它,因此它将是这样:
This seems to be the default behavior of the automatic indentation. However I'd like to change it so it'll be like this:
void foo()
{
if (cond)
{
int i;
...
}
}
推荐答案
我在我的.emacs文件中有以下内容:
I have the following in my .emacs file:
(defun my-c++-mode-hook ()
(setq c-basic-offset 4)
(c-set-offset 'substatement-open 0))
(add-hook 'c++-mode-hook 'my-c++-mode-hook)
您可以通过在任意行上点击[ctrl-c ctrl-s]来确定要编辑的偏移量。在之后的第一行上,如果会说
substatement-open
。
You can determine which offset to edit by hitting [ctrl-c ctrl-s] on any line. On the first line with a brace after the if
it will say substatement-open
.
这篇关于Emacs C ++ - 模式不正确缩进?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文