4

I often save my session using the following:

  • In vim: mksession! ~/session.vim
  • In gvim: mksession! ~/sessionX.vim

However, when I invoke vim with a sourcing of ~/session.vim, I'm finding that ~/sessionX.vim also gets sourced:

vim -S ~/session.vim

The regular expression session[Xx] does not occur in my vimrc. This file is used by both vim & gvim; it contains if-statements to distinguish between vim & gvim, and executes the appropriate code.

I did a recursive grep in /usr/share/vim for session[Xx] without any hits. I did the same recursive grep in ~/.viminfo and ~/.vim (the latter is a folder). The only place where session[Xx] occurs is in ~/.viminfo, and that occurrence is simply the historical record of my mksession command from a prior gvim session. I removed the .viminfo file, but the sessionX.vim still gets sourced.

I tried to track down what leads to the sourcing of sessionX.vim using verbose messages:

cd ~
'rm' -f vimLog.txt
vim -c 'set nomore' -V2vimLog.txt -S session.vim

This logs the startup at verbosity level 2, but I also tried verbosity level 10 (the default). I can't discern anything obvious about what statements in what files are causing the rogue sourcing. (I can post an anonymized version if anyone thinks this is helpful).

Can anyone suggest another avenue of tracking down the rogue sourcing?

  • What do you get with :echo v:this_session? – romainl Mar 31 '16 at 6:34
  • I get ~/session.vim. But I VanLaser's answer seems to solve the problem. Thanks anyway. – user2153235 Apr 1 '16 at 1:53
6

See :h :mksession, the 10th point:

  1. If a file exists with the same name as the Session file, but ending in "x.vim" (for eXtra), executes that as well. You can use *x.vim files to specify additional settings and actions associated with a given Session, such as creating menu items in the GUI version.

... I have a feeling this is the issue.

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.