You can save and restore Vim sessions to continue working with the same setup before you had to quit Vim for reasons like switching off the machine, switching to another project, etc.

  • :mksession proj.vim save the current Vim session with details like cursor position, file list, layout, etc
    • you can customize things to be saved using the sessionoptions setting
    • for example, :set sessionoptions+=resize will save resized window information as well
  • :mksession! proj.vim overwrite existing session
  • :source proj.vim restore Vim session from proj.vim file
    • vim -S proj.vim restore a session from the command line when launching Vim

info See :h 21.4, :h views-sessions and :h 'sessionoptions' for more details.

info See stackoverflow: How to save and restore multiple different sessions in Vim? for custom settings to automate the save and restore process and other tips and tricks. See also Learn-Vim: Views, Sessions, and Viminfo.

Video demo:


info See also my Vim Reference Guide and curated list of resources for Vim.