Emacs: Save Cursor Position

By Xah Lee. Date: . Last updated: .

You can save the cursor position for every file you opened. So, next time you open the file, the cursor will be at the position you last opened it.

Put this code in your emacs init file:

;; remember cursor position, for emacs 25.1 or later
(save-place-mode 1)

For before emacs 25.1, the syntax is different. Use this code:

;; remember cursor position
(if (version< emacs-version "25.0")
      (require 'saveplace)
      (setq-default save-place t))
  (save-place-mode 1))

By default, the cursor position info is saved at ~/.emacs.d/places

The file location is controlled by the variable save-place-file.

saveplace.el is written by Karl Fogel since 1993. Karl is also the author of Emacs's Bookmark Feature. [see Emacs: Bookmark] Thanks Karl.

Emacs Show Line/Column Number

If you have a question, put $5 at patreon and message me on xah discord.
Or support me by Buy Xah Emacs Tutorial

Emacs Tutorial

Emacs Init

Emacs Keys


ELisp Examples

ELisp Write Major Mode

Emacs Init

Init Basics


text editing