electric-indent-mode is enough to keep your code nicely
aligned when all you do is type. However, once you start shifting
blocks around, transposing lines, or slurping and barfing sexps,
indentation is bound to go wrong.
So long as you have Melpa configured, you can install it with.
Then simply turn it on and you’ll never have unindented code again.
This will activate aggressive-indent-mode on every non-text buffer. If you're
a little shy, you can also turn it on only for specific major modes by using
hooks.
Here’s some code to try it on. After you’ve evaluated the above, open
a new “.el” file, paste the following code, and type something
before the opening parentheses.
Aggressive Auto-indentation
28 Sep 2014, by Artur Malabarba.Emacs.SE Lessons post series
electric-indent-mode
is enough to keep your code nicely aligned when all you do is type. However, once you start shifting blocks around, transposing lines, or slurping and barfing sexps, indentation is bound to go wrong.Today’s lesson is my answer to mgoszcz2's question. Having the perfect auto-indent is easier than you might think. I've turned this post into a package. Emacsers, meet aggressive-indent.
So long as you have Melpa configured, you can install it with.
Then simply turn it on and you’ll never have unindented code again.
This will activate
aggressive-indent-mode
on every non-text buffer. If you're a little shy, you can also turn it on only for specific major modes by using hooks.Here’s some code to try it on. After you’ve evaluated the above, open a new “.el” file, paste the following code, and type something before the opening parentheses.
Update <2014-10-20 Mon>
Announce new package!
Tags: indent, init.el, emacs,
Longlines mode in LaTeX »
« Updating org-mode #+INCLUDE: statements on the fly
Related Posts
Aggressive-indent just got better! in indent
Content © 2019, All rights reserved. Icons under CC3.0.