Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the vim command for moving my cursor to the line it was previously on?

Tags:

git

vim

Let's say I'm on line 100 of myfile.txt. I type 200-G to move to line 200. Is there a shortcut to move the cursor back to line 100?

I wish for this all the time, given that I usually don't note the line number (100) before I jump to line 200. I just know I want to go back.

In case this doesn't make sense, I'm asking for vim's line equivalent of git checkout -.

like image 991
Bryce Johnson Avatar asked Feb 03 '26 00:02

Bryce Johnson


2 Answers

CTRL + O

See :help jumplist for more informations about cursor location.

like image 113
Dominic Beauchamp Avatar answered Feb 05 '26 13:02

Dominic Beauchamp


I use '' (two single quotes) to move to the beginning of the previous line. If you want to return to the previous column as well, then press two backtics ``

like image 21
Jim U Avatar answered Feb 05 '26 12:02

Jim U