I have enabled several C cleanups for Emacs by setting the c-cleanup-list variable, and then enabling electric and auto-newline modes. Unfortunately, this only formats the code as you’re typing it. I would like to format code that has already been written. Is there a quick way to do this?
Cheers!
I employ a simple cleanup function:
that I’ve assigned a global keybinding to:
You can put your cleanups in a similar function and invoke it instead. You can also make Emacs trigger such a function on buffer save(or some other event) – have a look at the after-save-hook.