See the following example:
" open a file with 20+ lines.
1gg " jump to line 1
3gg " jump to line 3
5gg " jump to line 5
7gg " jump to line 7
ctrl+O " back to line 5
ctrl+O " back to line 3
20gg " jump to line 20
ctrl+O " back to line 3
ctrl+O " back to line 7!!!! But what I expected is back to line 1
I read :h jumplist
and know why I get this result.
But this bevior is really annoying for me (I use vim to read c++ code and jump through function call stack frequently), what I want is:
After ctrl+O
and make a new jump, vim can erases jump tags that are later than current position in the jumplist.
CTRL-T
command? It goes back in the tag stack, which works differently from the jumplist and (I think) closer to what you want.ctrl+i
for going forward in jumplist. And if you just clear the later jumps from the current position, you can't usectrl+i
. So, it will never be the official behavior. But you can maybe use:h getjumplist()
to create your own plugin with your wanted behavior.