如何更改 Emacs 中的大括号缩进级别?

发布于 2024-08-27 05:29:41 字数 245 浏览 5 评论 0原文

我一生都无法通过传统的互联网手段找到任何答案,所以我希望得到一些帮助。

对我来说,Emacs 现在倾向于在大括号上进行缩进,如下所示:

if( ... )
  {

  }

这让我感到非常恼火;我什至从未在其他地方见过这种行为。无论如何,我期望的行为是,

if( ... )
{

}

如果有人知道如何修改它,我将不胜感激。

I can't for the life of me find any answer to this through conventional Internet means, so I'm hoping for some help.

Emacs for me right now tends to do indentation on braces as follows:

if( ... )
  {

  }

Which I find incredibly irritating; I've never even seen this behaviour anywhere else. At any rate, the behaviour I'm expecting is,

if( ... )
{

}

If anyone knows how to modify this, it'd be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彡翼 2024-09-03 05:29:41

基本上你想要:

(setq c-default-style "bsd"
  c-basic-offset 4)

对于更多缩进命令:

Mx c-set-style RET 风格 RET

选择预定义的缩进样式
风格。类型 ?当输入样式时
查看支持的样式列表;到
找出一种风格是什么样的,
选择它并重新缩进一些 C 代码。

Cc Co 符号 RET 偏移量 RET

设置缩进偏移量
句法符号 符号
(c-设置-偏移)。第二个论点
offset 指定新的缩进
偏移量。

来源: http://www.phys.ufl。 edu/docs/emacs/emacs_251.html

还有: http://www.gnu.org/software/emacs/manual/html_node/ccmode/Indentation-Commands.html

Basically you want:

(setq c-default-style "bsd"
  c-basic-offset 4)

For more indentation commands:

M-x c-set-style RET style RET

Select predefined indentation style
style. Type ? when entering style to
see a list of supported styles; to
find out what a style looks like,
select it and reindent some C code.

C-c C-o symbol RET offset RET

Set the indentation offset for
syntactic symbol symbol
(c-set-offset). The second argument
offset specifies the new indentation
offset.

source: http://www.phys.ufl.edu/docs/emacs/emacs_251.html

also: http://www.gnu.org/software/emacs/manual/html_node/ccmode/Indentation-Commands.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文