sponsor Vim development Vim logo Vim Book Ad

session_dialog.vim : manage vim sessions using dialogs and the command line

 script karma  Rating 56/29, Downloaded by 1704  Comments, bugs, improvements  Vim wiki

created by
David Liang
 
script type
utility
 
description
session_dialog.vim provides a simple dialog and command-line based
interface to Vim's :mksession feature. There are commands to save sessions
and restore, delete, and list sessions from multiple locations. It works
well with the terminal as well as console dialogs in GVIM (set
guioptions+=c), and provides command-line completion of session names.

Usage:
:SessionSave [SESSION]
  With no arguments, displays the save dialog. Otherwise, saves a new
  session with the given name in SessionSaveDirectory. The session file on
  disk will have the SessionFilePrefix and SessionFileSuffix attached (see
  "Options" below). Spaces are allowed in the sesison name.
  e.g. :SessionSave foo bar creates the session "foo bar"

:SessionRestore [GLOB_PATTERN]
  With no arguments, displays the restore dialog. Otherwise searches for a
  session to load in SessionPath. If more than one session was found (if
  sessions with the same name were found in different paths or if the
  given pattern matched multiple sessions), you will be prompted to choose
  one.
  e.g. :SessionRestore foo*

:SessionDelete [SESSION|GLOB_PATTERN]...
  Displays the delete session dialog if no arguments were given, otherwise
  deletes all the sessions that match the arguments. Spaces need to be
  escaped since they would otherwise separate the arguments.
  e.g. :SessionDelete foo will delete the session named "foo". If more
  than one session is named "foo", you will be prompted to select one. You
  can also use a pattern (e.g. :SessionDelete foo*). This will delete all
  sessions beginning with "foo".

:SessionList [GLOB_PATTERN]...
  Prints a list of all the sessions and their locations in SessionPath if
  no arguments were given. Otherwise prints a list of sessions that match
  the arguments.
  e.g. :SessionList foo bar* *baz will show all the sessions named foo,
  starting with bar, or ending with baz.

ZS ZR ZD ZL
  The default normal mode mappings for :SessionSave, :SessionRestore,
  :SessionDelete, and :SessionList, respectively. These can be disabled
  with the option SessionCreateDefaultMaps. Note that these will time out,
  unlike native commands such as ZZ. (see :help 'timeoutlen')

You can also map the commands yourself using:
  <Plug>SessionSave
  <Plug>SessionRestore
  <Plug>SessionDelete
  <Plug>SessionList

Options:
g:SessionSaveDirectory
  Default is "$HOME"
  Where to save new sessions. This can be set in your vimrc or while Vim
  is running. For example, to get the default behavior of :mksession,
       let SessionSaveDirectory = "."

g:SessionPath
  Default is set to the initial value of SessionSaveDirectory
  A comma-separated list of paths in which to look for session files to
  restore or delete.
  e.g. let SessionPath = ".,~,~/.vim/sessions"

g:SessionFilePrefix
  Default is ".vimsession_" (on Windows, "_vimsession_")

g:SessionFileSuffix
  Default is "" (on Windows, ".vim")

  Strings to prepend and append to session names when saving to
  SessionSaveDirectory. All files found in SessionPath with these
  attributes will be identified as sessions, so the combination of the two
  should uniquely identify session files (unless all files found in
  SessionPath will be Vim sessions).

g:SessionDefault
  Unset by default
  The default session name to save to or restore from. This is overridden
  by v:this_session. If both are unset, the Vim server name (v:servername)
  will be used as the default.

g:SessionConfirmOverwrite
  0 or 1 (default)
  Set this to 0 to save over an existing session file without asking for
  confirmation.

g:SessionQuitAfterSave
  1 or 0 (default)
  Whether to exit Vim after saving a new session.

g:SessionCreateDefaultMaps
  0 or 1 (default)
  Whether to create the default normal mode mappings (ZS, ZR, ZD, and ZL).
 
install details
Put the file in your Vim 'plugin' directory (usually ~/.vim/plugin, or Program Files/Vim/vimfiles on Windows)
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
session_dialog.vim 1.2 2010-07-26 7.0 David Liang Added confirmation messages and <Plug> mappings
session_dialog.vim 1.03 2009-04-25 7.0 David Liang Use a default name when running Vim from terminal.
session_dialog.vim 1.02 2009-01-02 7.0 David Liang Better error handling
session_dialog.vim 1.01 2008-12-09 7.0 David Liang New option g:SessionConfirmOverwrite; new mapping ZL for :SessionList
session_dialog.vim 1.0 2008-11-29 7.0 David Liang Initial upload
ip used for rating: 18.221.129.19

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github