set sessionoptions+=globals 
    if !exists('g:EGbufs')
        if exists('g:EGbufsstring')
            exe "let g:EGbufs=".g:EGbufsstring
            let g:EGbufs = {}

I have this in my .vimrc. When I load a session, I can :echo g:EGbufsstring for the right result.

But for some reason, my second exists conditional fails, and so g:EGbufs is set to a empty dictionary. There might be another bug, but I've used echo and echoerr around this code to check the value of the string and it tells me the variable doesn't exist.

Does a vimsession get loaded AFTER the .vimrc? The only work around I can think of is writing to a file the string I want to load, and reading it in the vimrc. I'm already trying to work around lack of support for saving dictionaries in a session. I guess my other option is to run this load conditional in the function that I need it, but that's just a little ugly.


Ah, I thought I had it with autocmd SessionLoadPost call LoadBufsString() but I can't seem to make it work. Thought it might be because it only triggers on manual :mks but that is not the case either. Probably I just need to sort out the syntax.

  • Try removing doubled s in EGbufSString - or you have a typo in the question?
    – grodzik
    Commented Dec 29, 2016 at 20:10

1 Answer 1


I think I found my answer. autocommand with the

|SessionLoadPost| after loading a session file

event. It hit me when I realised I want something to trigger this code.

autocmd SessionLoadPost * call LoadBufsString()

does it. I needed to specify * for the filematcher, for some reason. Not sure if that is mandatory for all autocommands.

  • You can use the parameter to filter specific session filepaths (e.g. autocmd SessionLoadPost myproject/*.session ...). All autocommands take a parameter like that. Commented Apr 22, 2017 at 7:55

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.