Reputation: 89
I'm using emacs 24.5 in cygwin. I need to indent to 4 spaces in text mode and when I press enter, the newline should align with the indentation of the previous line. I've tried the following.
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq-default electric-indent-mode 1)
But, when I press enter instead of indenting the current line, it removes the indentation of the previous line as well. Like this
This is the first line. When I press enter, this line becomes...
This is the first line
New line - cursor is not indented in this new line.
How do I get the required indentation?
Upvotes: 0
Views: 286
Reputation: 28531
You might want to try
(add-hook 'text-mode-hook
(lambda ()
(setq-local left-margin 4)))
instead of your use of tab-width
(which is usually the wrong tool for indentation purposes).
Upvotes: 1