Reputation: 5070
I have a file open called test.scss
, and when I press RET on a line, emacs will add 2 spaces to the current line and 4 extra spaces to the next line.
I've highlighted what the file looks like with whitespace-mode
.
You can see that the .my-element
row was auto-indented by 2 spaces, and the new line is indented by 4 spaces too many.
I want the output to look like this instead
What can I do to make emacs produce my desired output?
Here is the output of describe-mode
:
Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption
Electric-Indent File-Name-Shadow Font-Lock Global-Eldoc
Global-Font-Lock Line-Number Menu-Bar Tooltip Whitespace
(Information about these minor modes follows the major mode info.)
SCSS mode defined in `css-mode.el':
Major mode to edit "Sassy CSS" files.
In addition to any hooks its parent mode `css-mode' might have run,
this mode runs the hook `scss-mode-hook', as the final step
during initialization.
Although in this case I'm in scss-mode, I see similar behavior with most of the other modes I use, such as ruby-mode
, sgml-mode
, js.el
mode and others. I'd like to make the behavior match the desired output shown above.
Upvotes: 0
Views: 465
Reputation: 136995
Each mode can handle indentation in its own way, and you may have to look for mode-specific settings to get two-space indentation working everywhere.
For starters, you can set css-indent-offset
, which should cover css-mode
and scss-mode
:
(setq css-indent-offset 2)
You can set the basic indenting of many other modes similarly. ruby-mode
seems to use ruby-indent-level
, sgml-mode
uses sgml-basic-offset
, and js-mode
uses js-indent-level
.
Upvotes: 2