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
Vim help says
If the pointer is below the last entry, this indicates that you did not use a
CTRL-Obefore. In this case the
CTRL-Ocommand will cause the cursor position to be added to the jump list, so you can get back to the position before the
Can someone confirm/explain this to me and maybe point out how this could be resolved?
<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