I am new to Vim
, my code file has 300 lines, and suppose currently the cursor is on line 254, and when use gg
command the cursor turn to line 1, and I want to back to line 254 but I forget that line number. Is there a command the can do this?
And when I want to jump a line, I input :38
, and I want to jump back to the previous line, what should I do?
Asked
Active
Viewed 3,273 times
3

Sagar Jain
- 7,475
- 12
- 47
- 83

GoingMyWay
- 16,802
- 32
- 96
- 149
2 Answers
10
Ctrl+O jumps backward to the previous location.
Ctrl+I jumps forward to the next location.
:jumps
or :ju
gives you a jump list.
Use jump number
followed by Ctrl+O to jump to that particular location.
Ex: 20Ctrl+O

Sagar Jain
- 7,475
- 12
- 47
- 83
5
Use
``
(backtick, backtick)
This sends you back to the place you last jumped from. To learn more about this, type :help ''
. That whole help document is worth reading.

Greg Hurrell
- 5,177
- 23
- 27
-
if I input `:78` to line 78, and I want to jump to previous line, the `\`\`` seems just jump to line 1. What should I do? – GoingMyWay Sep 19 '15 at 06:19
-
@Alexander, could you clarify what do you mean by 'previous line'? Line 77? You can get there with `k`. – And R Sep 19 '15 at 06:51
-
This not line 77, for example the current line is `290` and I input `:77`, and now it jumps to line `77` and the previous line is `290`. – GoingMyWay Sep 19 '15 at 06:53
-
@Alexander: Just try Ctrl-O and Ctrl-I for a couple of times, you will understand. – Sagar Jain Sep 19 '15 at 06:54