在 Emacs 中尝试 catch 块缩进
我在 emacs 和 emacs 中使用 bsd 风格的缩进。 我想稍微修改一下。 我的 .emacs 文件的相关部分如下。 当我编写带有 try catch 块的函数时,大括号是缩进的。 我希望它们不要缩进类似于函数。
它现在在做什么呢。
try
{
}
catch
{
}
我想让它做什么。
try
{
}
catch
{
}
.emacs 文件
(defun my-c-mode-common-hook ()
;; my customizations for all of c-mode and related modes
;; other customizations can go here
(setq c-default-style "bsd")
(setq c-basic-offset 4)
(setq indent-tabs-mode nil)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
任何帮助将不胜感激。
I'm using the bsd style of indentation in emacs & I'd like to modify it a bit. The related portion of my .emacs file is below. When I write a function with try catch blocks the braces are indented. I'd like them to not indent similar to a function.
What's it's doing now.
try
{
}
catch
{
}
What I'd like it to do.
try
{
}
catch
{
}
.emacs file
(defun my-c-mode-common-hook ()
;; my customizations for all of c-mode and related modes
;; other customizations can go here
(setq c-default-style "bsd")
(setq c-basic-offset 4)
(setq indent-tabs-mode nil)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
转到您想要更改缩进的行,然后按 Cc Co。这将运行 c-set-offset 并默认为当前行的语法(在本例中为 substatement-open)。 '+' 表示一级缩进,'-' 表示不缩进一级,'0' 表示没有额外缩进。 您想要 0。要使其永久,请将 (c-set-offset 'substatement-open 0) 添加到您的挂钩中。
Go to the line with the indent you'd like to change and press C-c C-o. This runs c-set-offset and defaults to the current line's syntax (in this case substatement-open). '+' means one level of indent, '-' means one level unindent, and '0' means no additional indent. You want 0. To make it permanent, add (c-set-offset 'substatement-open 0) to your hook.