swiper-query-replace: unable to replace first match in buffer #144

zhaojiangbin opened this Issue Jun 16, 2015 · 1 comment


None yet

2 participants


To reproduce:

  1. In scratch buffer, enter a few lines of text containing a same word, say "foo".
  2. Call swiper, input "foo" as pattern. Press C-M-< to select the first match.
  3. Press M-q for query-replace.
  4. Enter "bar" as replacement.
  5. Hit RET. Notice the cursor moves to the second match and query-replace starts there, ignoring the first match.

It appears to be caused by that ivy places the cursor at the end of current match in buffer. When query-replace starts, it can only "look forward" for the match to replace. This has the consequence that swiper-query-replace is never able to replace the first match (or the only match) in buffer.

Verified with MELPA version 20150610.638 in Emacs 24.5.

@zhaojiangbin zhaojiangbin changed the title from swiper-query-replace: always starts replacing with the next match to swiper-query-replace: unable to replace first match in buffer Jun 16, 2015
@abo-abo abo-abo added a commit that closed this issue Jun 16, 2015
@abo-abo swiper.el (swiper-query-replace): Don't miss the first
* swiper.el (swiper-query-replace): Since the point is always after the
  matching thing in swiper, it's necessary to move it before it in order
  for `perform-replace' not to skip it.

Fixes #144
@abo-abo abo-abo closed this in 9df660c Jun 16, 2015
abo-abo commented Jun 16, 2015


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment