StataLinux
Sublime Text 3 plugin that adds support for Stata (all versions) in Linux.
Details
Installs
- Total 346
- Win 0
- Mac 0
- Linux 346
Dec 3 | Dec 2 | Dec 1 | Nov 30 | Nov 29 | Nov 28 | Nov 27 | Nov 26 | Nov 25 | Nov 24 | Nov 23 | Nov 22 | Nov 21 | Nov 20 | Nov 19 | Nov 18 | Nov 17 | Nov 16 | Nov 15 | Nov 14 | Nov 13 | Nov 12 | Nov 11 | Nov 10 | Nov 9 | Nov 8 | Nov 7 | Nov 6 | Nov 5 | Nov 4 | Nov 3 | Nov 2 | Nov 1 | Oct 31 | Oct 30 | Oct 29 | Oct 28 | Oct 27 | Oct 26 | Oct 25 | Oct 24 | Oct 23 | Oct 22 | Oct 21 | Oct 20 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Mac | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Linux | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
Readme
- Source
- raw.githubusercontent.com
StataLinux
Sublime Text 3 plugin that adds basic support for Stata (all versions) in Linux.
- Language definitions for
do
andado
files - Commands for sending a selection of lines or the whole file to Stata. See usage for more details.
Background
I needed a minimal yet robust plugin for sending code from Sublime Text into Stata. Since none of the plugins in the Package Control was specifically tailored for Linux, and none of the maintainers seem to want to add Linux support to theirs, I wrote my own. This plugin is originally based on StataEnhanced, and also on these notes.
This plugin aims for robustness over bells and whistles, and almost all the decisions were taken with that philosophy in mind.
It basically creates a temporary file with either the currently selected lines or the entire do-file to be executed in Stata. In the background xdotool
is used to call the temporary file from the command pane in Stata.
Dependency
xdotool
This package is likely already in your system.
You can check their presence by typing each name with the --version
option in your terminal.
For example,
xdotool --version
If the output is something like xdotool version 3.20160805.1
, then it's installed.
If you get an error, then the package is not installed.
Use your system's package manager to install them.
For example,
Arch(-based)
sudo pacman -S xdotool
Ubuntu(-based)
sudo apt install xdotool
etc.
Installation
There are two ways to install this plugin:
- Search for “StataLinux” on Package Control, or
- Copy/clone the entire plugin folder (this repository) to
~/.config/sublime-text-3/Packages/
.
Make sure you have installed the dependency listed above before using it.
Usage
Make sure you have one instance of Stata open.
Open a .do
(or .ado
) file in ST3.
You have two keybindings for executing code:
ctrl+alt+d
executes the current line, or the selected lines if a selection is made, andcrtl+alt+shift+d
executes the entire file.
These actions may also be called using the Command Palette: after invoking it with ctrl+shit+p
, type “StataLinux” and select an action.
Additionally, these actions are accessible in the main menu under Tools > Packages > StataLinux
.
The default keybinding can be changed by including the following in your sublime-keymap
file. This file can be viewed and edited by clicking on Key Bindings
under Preferences > Package Settings > Stata Linux
. Here is a example using ctrl
+enter
to run selected lines:
// StataLinux
{ "keys": ["ctrl+enter"], "command": "stata_linux", "context":
[{ "key": "selector", "operator": "equal", "operand": "source.stata", "match_all": true }]
The stata_linux_all
command, which runs the entire file can be also adjusted accordingly.
Other features
Comments
Comment toggling for entire lines works with the default ST3 keybinding, ctrl+\
.
Arbitary blocks can be commented out with ctrl+shift+\
.
Locals
Typing a backtick `
anywhere in the code will immediately put a closing tick after it, with the cursor inside.
Typing a backtick with a word
selected will yield `word'
.
Options
The following options be found in the main menu under Preferences > Package Settings > StataLinux > Settings
.
save_before_run_all
(default = true): Automatically saves the current file before “Send All” command.always_extract_full_line
(default = true): Always extracts whole line (true) or only exact selection (false). If nothing is selected then whole line under cursor is extracted. The default behavior mimics Stata's for familiarity but there are situations where running a partial line might save some time, so setting it tofalse
allows you to quickly run a command with and then without anif
condition or aby
statement. If the current selection is empty, this plugin will run the whole line and not the whole do-file. Although this is different to Stata's default behavior, we don't think it was a good design choice and one can always explicitly useRun all
functionality in such cases.remove_temp_file
(default: false): Deletes the temporary file after running it.
Stata versions, flavors and instances
Make sure you have an instance of Stata with GUI open (xstata
, or its various flavors); this plugin doesn't work with Stata's CLI.
No additional configuration needs to be added to indicate version or flavor, since the program will detect any running instance automatically.
If you have more than one instance of Stata open, the plugin will default to choosing the most recently opened one (internally, it looks for the result of xdotool search --name --limit 1 "Stata/(IC|SE|MP)? 1[0-9]\.[0-9]"
).
Known issues
Currently, there is an issue withNow not an issue, since I'm usingxdotool
'sclearmodifiers
option. This has the consequence that the plugin will fail to operate correctly if any keyboard modifiers (e.g. Caps Lock) are not manually turned off.xdotool
with the--window
, which seems cleaner than focusing and refocusing windows, and has the added bonus of disregarding any active modifiers.There is currently no option for switching focus to the Stata window. This is because there are good reasons to use
xdotool
with the--window
option (see issue #1), so I don't plan on implementing this. Window focus is a task for window managers, anyway.