Vim Tips Wiki
Tip 1645 Printable Monobook Previous Next

created January 4, 2010 · complexity basic · author Lotusone · version 7.0

On Mac OS X systems, you can automatically source Vim sessions by creating an Automator Application that forwards the file to Vim with the -S option.


  • Name all your Vim sessions with the same extension, for example ".vis".
  • Open Automator and create a workflow, using File > New.
  • Choose Application as the type for your document.
  • In the Library of Actions, choose Utilities.
  • From the Utilities section, drag the Run Shell Script action.
  • In the Run Shell Script window, choose /bin/bash in Shell pop-up button and as arguments in Pass input pop-up button.
  • Write the script:
source ~/.bash_profile  # necessary to locate mvim
FILE=$@                 # the session file to open
FILE=${FILE// /\\ }     # replace spaces with escaped spaces
mvim -S "$FILE"         # -S open MacVim sourcing the file

It is possible to write the script in some other language, but bash is more simple.

Creating an Application in automator

  • Save the Automator Application in some folder that is already in your path.
  • Set this application as the default app to open Vim session files (borrowed from the Finder Help):
    1. Select the document in Finder and choose File > Get Info.
    2. Click the triangle next to “Open with” to expand the section.
    3. Choose an application from the pop-up menu, or choose Other to locate a different application.
    4. If you want to use that application to open all documents of the same type as the current document and created by the same application, click Change All.


Whenever you double-click a session file in Finder, will open Vim or MacVim sourcing the saved session.
It also works using a command line in Terminal: $ open test.vis
And can be useful when Vim is already running: using netrw browser and hitting "x" while cursor is on file name test.vis open a new MacVim window with this saved session.