how to jump back to the previous edit place

Viewed 18664

Is it possible to go back to the previous edit place in vim? I know using marks, one can move back and forth between different places within a file, but I don't know whether or not vim could automatically remember the previous edit place for you.

5 Answers

I use the following (from the documentation):

g;          Go to [count] older position in change list.

g,          Go to [count] newer cursor position in change list.

Do :help g, to read more about this

The last change is held in the mark named . so you can jump to the mark with `. (backtick, dot) or '. (apostrophe, dot). See:

:help mark-motions
:help '.

ctrl+o
ctrl+i to go forward (once you've gone backward, of course)

To jump to the last edit position type gi.

I used to use u then Ctrl-r before I learned about '.

Related