I can’t find how to save modifiable and readonly states with :mksession.

Is it even possible?

1 Answer 1


Did you look at the help for :mksession? There it mentions an option 'sessionoptions' and if you read that help section you'll see there are various values that dictate what kind of information :mksession saves. In your case you need the options value:

options : all options and mappings (also global values for local options)

(I tested it with your two examples, 'modifiable' and 'readonly', fyi.)

So you can do

:set sessionoptions+=options

What's odd, though, is that options is one of the defaults (along with blank, buffers, curdir, folds, help, tabpages and winsize). Is 'sessionsoptions' (or 'ssop') getting modified in your vimrc or something?

  • Thanks a lot. I’ve read the help but probably I didn’t understand that part about options and I looked specifically for those that I needed. I checked my vimrc and found out that I messed with ssop. It was from the first time I tried to use sessions.
    – Alekh
    Dec 17, 2018 at 4:10
  • And still it does not save file encoding…
    – Alekh
    Dec 17, 2018 at 4:22
  • Are you talking about 'fileencoding'? There's no reason for it to save that in session data. File encoding is directly associated with the buffer file. Save the buffer and the file will be written to disk with that encoding.
    – B Layer
    Dec 17, 2018 at 9:05
  • Yes, it’s about fenc. The problem is when I start the session Vim opens the file with incorrect encoding and I have to manually :view ++enc=….
    – Alekh
    Dec 18, 2018 at 10:00
  • Try opening the file normally (e.g. :e file), do :set fileencoding=XXX where XXX is whatever it's supposed to be, and save it. Next time you open it it should have encoding XXX. If that doesn't work I suggest you submit a new question with all the details.
    – B Layer
    Dec 18, 2018 at 16:19

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.