Search code examples
emacsevil-mode

Remap evil mode write


I have format-all-buffer, and currently I'm calling it in normal mode with the ~ key...

But I figured I would love to call it always when doing :w to write the file as well... is there a way to do both things?


Solution

  • If I understand correctly, you want to call the command format-all-buffer every time you save a file.

    You can use hooks for that, add this to your config:

    (add-hook 'before-save-hook 'format-all-buffer)
    

    P.S. You can type that in the buffer named *scratch* and use C-M-x or eval-buffer to evaluate this piece of code.