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.
Should You Use Tab or Space to Indent? Technically, it is fine to either indent using the tab key or with the space bar. Indenting once with the tab key means just pressing the tab key once. Indenting once with the space bar means pressing the space bar 4 times.
Both C and C++ are not affected by white space in their interpretation of the code. That does not mean the programmer should not care about its misuse.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With