Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Stata with MacVim


From   Gabi Huiber <ghuiber@gmail.com>
To   statalist@hsphsun2.harvard.edu
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
#!/bin/bash
osascript -e "tell application id \"com.stata.stata12\"
       open POSIX file \"${1}\"
end tell"
----------------------------------------- start do-selection
#!/bin/bash
TMPFILE=".stata-$$.do"
if [ ! -e "$TMPFILE" ]
then
   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}\""
APPLESCRIPT
else
       echo "Can't create temporary file $TMPFILE (already exists)"
fi
------------------------------------------ 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()
  wa
  !do-file "%:p"
endfunction

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

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

: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 <pschumm@uchicago.edu> 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,
Gabi

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index