Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Emacs, how can I jump to the top of the file and then return to where I came from?

Tags:

emacs

In Vim, Ctrl-I takes the cursor back to its previous location (before the last jump). Ctrl-O is its complement, moving forward through the jumplist. gg jumps to the top of the file, so Ctrl-I then jumps back.

The equivalent to Ctrl-I in Emacs would be C-u C-space. However, the obvious way to get to the top of the file, Home, doesn't set the mark, so there's no way to return to the line you came from that way.

Is there a better set of commands for getting to the top and bottom of the file (and perhaps other places) that does respect the mark ring? Or is there a better way to reverse Home?

like image 288
Peeja Avatar asked Oct 22 '15 15:10

Peeja


1 Answers

C-SPC M-< to go to the top. C-u C-SPC (or C-x C-x C-g) to get back again.

(C-x C-x g does not change the mark-ring. C-x C-x swaps point and mark, and activates the region. C-g then deactivates the region.)

like image 72
Drew Avatar answered Sep 29 '22 02:09

Drew