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.
To Save a Session ( :mksession , :mks )vim file on the directory where the current Vim execution was started. Using exclamation mark, :mks! the command overwrites Session. vim file if it exists in the directory. You can specify a custom file name to save the session :mks!
You can save the current session (or buffer layout) by giving the command :Obsession . If you don't supply an argument, it writes a session file called Session. vim by default. To reload a session, either use vim -S <session-name> or :source <session-name> if you're inside Vim already.
:wa - save all tabs / unsaved buffers. :xa / :wqa - save all tabs / unsaved buffers and exit Vim.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With