Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It is really inconvenient to first go back to the buffer top and then do the search/query. Well, for search, it is relatively simple that you can just press C-s one more time to wrap around, but for query/replace, it's tedious.

Any simple hack to do that without going back to the buffer top for both operations?

share|improve this question

Huh, looks like you can't (taken from here, emphasis mine):

To replace every instance of 'foo' after point with 'bar', use the command M-x replace-string with the two arguments foo and bar. Replacement occurs only after point, so if you want to cover the whole buffer you must go to the beginning first.

Personally, I split the buffer in two (C-x 2), go to the top (C-Home) and then run the replace command, switch back to my original pane (C-x o) and then kill the second (C-x 0). Don't know if there is a trick to make that simpler.

share|improve this answer
(defun my-replace-string ()
    (call-interactively 'replace-string)))
share|improve this answer
Works nicely, but screws up query-replace on region/selection (always does on the whole buffer). – Alex Jan 8 '15 at 8:34

I use iedit for this. Very useful.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .