Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Stata with MacVim

From   Gabi Huiber <>
Subject   Re: st: Stata with MacVim
Date   Wed, 14 Sep 2011 06:02:41 -0400

I am happy to report that, thanks to Phil Schumm's help, I finally
managed to integrate MacVim with Stata 12 on Mac OS X Lion. The
process has three steps:

1. Save the bash scripts below as /usr/local/bin/do-file and
/usr/local/bin/do-selection respectively:

----------------------------------------- start do-file
osascript -e "tell application id \"com.stata.stata12\"
       open POSIX file \"${1}\"
end tell"
----------------------------------------- start do-selection
if [ ! -e "$TMPFILE" ]
   cat > "$TMPFILE"
   osascript <<-APPLESCRIPT
       tell application id "com.stata.stata12" to open POSIX file "${TMPFILE}"
       delay 0.5  -- avoid deleting file before Stata reads it
       do shell script "rm \"${TMPFILE}\""
       echo "Can't create temporary file $TMPFILE (already exists)"
------------------------------------------ end bash scripts

Both scripts above are almost identical to how Phil wrote them. I just
changed stata11 to stata12. Don't forget to check their permissions.
They should both be executable.

2. Add the following two functions to .gvimrc:

------------------------------------------ start .gvimrc additions
function RunIt()
  !do-file "%:p"

:map <F5> :<C-U>call RunIt()<CR><CR>
:imap <F5> <Esc>:<C-U>call RunIt()<CR><CR>

function RunDoLines()
  '<,'>w !do-selection

:vmap <F6> :<C-U>call RunDoLines()<CR><CR>
-------------------------------------------- end .gvimrc additions

3. Uncheck  "Edit do-files opened from the Finder in Do-file Editor"
as instructed below:

On Thu, Sep 8, 2011 at 10:40 AM, Phil Schumm <> wrote:
There is a new setting (in Stata for OS X) under
>    General Preferences... -> Do-file Editor -> Advanced
> called "Edit do-files opened from the Finder in Do-file Editor."  I believe that this is checked by default.  You need to uncheck it if you want an Open File Apple Event to execute a do-file instead of opening it in the do-file editor.  Note that for those people (like myself) who use an external editor, most will have set the Finder to use that editor (rather than Stata) to open a do-file when double-clicking on it.  Thus for them, this option is essentially superfluous (but must be unchecked if you wish to use an Open File AE to execute code in Stata from your editor).
> -- Phil

Thanks again,

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index