Using Stata my text editor is gVim. Using scripts from here and here to send code from Vim to Stata keeps me from switching to Linux. The scripts are in AutoIt I cannot use in Linux. They are independent of text editor; people who wrote them use Notepad++. These scripts with a few lines in my .vimrc file allow me to send selections or the whole file to a Stata window.
I am looking for this in Linux. There are Stata for command line and xstata is the GUI version. I use the GUI version so Screen and Tmux are ruled out. I wasn't able to find a plugin for Vim. Bash I want to look into. Python would be OK.
AutoIt script I need to translate I prefer doesn't overwrite content of clipboard. It checks for an open Stata window, selects or executes one, pastes contents to be executed into temporary file, switches to Stata window, selects command line with Ctrl + 1 (and anything already be written with Ctrl + A) then pastes "tempfile" into command line, which then executes the code. I have a solution in Bash.
; Declare variables
Global $ini, $statapath, $statawin, $statacmd, $dofile, $clippause, $winpause, $keypause
; File locations
; Path to INI file
$ini = @ScriptDir & "\rundo.ini"
;; contents of ini file are the following
;[Stata]
;; Path to Stata executable
;statapath = "C:\Program Files\Stata11\StataSE.exe"
;; Title of Stata window
;statawin = "Stata/SE 11.2"
;; Keyboard shortcut for Stata command window
;statacmd = "^1"
;[Delays]
;; Pause after copying of Stata commands to clipboard, in milliseconds
;; Use higher number if script fails (default: 100, recommended range: 0 - 200)
;clippause = 100
;; Pause between window-related operations, in milliseconds
;; Use lower number to speed up script, higher number if script fails (default: 200)
;winpause = 200
;; Pause between key strokes sent to Stata, in milliseconds
;; Use lower number to speed up script, higher number if script fails (default: 1)
;keypause = 1
; Path to Stata executable
$statapath = IniRead($ini, "Stata", "statapath", "C:\Program Files\Stata11\StataSE.exe")
; Title of Stata window
$statawin = IniRead($ini, "Stata", "statawin", "Stata/SE 11.2")
; Keyboard shortcut for Stata command window
$statacmd = IniRead($ini, "Stata", "statacmd", "^1")
; Path to do-file that is passed to AutoIt
; Edit line to match editor used, if necessary
$dofile = $CmdLine[1]
; Delays
; Pause after copying of Stata commands to clipboard
$clippause = IniRead($ini, "Delays", "clippause", "100")
; Pause between window-related operations
$winpause = IniRead($ini, "Delays", "winpause", "200")
; Pause between keystrokes sent to Stata
$keypause = IniRead($ini, "Delays", "keypause", "1")
; Set WinWaitDelay and SendKeyDelay to speed up or slow down script
Opt("WinWaitDelay", $winpause)
Opt("SendKeyDelay", $keypause)
; If more than one Stata window is open, the window that was most recently active will be matched
Opt("WinTitleMatchMode", 2)
; Check if Stata is already open, start Stata if not
If WinExists($statawin) Then
WinActivate($statawin)
WinWaitActive($statawin)
; Activate Stata command window and select text (if any)
Send($statacmd)
Send("^a")
; Run saved do-file
; Double quotes around $dofile needed in case path contains blanks
ClipPut("do " & '"' & $dofile & '"')
; Pause avoids problem with clipboard, may be AutoIt or Windows bug
Sleep($clippause)
Send("^v" & "{Enter}")
Else
Run($statapath)
WinWaitActive($statawin)
; Activate Stata command window
Send($statacmd)
; Run saved do-file
; Double quotes around $dofile needed in case path contains blanks
ClipPut("do " & '"' & $dofile & '"')
; Pause avoids problem with clipboard, may be AutoIt or Windows bug
Sleep($clippause)
Send("^v" & "{Enter}")
EndIf
do the_whole_thing
in Stata. Ifthe_whole_thing
takes too long to run, you need to break it down into smaller manageable pieces, which is the standard programming advice, and store the intermediate results, which is available for both data and estimation results in Stata. (See also stata.com/bookstore/wdaus.html) – Dissectedgraph save
orgraph export
whatever you have produced, even though the graph window may not be actually created. (I understand that I am proposing kludges; I don't really know if a good solution exists, otherwise I would've offered it right away.) – Dissected