In vim, right after opening a file, I can type g; to go to the place last edited. This doesn't work in evil-mode with my configuration. Is there something I can do to make it work?

  • This looks like a limitation in the package used to provide g;, goto-chg.
    – wasamasa
    Commented Nov 5, 2016 at 12:38
  • you'd have to save your session info with desktop before you quit and maybe then you can use goto-chg to view the last edit place in a file. Commented Nov 5, 2016 at 13:38

2 Answers 2


Add this to your init file:

(require 'saveplace)
(setq-default save-place t)

From saveplace.el:

;; Automatically save place in files, so that visiting them later
;; (even during a different Emacs session) automatically moves point
;; to the saved position, when the file is first found.  Uses the
;; value of buffer-local variable save-place to determine whether to
;; save position or not.
  • Thanks! I put in (save-place-mode 1).
    – Toothrot
    Commented Nov 9, 2016 at 7:51

I also use saveplace, however it actually doesn't save the point of the last edit, but the point that was last visited before closing a file.

If you want to save the last edited point, you can combine saveplace and goto-last-change. You have to install the package goto-last-change.

You have to define a function, that returns the last point saved from goto-last-change.

(defun my-last-edited-point ()
  "Return point of last edit in file."

Then you have to replace point in save-place-to-alist with my-last-edited-point. I just paste the modified function so you don't have to look for it yourself.

(defun save-place-to-alist ()
  ;; put filename and point in a cons box and then cons that onto the
  ;; front of the save-place-alist, if save-place is non-nil.
  ;; Otherwise, just delete that file from the alist.
  ;; first check to make sure alist has been loaded in from the master
  ;; file.  If not, do so, then feel free to modify the alist.  It
  ;; will be saved again when Emacs is killed.
  (or save-place-loaded (load-save-place-alist-from-file))
  (let ((item (or buffer-file-name
                  (and (derived-mode-p 'dired-mode)
               (expand-file-name (if (consp dired-directory)
                         (car dired-directory)
    (when (and item
               (or (not save-place-ignore-files-regexp)
                   (not (string-match save-place-ignore-files-regexp
      (let ((cell (assoc item save-place-alist))
            (position (cond ((eq major-mode 'hexl-mode)
                   (1+ (hexl-current-address))))
                ((and (derived-mode-p 'dired-mode)
                 (let ((filename (dired-get-filename nil t)))
                   (if filename
                   `((dired-filename . ,filename))
                (t (my-last-edited-point)))))
        (if cell
            (setq save-place-alist (delq cell save-place-alist)))
        (if (and save-place
                 (not (and (integerp position)
               (= position 1)))) ;; Optimize out the degenerate case.
            (setq save-place-alist
                  (cons (cons item position)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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