When I start vim and I want to return to the last location in the jump list, I would like to do so with a single <C-O>
. However, right now I have to press twice <C-O><C-O>
to achieve this.
In order to better understand this, I narrowed down the behavior by deleting viminfo, moving my vimrc away (i.e. vim starts only with defaults.vim
), opening a single file and then restarting vim without any argument.
When I then enter :jumps
, I get following output
As you can see the first entry in the jump list points to no file and I "move" the current position to this entry when I press the first time <C-O>
. This can be confirmed by running :jumps
after the first <C-O>
.
Vim help says
If the pointer is below the last entry, this indicates that you did not use a
CTRL-I
orCTRL-O
before. In this case theCTRL-O
command will cause the cursor position to be added to the jump list, so you can get back to the position before theCTRL-O
.
Can someone confirm/explain this to me and maybe point out how this could be resolved?
UPDATE
IMHO if <C-O>
is invoked the first time and the newly added entry for return as described in the helpfile is identical to the first entry, it should be skipped and does not need to be added.
Chapter 29 of the user manual suggests to use '0
to return to the last position when you exited vim. I will consider to use this instead. However, <C-O>
has the advantage to jump to older entries in the jumplist. Therefore, I still like to know why vim has this behaviour.
Vim version: 8.1.950
'"
, see:h 'quote
, to get to the position I left the file before. Then I can use <C-O> or <C-I> naturally, not requiring to double tap them. Don't know how to solve your problem though, just wanted to share.:map <c-o>
No mapping found
. BTW, I mentioned in my question that I have removed my own vim config. This could only have been a mapping in a system vimrc or in defaults.vim which I would not have been aware of. Could you try it for yourself? I would appreciate a confirmation by others. I think the comment by klaus is an implicit confirmation by him.jumplist: avoid extra tail entry
. It was discussed in issue #9775 and the corresponding PR is #9805. I assume when neovim 0.4 will be released, neovim users will have a different behavior than vim users.