I am wondering about a improvement for vim that I can jump back for where I was the last time I stopped to move around for like 3 seconds. Then I can scroll around and have a kick shortcut to jump back where I was with the same old CTRL+o.
Vim put a lot of movements in the :jumps list and I wondering that half of that is useless in any moment for me, so how could I do that ?
In any another words I'm trying to make the jumplist more sensible.
ps: Netbeans and VS has a similar behavior.
To have the current position automatically added to the jump list, you can utilize the CursorHold
event:
:autocmd CursorHold * normal! m'
Navigation is with the default <C-o>
/ <C-i>
.
It's common to use the m
and '
commands to jump around. For instance, you can type mx
, go off and do some things, and then do 'x
to jump back to where you were when you did mx
. This works for every letter of the alphabet (i.e. ma
, mb
,... mz
). Uppercase marks (mA
, mB
,...) will also remember the filename so you can jump between files. There are a number of other special marks you can set for various purposes.
The "previous context mark" is called '
. It is set automatically when you jump around, and can also be manually set with m'
. Jump to it with ''
. The m'
command also manually adds a jump to the jumplist. ''
is roughly equivalent to Ctrl+O, but doesn't take a count.
If you replace the apostrophes in these commands with backticks, Vim will jump to the specific column rather than just the line. In practice, apostrophe is easier to type and often close enough.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With