Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

3 Answers 3

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

To replace every instance of foo' after point withbar', use the command M-x replace-string with the two arguments foo' andbar'. 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

I use iedit for this. Very useful.

share|improve this answer
(defun my-replace-string ()
  (interactive)
  (save-excursion
    (beginning-of-buffer)
    (call-interactively 'replace-string)))
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.