Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In emacs, when i am editing a program, and miss-input some command and make the cursor jump to somewhere in other files. Is there a short-cut key or command to jump back to the last location of the cursor?

share|improve this question
up vote 30 down vote accepted

I believe what you are searching for is pop-global-mark, usually bound to C-x C-@ and C-x C-SPC.

The global mark ring is updated automatically on many occasions such as buffer switching, accidental or otherwise.

share|improve this answer

You can use the command previous-buffer which in my version (GNU Emacs 23.2.1) is bound to C-x left-arrow by default.

Just type Meta-x describe-key C-x left for further information

There is also winner-mode that binds C-c left arrow to winner-undo which in short allows you to undo any change done to your windows.

share|improve this answer
C-x C-x

It will also highlight everything between your previous cursor location and the new location (if you want to get rid of the highlighting, just C-g). You can set the location where you will jump back to with C-space. So, for example, you might plan to use this with:

cursor at the start of a paragraph


move cursor to the end of the paragraph

C-x C-x

(the entire paragraph is now highlighted)


(the paragraph is now in the copy buffer, ready to be pasted elsewhere with C-y)

share|improve this answer
It seems the cursor cannot jump between different files/buffers. – Kim Feb 5 '11 at 10:45
Ah, I misunderstood, I'm sorry. Are you jumping to a different frame? A different window (different file inside the same frame)? Something else? What command are you entering by mistake: are you closing the current buffer or frame by accident? – drewbenn Feb 5 '11 at 10:54
in the same frame but different file. – Kim Feb 6 '11 at 3:12
I use this one quite often, but it will only take you back to your last position. Joseph's pop_global_mark will take you back to your last position and then keep going to several more past positions. – JS. Feb 26 at 18:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .