Using C/C++ (cc-mode), emacs sometimes re-indents text as I'm typing.
For example (# for indentation, the first 4 are a tab):
enum {
####/
Typing *
, becomes:
enum {
######/*
(inserting 2 extra spaces)
Is there a way to disable this?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityUsing C/C++ (cc-mode), emacs sometimes re-indents text as I'm typing.
For example (# for indentation, the first 4 are a tab):
enum {
####/
Typing *
, becomes:
enum {
######/*
(inserting 2 extra spaces)
Is there a way to disable this?
It turns out electric-mode causes re-indentation, it can be disabled:
To disable, add this to your startup.
(when (fboundp 'electric-indent-mode) (electric-indent-mode -1))
An alternative is to disable re-indenting just for comment characters (since its handy to keep for braces).
;; Prefer no indentation for comment chars.
(define-key c-mode-base-map "/" 'self-insert-command)
(define-key c-mode-base-map "*" 'self-insert-command)
electric-indent-mode
... – Drew Mar 8 '17 at 16:47