15

How I can save the state of the vim after exit and then restore this state when I open it?

So it seems like it did not close vim.

3
  • To show the previously opened files?
    – alex
    Feb 8, 2012 at 8:49
  • this and the plugins' states For example, the filesystem tree of the NERDTree plugin, the current directory and last command of the vimshell plugin.
    – itun
    Feb 8, 2012 at 9:26
  • possible duplicate of saving/restoring buffers not working in vim Feb 8, 2012 at 10:03

2 Answers 2

29

Use vim sessions, it's an awesome feature! (Adding basic usage here--Kent's answer points to these details.)

To save the current views+settings for your current editing session do:

:mksession path/to/my-session-file.vim

To open/restore the session do:

% vim -S path/to/my-session-file.vim

To overwrite previously saved session with the current one just add a !:

:mksession! path/to/my-session-file.vim
4

do you mean vim session?

give it a shot on google, you got many articles about vim session.

like http://web.archive.org/web/20120118230658/http://vim.runpaint.org/editing/managing-sessions/

or in vim

:h session

3
  • I tried to use seesion, but it does not save the last opened files.
    – itun
    Feb 8, 2012 at 9:24
  • @itun files are reopened here. and in :h session, you can see "automatically loading the files you were last working on in that project."
    – Kent
    Feb 8, 2012 at 9:44
  • Nice! I didn't know about vim sessions. This will be very useful!
    – RunHolt
    Feb 8, 2012 at 14:54

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

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