Install elpa-aggressive-indent by entering the following commands in the terminal:
sudo apt update sudo apt install elpa-aggressive-indent
Emacs minor mode that reindents code after every change
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. . aggressive-indent-mode is a minor mode that keeps your code always indented. It reindents after every change, making it more reliable than electric-indent-mode.