3

As per vim wiki:

Vim remembers the locations where changes occurred. Each position (column number, line number) is recorded in a change list, and each buffer has a separate change list that records the last 100 positions where an undo-able change occurred.

One can then use g; to move to the last change in the change list. This list survives through different sessions. This means, that even if one did not make any change to the file after opening it in a new session, g; will move the cursor/point to the line where the latest change occurred in previous session.

From what I can tell, evil-mode does not have the change list per buffer which survives session. Or does it?

user3156459
  • 1,123
  • 2
  • 9
  • 17

2 Answers2

0

You probably want to have a look at Undo Tree, which is used by evil-mode if undo-tree is installed. I do not think that it has the g; functionality that you describe though. It can, however, maintain undo history between sessions.

  • Well, `Undo Tree` is `evil-mode`'s dependency. I suspect that the issue is tied somehow to `Undo Tree`, as its branching model of keeping the undo history is a bit unintuitive: hitting `u` in evil-mode will not undo the change if you are at a brach tip of the undo list. And `evil-mode` binds g; to `(goto-last-change ARG)`. So, it should be, I thought, possible to use it across the sessions, perhaps by doing away with the tree model of `Undo-Tree`. – user3156459 Sep 06 '16 at 08:02
0

Take a look at goto-last-change on melpa. Evil has default integration through g;.

  • 1
    This function is defined in [Goto-chg](https://www.emacswiki.org/emacs/GotoChg), which is a dependency for `evil-mode`. It does not seem to provide the cross-session "'changes" list. There is some discussion about [goto-last-chage here](https://www.emacswiki.org/emacs/GotoLastChange), and it seems to also to use `buffer-undo-list`, the value of which does not survive sessions. – user3156459 Sep 13 '16 at 08:02
  • I suspect the key difference is that vim maintains two lists: `changes` and `undo`. All emacs' implementations seem to use `buffer-undo-list`. – user3156459 Sep 13 '16 at 08:03