cc-mode 缩进的一个细节问题

Vim、Emacs配置和使用
回复
cuiaoxiang
帖子: 62
注册时间: 2010-02-01 19:08

cc-mode 缩进的一个细节问题

#1

帖子 cuiaoxiang » 2010-07-18 8:50

stroustup 风格的。
大多数缩进都是符合我平时习惯的,下面的一个缩进在花括号单独占一行的情况下缩进有问题:

代码: 全选

struct cmp
{
	bool operator ()(int u, int v) {
		return a[u].x1 < a[v].x1;
	}
};

struct cmp
{
	bool operator ()(int u, int v)
		{
			return a[u].x1 < a[v].x1;
		}
};
我看到别人的 .emacs 文件中关于缩进有根据个人喜好做的微调,不知道我的这个问题应该怎么在 stroustrup 风格下微调
God grant me the serenity to accept the things I cannot change
the courage to change the things I can
the wisdom know the difference
cuiaoxiang
帖子: 62
注册时间: 2010-02-01 19:08

Re: cc-mode 缩进的一个细节问题

#2

帖子 cuiaoxiang » 2010-07-18 12:36

在 (setq c-offsets-alist 里面
设置 (inline-open . 0)
God grant me the serenity to accept the things I cannot change
the courage to change the things I can
the wisdom know the difference
头像
zhoucga
帖子: 246
注册时间: 2009-06-12 8:55

Re: cc-mode 缩进的一个细节问题

#3

帖子 zhoucga » 2010-07-18 12:46

没用过这个 一直vim set cindent
青春不是人生的一段时期,而是心灵的一种状况...
cuiaoxiang
帖子: 62
注册时间: 2010-02-01 19:08

Re: cc-mode 缩进的一个细节问题

#4

帖子 cuiaoxiang » 2010-07-18 12:55

推荐大家一个设置的窍门,把光标移动到某个缩进的地方,比如说某个花括号
然后按 C-c C-o minibuffer 会显示改缩进的名称,比如我发的这个帖子对应于 'inline-open'
然后在 .emacs 里面修改一下 'inline-open' 的缩进。

下面是我目前的一些缩进设置,现在肯定还不完全。
等遇到了和VS下缩进不一样的地方,我再用上面的方法,添加缩进设置

(setq c-basic-offset 4)
(setq c-offsets-alist
'((innamespace . 0)
(brace-list-open . 0)
(substatement-open . 0)
(access-label . -)
(inline-open . 0)
(block-open . 0)))
God grant me the serenity to accept the things I cannot change
the courage to change the things I can
the wisdom know the difference
回复