Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

How can I restore cursor position in Vim as it was before scrolling, selecting or PgUp/PgDn?

I'm tired of searching where I was before I scrolled up to look something at the top.

Are there something like "Prev cursor position" and "Next cursor position" commands (like 'u' and 'R' for regular undo/redo)?

Example: Looking somewhere in the middle of the source file (no editing), then jumping to the top (1G) then failing to find where you was before that. Of course, no marks set. (I know that I can use ":sp" to view several places simultaneously).

Update. The question is still open, I have received a follow-up:

The answerers didn't understand your question and the answers were too weak of a solution. c-o & c-i don't work for movements.
If I understood correctly, I find that your question was un-answered and that you were looking for a solution for a scenario like this:
As I am vim beginner I frequently do incorrect movements and actions and would like to undo them as though I had never pressed anything, returning to my previous editing location before I started messing up.

So, are there any standard or non-standard (involving patches to Vim or Vim extensions) ways to make it remember the cursor movement history?

share|improve this question
  • Ctrlo goes back in jump list
  • Ctrli goes forward in jump list

additionally i would consider to set a mark via m' and when done with scrolling press ''.

share|improve this answer
OK, Ctrl+o jumps me to the place where I was editing. How to just to the place where I was looking? I enter "1G" to jump to the beginning and don't know how to jump back (I wasn't editing). Of course mark is not set and I haven't used ":sp". – Vi. May 21 '10 at 17:17
@Vi: no, ctrl-o jumps to where your last jump was (jump list). g; goes where you edited last – akira May 21 '10 at 17:28
1. "vim initrd.txt". 2. 5 times PgDn, 10 times Down. 3. Hold PgUp until hit the top. 4. Ctrl+o? No, It's just jumped to the top. 5. Crtl+o again? It opened some other file... I don't understand what exactly Ctrl+o does, but it doesn't just undo the last cursor movement command. – Vi. May 21 '10 at 18:32
i know, it is using the "jump list" .. :help jumps ... thats why i meant, probably a good idea to use the markers. if you want to jump around in your file and you want to go back to THAT place you started: set a mark, jump around and then come back with ''. – akira May 21 '10 at 20:05
So I can't make Vim replay text and cursor scroll history backwards (I also expected it will handle mouse scrolling in gvim), right? I expected that while holding Ctrl+O is see my text movements reversed, finishing at just opened file positioned in the beginning. – Vi. May 21 '10 at 22:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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