Windows 10, Emacs 25.1, Helm
I need:
Edit simultaneously all buffers. Add text "
customer/
" to the node"bodyFileName"
in all buffers.After edit save all buffers,
Is it possible?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityMaybe you can try to to use multi-occur-in-this-mode. To do that process as follows:
C-x f
then *.json)M-x multi-occur-in-this-mode
then enter your search string ("bodyFileName" for instance)e
C-x %
for instance. For each json buffer where a match occurs you will be prompted for modification.C-c C-c
q
C-x s
Update Omar is right, I have multi-occur-in-this-mode
function in my Emacs config for so long.... that I completely forgot that it is not a built-in function but a function described in Mastering Emacs.
(eval-when-compile
(require 'cl))
(defun get-buffers-matching-mode (mode)
"Returns a list of buffers where their major-mode is equal to MODE"
(let ((buffer-mode-matches '()))
(dolist (buf (buffer-list))
(with-current-buffer buf
(if (eq mode major-mode)
(add-to-list 'buffer-mode-matches buf))))
buffer-mode-matches))
(defun multi-occur-in-this-mode ()
"Show all lines matching REGEXP in buffers with this major mode."
(interactive)
(multi-occur
(get-buffers-matching-mode major-mode)
(car (occur-read-primary-args))))
C-x s
will ask you for each buffer whethere you want to save it or not, but you can also do C-u C-x s
which saves all without prompting.
multi-occur-in-this-mode
command, might be from this Mastering Emacs blog post.
grep-mode
and thenwgrep
to edit multiple buffers and save, and I also usemultiple-cursors
when inwgrep
mode. There are undoubtedly other methods ...