1. Frank Fischer
  2. evil
Issue #117 open

RFE: Go back to where the point was before evil-search-forward

created an issue

To simulate what I would like to do, you could set a marker right before the search, and then pop it, e.g.: {{{ mm /foo<RET> nnnn `m }}}

I wish some marker were set automatically as the search started.

The rationale would be to make this closer to the emacs isearch behavior, where if you isearch for a string, go through a few matches by pressing C-s repeatedly, and then hit C-g, you will be returned to where the search began. Currently, with the evil-search-forward, when you start going through matches by pressing 'n', the starting point gets forgotten. It can be retrieved through repeated applications of evil-jump-backwards, but this isn't as convenient as a single keypress.

Comments (1)

  1. Vegard Øye

    You can modify the evil-search-forward and evil-search-backward commands with the following:

    (defadvice evil-search-forward (before marker activate)
      "Store the current position in the '/ marker."
      (evil-set-marker ?/))
    (defadvice evil-search-backward (before marker activate)
      "Store the current position in the '? marker."
      (evil-set-marker ??))

    I don't know if '/ and '? are the best choices here, but if this is to become part of Evil, we have to choose something that doesn't have a special meaning in Vim. Suggestions are welcome.

  2. Log in to comment