8

I use CTRL-O and CTRL-I heavily to move between previously visited positions. These commands rely on the jumplist.

It makes sense to me to visualize the jumplist as a stack of my position history. Thus, I'm surprised that the jumplist is effectively indexed by file and line number, which you can deduce from the vim docs.

In motion.txt:

If the same line was already in the jump list, it is removed. The result is that when repeating CTRL-O you will get back to old positions only once.

It's a bit annoying to me because it doesn't preserve the exact history. Maybe I'm not conceptualizing the feature as intended. My questions:

  1. Is there a way to customize this behaviour?
  2. More importantly to me, what's the reason it was implemented this way?

Example

Take some file with >= 3 lines, do the following movement commands, and view the line numbers in the jumplist.

1G
2G
3G
2G
G "some movement to persist the last jump to the jumplist

Expected

1
2
3
2

Actual

1
3
2
1

2 Answers 2

3

The 'jumpoptions' option is not yet supported in Vim (it is only supported in Neovim). The following pull request was created to add this support:

https://github.com/vim/vim/pull/7738

But this is not merged (refer to the the discussion in the PR).

2
  • just curious, why did you close your PR?
    – Mass
    May 14, 2021 at 3:11
  • Merged in 9.0.1921. Sep 22 at 3:28
0

I think the jumpoptions is the setting which you're looking for. Put the following into your vimrc/init.vim:

set jumpoptions=stack

For more information, take a look into :h 'jumpoptions'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.