Reputation: 65
I have just begun to learn using vim, and been reading the manuals for a while and trying things out.
To cite the vim reference at [http://vimdoc.sourceforge.net/htmldoc/motion.html#jump-motions][1]
There is a separate jump list for each window. The maximum number of entries is fixed at 100.
When you split a window, the jumplist will be copied to the new window.
I have actually tried a few experiments to confirm that second point; when you cause a new window to be created (split a window, create a new tab etc), the jump list of the original window is copied to the new window.
Since each window's jump list is independent, each one evolves differently based on the jump commands used in its specific window.
My question is, when it comes time to write the jump list to the .viminfo, and we have several windows open, each with its own different jump list, which one will be saved to the .viminfo? From what i observe, it is the one in the window from which the quit command (:q[!]) is given.
Is this true all the time, or are there any exceptions?
Thanks, Arun
Upvotes: 2
Views: 556
Reputation: 172590
Your observations are right. This is implemented in src/mark.c
, function write_viminfo_filemarks(fp)
:
/* Write the jumplist with -' */
fputs(_("\n# Jumplist (newest first):\n"), fp);
setpcmark(); /* add current cursor position */
cleanup_jumplist();
for (fm = &curwin->w_jumplist[curwin->w_jumplistlen - 1];
fm >= &curwin->w_jumplist[0]; --fm)
{
if (fm->fmark.fnum == 0
|| ((buf = buflist_findnr(fm->fmark.fnum)) != NULL
&& !removable(buf->b_ffname)))
write_one_filemark(fp, fm, '-', '\'');
}
The curwin
is defined in src/globals.h
:
EXTERN win_T *curwin; /* currently active window */
So, it indeed uses the jumplist from the window that is current when the viminfo file is written / when Vim is quit.
Upvotes: 2