-1

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?

Abhishek Bhagate
  • 5,583
  • 3
  • 15
  • 32
  • 1
    Sharing your research helps everyone. Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer! See also: [ask] – rizerphe Jun 19 '20 at 04:37

2 Answers2

0

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.

fstamour
  • 760
  • 4
  • 9
0

ty for your answer, I had resorted to using: (evil-global-set-key 'normal (kbd "Q") 'format-all-buffer)

which is the manual way perhaps, but yours is better!