2

I have a Vim Session file I created by doing:

:mksession

Then I quit Vim. I then downloaded a plugin to:

${HOME}/.vim/pack/vendor/start/vim-markdown-folding

and then I fired up Vim with the session file by doing

vim -S Session.vim

Then I attempted to open the help docs for the vim-markdown-folding plugin by doing:

:helptags ALL
:help markdown-folding

Which Vim told me that it didn't exist. So I opened a new terminal tab, and tried it in a different vim session without loading the Session file. The help command worked. So I tried then to :source $MYVIMRC in the Vim that loaded the Session.vim and it still didn't update the loaded plugins. The only other way I can think of to do this is to delete the Session.vim file and reposition all my open splits and windows, which I DO NOT want to do.

How do I make Vim update the Session.vim file and the list of plugins that should be loaded when editing certain files without deleting the existing Session.vim and losing all those settings?

Why would the Session.vim file detail the plugins loaded or not update them when I tell it to :packadd or to :mksession! again or reload my $MYVIMRC?

Comment Chat is here

8
  • 2
    What is set ssop? Especially, does it include options?
    – Matt
    Commented Jun 28, 2020 at 6:38
  • I don't have ssop set anywhere in my vimrc. I did a recursive grep through the plugins I have, and nothing is in there either.
    – FilBot3
    Commented Jun 28, 2020 at 13:15
  • There is also no ssop setting in the Session.vim file.
    – FilBot3
    Commented Jun 28, 2020 at 13:16
  • What I asked is the value of 'ssop'. If you haven't touched it then it does include options and then it's no surprise it worked that way. Read :h 'ssop' and :h 'rtp' then have a look into your session file, and you probaly will be able to explain what happens yourself.
    – Matt
    Commented Jun 28, 2020 at 13:24
  • my default :set sessionoptions? is sessionoptions=blank,buffers,curdir,folds,help,options,tabpages,winsize,terminal
    – FilBot3
    Commented Jun 28, 2020 at 13:43

1 Answer 1

2

With the help of @Matt, we were able to get my new plugins loaded, and markdown folds working.

  1. Open vim with the session file

    vim -S Session.vim

  2. Modify sessionoptions by removing options and folds from the sesion options

-- :set sessionoptions=blank,buffers,curdir,folds,help,options,tabpages,winsize,terminal
++ :set sessionoptions=blank,buffers,curdir,help,tabpages,winsize,terminal
  1. Save the session

    :mksession

  2. Quit and restart Vim with the session file again.

    • This should load up all the new plugins that were added after the initial plugins were saved in the session file. This will also allow any folding plugins to perform their function.
  3. With all the new plugins loaded, folds set, check the sessionoptions again. It should have the original options set.

  4. Save the session again.

    :mksession!

  5. Quit and start Vim again with the Session file.

This should have all the relevant packages loaded, folds set, and windows in their position. To help make this easier and quicker to run the following

vim -S Session.vim \
    -c "set sessionoptions=blank,buffers,curdir,help,tabpages,winsize,terminal" \
    -c "mksession!" \
    -c "q"

vim -S Session.vim \
    -c "mksession!" \
    -c "q"
1
  • Please accept your own answer. Your solution works great! Commented Mar 27, 2023 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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