When using replace-string
from the M-x while having some text selected, it only operates on that selection (specifically, on an Evil visual selection, in my case). However, if I put the same replacement in a function in my init.el
, like
(defun my-custom-replace ()
"Replaces 'foo' with 'bar'."
(interactive)
(replace-string "foo" "bar") )
it always seems to modify the entire buffer instead. How can I get this to respect the selection?