Emacs Tip: Make CSS mode sane

The default CSS mode in emacs does very funny things with indentation if you like leaving the brace on the same line as the definition. As with everything in emacs, this is fixable with a few lines of config. In this case:

 ;;; Fixes totally weird default css formatting.
 (require 'css-mode)
 (setq cssm-indent-level 4)
 (setq cssm-newline-before-closing-bracket t)
 (setq cssm-indent-function #'cssm-c-style-indenter)
 (setq cssm-mirror-mode t)

I can’t remember where I found this on the internet, but here it is, repeated again, so more folks can find it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s