This extension contains a set of tools for working with Stata:
- Language grammar for syntax highlighting (from Kyle Barron)
- Ability to send code to the Stata application (from poidstotal)
- This feature makes VSCode effectively a do file editor
- Interactive window support using
nbstata
. See below
Interactive window
Interactive window allows you to use a plain .do
file and have an interactive REPL in VSCode.
The idea is that you take your regular .do
file and sprinkle in * %%
comments.
These comments will mark "code cells" which are set of lines of code that you want to run all together.
When you hit Run Cell (or use a keyboard shortcut), then those lines are sent to the interactive window and the results are displayed below.
By default you can use cmd+shift+d
to run all the cells (in order) and cmd+enter
to run the current cell and move to the next cell.
I recommend adding two more keyboard shortcuts (cmd+[
for Go to Previous Cell and cmd+]
for Go to Next Cell).
This allows you to jump around the do file according to your cell markers

Installing necessary software
This feature uses the nbstata
jupyter kernel by Tim Huegerich.
Send code to stata
These commands allow you to execute Stata code directly from VSCode without switching applications.
You can either set up keyboard shortcuts or use the command palette (launch with cmd+shift+p
and then search Send to Stata)
There are four commands for sending code to Stata:
Send to Stata: All Lines
Sends the entire file to Stata (cmd + shift + d
)
Send to Stata: Selection / Current Line
Sends the currently selected text to Stata. If no text is selected, then the current line is sent (cmd + enter
)
Send to Stata: Above Lines
Sends all code above the curso
Send to Stata: Current Line and Below
Sends all the code on the same line as the cursor and below
Credits
This repository uses a lot of code MIT licensed language-stata by Kyle Barron
, poidstotal
, and Han Lu Long
into a single extension.
Please give a star to each project to say thanks!