Reputation: 5301
I use M-x replace-string
or M-%
to replace strings in emacs buffer.
The problem with them is that they only replace strings in forward from the current position of the buffer. How can i force it all over the buffer ?
I do not want to do M-<
to reach the start and then do it.
Upvotes: 2
Views: 343
Reputation: 18385
Looks like this is not possible interactively. So let's put up some Elisp together.
(defun my-replace-allbuffer (str-orig str-replace)
(interactive "sString ? \nsReplace with ? ")
(replace-string str-orig str-replace nil (point-min) (point-max))
)
and bind the function to your prefered key binding.
The documentation of replace-string
(C-h f replace-string RET
) tells us it can take the optional arguments start and end of replacement.
More doc:
Upvotes: 2