Vim goes back to the second last edited line

In vim, you can go back to the last edited line with '., But is there a way to go back to the second or last edited line? Suppose I made some changes to line 100, and then some changes to line 1, is there a quick way to go back to line 100? I know that a sign can be used, but it requires forethought ...

+8
vim
source share
2 answers

You can use jumplist ( :help jumplist ). Just use Ctrl-O to return (and Ctrl-I to go forward) to the list of last places that you either edited or jumped over ( % , / , [[ , etc.: See :help jumplist for a complete list )

To return to the place that you edited until recently, then, assuming that you did not make any other transitions, it will be Ctrl-O Ctrl-O or (I think) 2 Ctrl-O .

+10
source share

In addition to jumplist, vim also has a changelist that can be repeated with g; (for an older item) and g, (for newer items).

+9
source share

Source: https://habr.com/ru/post/651115/


All Articles