Sublime Text 3 with Stata (Enhanced) - opens new instance of Stata for every command
Asked Answered
T

1

6

I'm a completely new Sublime Text user. I'm trying to make the Stata (Enhanced) plugin work for Sublime Text 3. I'm on a W7 machine.

I've installed the plugin and edited the Stata Enhanced (windows).sublime-settings file to look like this, as instructed:

{ "stata_version": 13, "stata_name": "C:/Program Files (x86)/Stata13/StataMP-64.exe" }

and I've also changed Stata's preferences so that Stata runs do-files automagically, also as instructed.

And it works: with Ctrl+Enter Stata runs do-files from Sublime Text. However, every time I run a command, it opens a new instance of Stata. That's very impractical, but I don't know what to do about it. The readme doesn't mention this problem and haven't been able to find a solution on the net. So I'm at a loss: do you know what to do about it?

Tolbutamide answered 15/8, 2014 at 12:17 Comment(6)
Ok I think I've gotten a bit closer to the problem at hand. I think this is a general problem not just with Sublime, but also with other editors - it might possibly be a problem with Stata itself. there seems to be some kind of option missing, that tells STATA to run the command in the already-opened instance of the application and not open a new one. I think this is parallel to Stata opening a new instance if you open a do-file directly instead of through the already-opened instance of Stata.Tolbutamide
There doesn't seem to be a solution at this moment, according to Andrew Weiss, the creator of the plugin: github.com/andrewheiss/SublimeStataEnhanced/issues/19Tolbutamide
This goes rather deep into Stata guts. You would want to ask at statalist.org, or contact Stata developers directly. I have seen at least one implementation where Stata listened to and provided output into pipe, but this is wa-a-ay beyond my programming abilities.Anastomosis
I've asked on statalist, there are some insightfull comments. go there if you want the qualified discussion for this question: statalist.org/forums/forum/general-stata-discussion/general/…Tolbutamide
Oh, they gave you an unusually a rough time there :). S.R. is the guy who implemented that pipe thing, so he is the one you need to talk to.Anastomosis
haha yeah I thought so too :D but they also gave me insightful answers, so i can't complain. Nice to know it isn't just my own shortcommings which are in the way.Tolbutamide
S
8

As indicated above, this may not be possible using Stata Enhanced. However, you can try out the StataEditor package which I made for Windows and Sublime Text 3. Using that package, the same Stata instance is used all the time as long as Sublime Text is open. It is available from Package Control: https://sublime.wbond.net/packages/StataEditor. One advantage of that package (for Windows users) is that it uses Stata automation (http://www.stata.com/automation/) to send code directly to Stata.

Septillion answered 26/10, 2014 at 9:36 Comment(5)
Stata Enhanced is a package to Sublime Text, see sublime.wbond.net/packages/Stata%20Enhanced. While Stata Enhanced works on both Windows and OS X, I believe it is better suited for OS X as it uses AppleScript to send code to Stata (don't use OS X myself, so I can't comment on it). The link provided by EmilBB above sheds some light on the issues with getting the package to work on Windows machines.Septillion
This seems like the ideal solution! However, it doesn't work. I checked stata_path, it is correct, I got ST3 build 3065 and Stata 13.1 (rev. 19/2014) on a W7 machine, and when I try Ctrl+d or Ctrl+r from sublime, it doesn't respond. I followed your instructions to the letter, including registrering the automation library like this "C:\Program Files\Stata13\StataSE.exe" /Register. I would love to use this though!!Tolbutamide
In my experience, it only works if you follow the instructions for Windows Vista instead of Windows 7 when registering the Stata automation type library (stata.com/automation). I don't know why that is, but the W7 doesn't seem to work for anyone I've talked to.Septillion
It works perfectly! I can't even begin to tell you how much this helps on my workflow, to be able to use sublime instead of the do-file editor, thank you so much!Tolbutamide
StataEditor is the way for Windows users. I am using Stata14MP on Windows 7 without any problems.Playmate

© 2022 - 2024 — McMap. All rights reserved.