1

I just want each line to get the same indentation as the previous line, and that TAB would indent 4 spaces. For C++ I managed it with:

(setq-default indent-tabs-mode nil)
(setq-default c-syntactic-indentation nil)
(setq-default c-basic-offset 4)

In my .emacs, but for CMake files Emacs just indents the lines automatically according to its own rules, and TAB has no effect at all.

Yaron Cohen-Tal
  • 2,005
  • 1
  • 15
  • 26
  • If you're using `cmake-mode`, my answer should work. If your major mode is different, tell me and I'll try to work something out. – GJStein Jul 15 '15 at 13:23

1 Answers1

0

What you probably need to disable is known as electric-indent-mode which is the function which indents your code when you press return. To disable it for cmake-mode, as in this answer is to include the following line in your init

(add-hook 'cmake-mode-hook (lambda () (electric-indent-local-mode -1)))
Community
  • 1
  • 1
GJStein
  • 648
  • 5
  • 13
  • Thanx, but this has the effect that a new line has no indentation **at all**, and TAB still has no effect. I want each line to be idented exactly like the one before it, and TAB to insert 4 spaces. – Yaron Cohen-Tal Jul 15 '15 at 15:29