Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to jump back to the previous edit place

Tags:

vim

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.

like image 967
Haiyuan Zhang Avatar asked Jan 25 '10 09:01

Haiyuan Zhang


People also ask

How do I go back to previous cursor position in Vim?

With the CTRL-O and CTRL-I command you can go to cursor positions before older jumps, and back again.

What is Ctrl-I in Vim?

In insert mode, Ctrl-o escapes user to do one normal-mode command, and then return to the insert mode. The same effect can be achieved by <ESC> ing to normal mode, doing the single command and then entering back to insert mode. Ctrl-i is simply a <Tab> in insert mode.

How do I jump to the last line in Vim?

In short press the Esc key and then press Shift + G to move cursor to end of file in vi or vim text editor under Linux and Unix-like systems.

How do I go to a previous file in Vim?

CTRL-^ Edit the alternate file. Mostly the alternate file is the previously edited file. This is a quick way to toggle between two files. It is equivalent to ":e #", except that it also works when there is no file name.


2 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

like image 124
vorpyg Avatar answered Sep 21 '22 05:09

vorpyg


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 '. 
like image 21
DrAl Avatar answered Sep 21 '22 05:09

DrAl