6

After modifying multiple files, how can I save all their buffers?

Malabarba
  • 22,878
  • 6
  • 78
  • 163
elarson
  • 601
  • 4
  • 8
  • `multi-occur` is not dependent on projectile. It is a vanill Emacs command from standard library `replace.el`. Why mention (and link to) projectile here? Is there really something pertinent about projectile in your question? Search and replace seem to be irrelevant to the question, as well. – Drew Oct 08 '14 at 15:41
  • 1
    `C-h a` (`apropos-command`) is your friend. `C-h a save buffers` tells you about commands whose names match `save` and `buffers`. – Drew Oct 08 '14 at 15:46
  • Thanks for clarifying that `multi-occur` is built in. I mentioned projectile specifically as it is a feature and package that people may not know about. Most folks are diligent at saving while editing, so the use case of updating multiple files at a time makes more sense within the context of a library like projectile and/or multi-occur. The same goes for using a macro to edit multiple buffers. My thought was that including these libs helps widen the discoverability of helpful features. – elarson Oct 08 '14 at 17:13

2 Answers2

8

After making the changes you can save the open buffers using save-some-buffers. This is bound C-x s by default.

Here is what the docs say.

Save some modified file-visiting buffers.  Asks user about each one. 
You can answer `y' to save, `n' not to save, `C-r' to look at the 
buffer in question with `view-buffer' before deciding or `d' to 
view the differences using `diff-buffer-with-file'.

You can use C-u C-x s to save without asking.

elarson
  • 601
  • 4
  • 8
5

M-x ibuffer * u S is quite convenient for this as well, because you can add/remove selected buffers with m or u before saving with S.

Silex
  • 801
  • 6
  • 6