VIM - How can I put my current position in the jumplist?

I am wondering how to improve vim so that I can go back where I was the last time I stopped to move around for about 3 seconds. Then I can scroll and have a shortcut to jump back where I was with the same old CTRL + o.

Vim has put a lot of moves in the jump list and I'm wondering if half of this is useless at any given moment for me, so how can I do this?

In any other word I am trying to make the jumplist more sane.

ps: Netbeans and VS have similar behavior.

+3


source to share


2 answers


To automatically add the current position to the jump list, you can use the event CursorHold

:

:autocmd CursorHold * normal! m'

      



Navigation is by default <C-o>

/ <C-i>

.

+6


source


It is generally accepted to use the team m

and '

for the transition. For example, you can type mx

, leave and do something, and then do 'x

to get back to where you were when you did mx

. It works for every letter of the alphabet (ie ma

, mb

... mz

). Top marks ( ma

, mb

, ...) will also remember the file name, so you can switch between files. There are a number of other special characters that you can set for different purposes.

"previous context mark" is called '

. It installs automatically when you jump, and can also be manually installed using m'

. Navigate to it with ''

. The command m'

also manually adds a transition to the jumplist. ''

roughly equivalent to Ctrl + O, but does not accept counting.



If you replace the apostrophes in these commands with backslashes, Vim will jump to the specific column, not the line. In practice, the apostrophe is easier to type and often closes enough.

+5


source







All Articles