I use M-x query-replace on Emacs (M-%) quite often, and I like that I have the flexibility to choose between these options:
Spacebar Replace text and find the next occurrence
Del Leave text as is and find the next occurrence
. (period) Replace text, then stop looking for occurrences
! (exclamation point) Replace all occurrences without asking
^ (caret) Return the cursor to previously replaced text
Is there a way to:
Cycle back to the beginning of the document after we hit the end of the document?
Reverse the direction of the search-and-replace in the middle of the execution of the command.
query-replace-string(and its regexp sibling) only go forward, you'd have to rewrite a big chunk of code to go backward. There's no option to wrap (there might be a package out there somewhere), but that's easy to work around:M-<(beginning-of-buffer), do the replacement,C-2 C-SPC(go back to the next-to-last mark set (byM-<)). – Gilles Sep 16 '12 at 1:35query-replace(As for your question, can't help you.) – Emanuel Berg Sep 16 '12 at 9:26