1

I read that in order to navigate backwards in a jumplist. I could use ctrl+i. However I noticed that if i press that key combination extra times vim opens up files that were loaded in vim before. I am familiar with the concept of buffers and my first thought was that the file that was being loaded up was present in the buffer so I did a ls and the name of that file did not show up. My question is I would like to know why when the key combination ctrl + i is pressed multiple times it loads up older documents. How can I prevent documents that are not currently open from opening up when navigation backwards over a jumplist using Ctrl+i ?

3

My question is I would like to know why when the key combination ctrl + i is pressed multiple times it loads up older documents.

Because that's how Vim works. From different places near :h jumplist you can read:

  • A "jump" is one of the following commands: "'", "`", "G", "/", "?", "n", "N", "%", "(", ")", "[[", "]]", "{", "}", ":s", ":tag", "L", "M", "H" and the commands that start editing a new file. If you make the cursor "jump" with one of these commands, the position of the cursor before the jump is remembered.

  • Jumps are remembered in a jump list.

  • If you have included the ' item in the 'viminfo' option the jumplist will be stored in the viminfo file and restored when starting Vim.

The jumplist was designed the ease the navigation between previous locations in the files, it is normal that it remembers all of these locations.

Now about your second question:

How can I prevent documents that are not currently open from opening up when navigation backwards over a jumplist using Ctrl+i ?

I don't know of an easy way to do so. One could imagine a piece of Vimscript which would remap ctrl+i to check the position in the jumplist, check is the buffer is present in the buffer list and decide if it should make the jump or check the previous one (unfortunately I don't have time to develop that now).

But you still could be interested by the keepjumps command (:h :keepjumps). When a normal command is preceded by keepjumps it doesn't update the jumplist, that can be useful in some cases.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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