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.

  • 2
    Not really an answer to your question, but are you already aware of the CTRL-T command? It goes back in the tag stack, which works differently from the jumplist and (I think) closer to what you want. – Rich Dec 19 '18 at 16:30
  • @Rich I didn't known ctrl-t before and just tried it, I would say ctrl-t does help a lot, the behavior for tag stack is what I want for jumplist. However, ctrl-t is limited for tag stack, sometimes I stiil have the need for ctrl+O, but each ctrl+] adds an element in jumplist, which makes it annoying to use ctrl+O to go back. – Tiny Dec 20 '18 at 17:10
  • I have the same problem. It's really annoying, Please someone can give any help. eg. Clean jump lists after ctrl+o. – wllenyj Mar 20 at 12:27
  • This is not possible I think, i.e. there is no settings to achieve that. And this would not be desirable for most people cause we use ctrl+i for going forward in jumplist. And if you just clear the later jumps from the current position, you can't use ctrl+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. – klaus Mar 20 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.