Tag: 缩进

用于C代码的多级嵌套的Emacs缩进

我是emacs的新手(主要是使用vim和eclipse / netbeans等)。我正在使用C级代码的多级嵌套,并在emacs中编写一个示例代码来测试它如何缩进代码,其中嵌套太深(不是现实生活中的代码)。 int foo() { if (something) { if (anotherthing) { if (something_else) { if (oh_yes) { if (ah_now_i_got_it) { printf(“Yes!!!\n”); } } } } } } 这看起来就像我输入emacs并保存它一样。 但是在另一个文本编辑器上打开它显示实际保存的文本是这样的: int foo() { if (something) { if (anotherthing) { if (something_else) { if (oh_yes) { if (ah_now_i_got_it) { printf(“Yes!!!\n”); } } } } } } […]

如何禁用vim的switch case缩进?

我目前正在与Vim战斗,我似乎无法让缩进选项做我想要的。 这是我的设置,我把它们放在.vimrc的底部,以确保它们优先。 你可以看到我有点疯狂,所以我试着关掉几乎所有东西: set cindent set cinkeys=o,O set cinoptions= set cinwords= set indentexpr= 在大多数情况下它似乎工作正常,它打开块后做一个缩进,一切都很好。 但有一个案例让我发疯,当有一个{在一个case陈述之后,下一行太过分了: switch () { case CASE: { // <– next line gets indented to here, why?? // <– should be indented to here 我怎么能让它停止这样做? TIA

将预处理程序指令缩进为emacs中的C代码

默认情况下,Emacs不会缩进预处理器代码。 我知道它的历史根源已经过时了。 但是,拥有大量#ifdef unindented的代码很难阅读。 所以我想让emacs自动缩进给我这样的东西: void myfunc() { int foo; #ifdef BAR printf(foo); #endif return foo; } 而不是我现在得到的: void myfunc() { int foo; #ifdef BAR printf(foo); #endif return foo; } 这个问题的任何线索你emacs黑客:)?

如何自动将K&R函数声明转换为ANSI函数声明?

// K&R syntax int foo(a, p) int a; char *p; { return 0; } // ANSI syntax int foo(int a, char *p) { return 0; } 如您所见,在K&R样式中,变量的类型在新行中而不是在大括号中声明。 如何自动将K&R函数声明转换为ANSI函数声明? 在Linux中有人知道这么容易使用的工具吗?