andrewheiss / SublimeStataEnhanced

Plugin that adds support for Stata 11–15 for Sublime Text 2 and 3
55 stars 22 forks source link

change end-of-line delimiter to ; #39

Closed zhouyisu closed 8 years ago

zhouyisu commented 8 years ago

Hi there, it seems I could not change the end-of-line delimiter to ";" using #d;. Stata will simply pick up the first and second line as separate commands, not combining them into a single line of command. Any suggestions?

andrewheiss commented 8 years ago

This is because of how Stata processes .do files. In Stata's documentation, it says #delimit "can be used only in do-files or ado-files", and so it will only work when running a .do file in batch mode from the terminal or running the whole .do file using Stata's own .do file editor.

This package does not work the same way—it essentially copies lines from Sublime Text and pastes them in Stata's command window. Because of that, commands that are reserved only for running as a complete .do file (like #d) do not work. You'll get the same error when running them that you'd get when typing them manually into the command window.

Sorry!

andrewheiss commented 8 years ago

The only alternative is to send the whole .do file to Stata at the same time using the "Send line/selection to Stata (Stata 11-12)" command that this package provides. Older versions of Stata didn't have an easily scriptable way of sending text to the command window, so this command saves the selection as a temporary .do file (sublime2stata.do in your current working directory) and then runs the entire file at once in Stata. Because it runs the .do file all the same time, it can handle .do file-only commands like #d;

zhouyisu commented 8 years ago

Thanks for quick response. It's really helpful. Right now I just copy/paste long lines (usually labelling) to do file editor and put /// in other circumstances.