Project sharing | Stata All in One
logo
Table of Contents
Stata All in One
One VS Code extension tailored for Stata users
| Version: 0.3.10 | Author: Zihao Viston Wang | Translate: 中文版本 |
All-in-one Stata experience: Code Execution + Syntax Highlighting + Code Completion + Smart Outline + Data Viewing + AI Skill!
Ready out of the box!
Natively integrated into VS Code—no need to configure external environments like Python or Node.js.
Stata All in One is derived from Stata Outline, expanded with new features and improvements.
This README provides technical documentation and installation/configuration instructions for Stata All in One. For a more accessible feature overview, visit my blog to learn more.
Acknowledgments
- First, my thanks go to RedNote user Rich**d, WeChat users M*k*, 柿**橙, X**n, and the anonymous user who commented “功能强大且配置简单的插件,谢谢!”, and Buy Me a Coffee supporters LB**PG@gmail.com and ol***ba@gmail.com for their generous contributions and continued support of this project.
- Above all, I am deeply grateful to the Agricultural Economics and Management Innovation Team at Northwest A&F University for supporting my research, providing funding, and helping promote and publicize this project.
- I am also sincerely grateful to Assoc. Prof. Yujun Lian and the lianxh.cn team for their patient guidance and publicity support.
- Finally, I thank Stata’s officially authorized distributor Beijing Uone Info&Tech Co.,Ltd (Uone-Tech) for its support in promoting and publicizing this project.
Features
⚠️ Features marked with 🛠️ require Stata 17 or later and a
STATA.LIClicense file. Please support genuine Stata software to enjoy the full experience. You can contact Stata Corp, LLC’s officially authorized partner Beijing Uone Info&Tech Co.,Ltd (Uone-Tech) to purchase genuine Stata software or request a trial.
1. Stata AI Skill 🛠️
- Let AI Agents Run Stata Code: Install the standalone native
stata-ai-skillso AI coding tools (Claude Code, Cursor, Codex CLI, Open Code, OpenClaw, etc.) can run Stata through a Rust background service. - Native Local Service: Once installed, the AI Skill runs through its native executable and local service, with no third-party environment such as Python or Node.js required.
- Leave the setup to AI: Click the
AIbutton in the editor toolbar, copy the prompt, and paste it into your AI tool. The prompt links to the onlineinstallation.mdthrough Gitee and GitHub.
2. Code Execution (Interacting with Stata)
- Platform Support: This extension natively supports seamless integration with Stata on both macOS and Windows.
- Two Run Modes:
- Embedded Console (default) 🛠️: Run and display Stata output directly within VS Code, including command results, error messages, command window output, and graph output, for a true one-stop experience. Click any file path shown in the Console output to open it.
- External App: Continue using the traditional approach of sending code to the Stata GUI, for users who prefer Stata’s native interface. Windows now uses Stata COM Automation, delivering significantly better performance than the previous PowerShell-based implementation.
- Multi-Scenario Execution Strategies:
- Section Execution: When the cursor is on a header line (e.g.,
** # Title), click the ▶️ button or pressCtrl / ⌘ + Dto execute all code from that header to the next same-level or higher-level header (i.e., the entire section). - Single Line Execution: When the cursor is anywhere on a regular code line, click the ▶️ button or press
Ctrl / ⌘ + Dto execute only the current line. - Selected Code Execution: When one or multiple lines are selected, click the ▶️ button or press
Ctrl / ⌘ + Dto execute the selected lines. Supports fuzzy selection — no need to precisely select the first or last line of a code segment; the system automatically captures and runs all lines covered by the selection.
- Section Execution: When the cursor is on a header line (e.g.,
3. Enhanced Syntax Highlighting & Code Completion
- Full Syntax Highlighting and Code Completion Support: Integrates Stata Enhanced syntax engine1, providing precise syntax highlighting and code completion for
.dofiles (under MIT License). - Custom Command Highlighting: Supports highlighting for commonly used third-party commands (e.g.,
reghdfe,ivreghdfe,gtools), freely configurable in settings. - Dataset Variable Autocompletion: (After running code that loads a dataset once) Provides intelligent autocomplete suggestions based on the current dataset when typing variable names in the editor and console, boosting coding efficiency.
4. Smart Outline & Structural Navigation
- Multi-level Outline Recognition: Automatically detects comment lines from
**#to**######as hierarchical headers, supporting up to 6 levels.- Shortcuts:
Ctrl / ⌘ + 1-6to quickly convert to the corresponding header level;Ctrl / ⌘ + 0to revert to a standard code line.
- Shortcuts:
- Cursor Auto-Follow: The outline view automatically highlights and navigates to the corresponding section as the cursor moves in the editor.
- Setup: Click the “···” button in the top-right of the Outline view and check “Follow Cursor”.2
- Multi-level Numbering: Optional display of logical numbering (e.g.,
1.1,1.2.1) within the outline (must be enabled in settings). - Auto-Sync Numbering: When enabled, the extension automatically adds or removes numbering directly within the
.dofile based on the outline structure. program defineBlock Recognition: Displays program names in the outline view for easy navigation and management of custom programs.
5. Data Viewer 🛠️
- Click to View: Click a
.dtafile in the VS Code Explorer to open it in the newData Viewerpanel.- Variable Info: Variable table displays metadata such as name, label, and type.
- Data Browsing: Supports lazy loading of rows and columns — easily browse large datasets right in VS Code without opening Stata.
- View After Run: After running code, instantly view results in the
Data Viewerwithin theConsolepanel. - Data Filtering: Provides Stata-style filtering for quickly locating subsets of data.
- Handy Extras:
- Built-in
br/browse: In Embedded Console mode, runbr/browsewith Stata filtering expressions from either the code editor or Console input to open the built-in Data Viewer. - View Long Text: If a cell contains more text than it can display, hover over the cell to view the full content.
- Double-click to Copy: Double-click a cell to copy its full content to the clipboard.
- Built-in
6. Efficient Separator Lines & Styling
- Quick Insertion: Supports various symbols to significantly enhance code readability.
- Standard Separators: Use
Ctrl / ⌘ + Symbolto quickly insert separator lines:Ctrl / ⌘ + -(Dash) |Ctrl / ⌘ + =(Equal) |Ctrl / ⌘ + Shift + 8(Asterisk)
- Custom Separators:
Ctrl + Alt + S(Windows) |Ctrl + ⌘ + S(macOS), where S stands for “Separator”.- After pressing the shortcut, simply input your desired character to generate the corresponding separator line.
- Standard Separators: Use
- Intelligent Wrap Mode:
- Blank Line Insertion: Generates a full-width separator line (length adjustable in settings).
- Non-blank Line Insertion: Pressing the shortcut once inserts above the line; pressing it again inserts below, creating a “wrapped” effect.
- Header Decoration: Select some characters of a header and press the shortcut to generate a title with balanced decorative symbols (e.g.,
**# === Title ===), without affecting outline recognition.- Centered Header: If using Header Decoration + Custom space separator, the header content will be automatically centered.
7. More Features
-
Enhanced Embedded Console 🛠️
-
Graph Output
- Direct Display: Render Stata graph output directly in the embedded console.
- Export Options: Save graphs as SVG, PNG (configurable DPI), or copy to clipboard.
- Fullscreen View: Click a graph to view it in fullscreen mode for detailed inspection.
-
Progress Display
- Command Execution Status: For long-running commands like
bootstrap,bdiff, andxthreg, the console shows real-time progress (e.g. 50/2000) and estimated time remaining. Other commands display elapsed time.
- Command Execution Status: For long-running commands like
-
Custom Font:
- Online (Default): Load Maple Mono for Latin text and Maple Mono NF CN for Chinese text.
- Font Settings: Use
stata-all-in-one.consoleFontModeandstata-all-in-one.consoleCustomFontFamilyto customize the console font for a better reading experience.
-
Run Presentation
- Grouped Display: Show each run as a collapsible input cell with clearly grouped command echoes and results.
- Quick Navigation: Quickly locate output using the Embedded Console’s right-side navigation and jump-to-bottom button.
-
Large Output & Run Control
- Responsive Browsing: Page large output while preserving complete history.
- Reliable Stop: Stop or Esc first attempts a soft interrupt, then force-terminates and automatically rebuilds an unresponsive Stata session.
- Stable Status: Keep elapsed time accurate across view changes and avoid duplicate temporary do-file input.
-
Result Management
- Complete Exports: Preserve the entire Console history when exporting results to HTML, Markdown, or Notebook.
- Consistent Layout: Keep command grouping aligned across HTML, Markdown, and Notebook; HTML also provides code previews, continuous navigation, aligned numbering, and horizontal-scroll cues.
- Reliable File Links: Recognize and validate file and directory paths in results, including Chinese, multi-line, and repeated paths, and open them with one click.
-
Data Viewer Integration
- On-demand Refresh: After data changes, click the already-open Data Viewer tab again to refresh it and restore the previous viewport.
-
-
Enhanced Comments
- Toggle Comments: Quickly toggle line comments using
Ctrl / ⌘ + /. - Optional Styles: Defaults to
//, with support for switching to other valid Stata comment delimiters in settings.
- Toggle Comments: Quickly toggle line comments using
-
Built-in Help
- Hover Help: Hover over a Stata command to see help information, with automatic filtering of non-practical commands like
#delimit,using, etc. - Show Help Text: For example, select
regressand pressCtrl / ⌘ + Shift + H. In External App mode, this opens Stata’sregresshelp page; in Embedded Console mode, the help text is displayed directly in the console.
- Hover Help: Hover over a Stata command to see help information, with automatic filtering of non-practical commands like
-
Smart Line Break
- One-Key Line Break: Use
Shift + Enterto insert Stata line continuation symbol///at the cursor position. - Smart Indentation: Automatically indent by 4 spaces
- One-Key Line Break: Use
-
Convenient Editor Context Menus
- Smart Run Actions: Show “Run Current Section,” “Run Current Line,” or “Run Selected Lines” based on the cursor and selection, with the matching shortcut hint.
- Quick Editing: Right-click to set heading levels, insert separators, center heading text, or quickly comment using the configured style.
- AI Skill: Open Stata AI Skill from the context menu when a usable Stata license is detected.
-
Safe Rename Mode
- Rename Variable: Select a variable and press
F2to rename all occurrences in the current document. - Smart Validation: Automatically validates the new name to ensure it follows Stata naming rules and does not conflict with built-in commands or keywords.
- Command Protection: Intelligently prevents renaming Stata commands (e.g.,
reghdfe,outreg2) and their options (e.g.,absorb,ctitle).
- Rename Variable: Select a variable and press
-
Auto
cdto Do File Directory- Auto Working Directory: When enabled, automatically sets Stata’s working directory to the do file’s location on first launch.
-
Quick Settings
- Settings Button: Click the gear icon in the editor title bar to quickly access Stata All in One settings.
Keyboard Shortcuts
Click here to view the complete list of keyboard shortcuts.
Installation
Install from Extension Marketplace
- VS Code: Search for “Stata All in One” in extensions and install.
Download and Install (for Cursor, Trae and other VSCode-based IDEs)
- Download
stata-all-in-one-x.x.x.vsixfrom either source: - Open Extensions panel in your editor →
...→Install from VSIX.... - Select the downloaded
.vsixfile to complete installation.
Configuration
Search for “Stata All in One” in VS Code settings and configure:
AI Skill
Click the AI button in the Stata editor toolbar to copy a prompt containing Gitee and GitHub links to the online installation.md. After installation, your AI coding tool follows the installed Skill’s SKILL.md for service startup, status checks, Stata configuration, and subsequent operations.
Configure from Stata
If automatic discovery cannot find Stata, choose Stata not found? Configure it directly from Stata. Follow the extension’s two prompted steps and run each command in Stata to complete the setup.
Code Execution
-
Run Mode (
stata-all-in-one.runMode)embeddedConsole(default): Run code in the built-in Console | Stata All in One panel within VS Code, with direct output viewing and interaction.externalApp: Send code to the system-installed Stata application for execution.
-
Stata Version on macOS (
stata-all-in-one.stataVersionOnMacOS)- Stata runtime version. When empty, the extension detects installed versions at startup for up to 3 seconds, preferring the highest numeric version and then
StataMP,StataSE,StataBE, andStataIC. If detection fails, configure directly from the running Stata instance. The initializer then verifies the exact.app, Console dylib, andstata.lic, initializes the Embedded Console when possible, and reports the result once in a central dialog.
- Stata runtime version. When empty, the extension detects installed versions at startup for up to 3 seconds, preferring the highest numeric version and then
-
Stata Path on Windows (
stata-all-in-one.stataPathOnWindows)- Path to Stata executable file (e.g.,
C:\Program Files\Stata17\StataMP-64.exe). When empty, the extension runs the bundledscripts/discover_stata_windows.batregistry probe at startup for up to 5 seconds. The same BAT can be run independently to generatestata-discovery-report.jsonfor troubleshooting. If detection fails, configure directly from the running Stata instance. The initializer then verifies the EXE, Console DLL, andstata.lic, initializes the Embedded Console when possible, and reports the result once in a central dialog.
- Path to Stata executable file (e.g.,
-
Close Stata Other Windows Before Sending Code (Windows) (
stata-all-in-one.closeStataOtherWindowsBeforeSendingCode)true: Close Stata helper windows (such as Viewer/Data Editor) before sending run commands.false(default): Keep those windows open and send code directly.
-
Auto cd to Do File Directory (
stata-all-in-one.cdToDoFileDir)true(default): Automatically set Stata’s working directory to the do file’s location on first launch.false: Stata’s working directory is not changed on startup.
-
Show Action Buttons (
stata-all-in-one.showActionButtons)true(default): Show the “Bug Report” and “Stata AI Skill” buttons in the editor title bar.false: Hide both buttons.
-
Show Sponsor Button (
stata-all-in-one.showSponsorButton)true: Show the “Sponsor” button in the Stata editor title bar.false(default): Hide the button.
-
Enable Ctrl+Shift+D for Run Shortcut (
stata-all-in-one.enableCtrlShiftD)true: UseCtrl / ⌘ + Shift + Das the run code shortcut.false(default): Use the defaultCtrl / ⌘ + Dshortcut.
Embedded Console
- Console Font Mode (
stata-all-in-one.consoleFontMode)online(default): Load Maple Mono for Latin text and Maple Mono NF CN for Chinese text.3editor: Follow the editor font, falling back to the system monospace font.system: Use the system monospace font directly.custom: Use the custom font specified below.
-
Console Custom Font Family (
stata-all-in-one.consoleCustomFontFamily)- When font mode is set to
custom, the CSSfont-familylist used by the console. - Example:
"Maple Mono NF CN", Menlo, Monaco, monospace
- When font mode is set to
-
Graph Export DPI (
stata-all-in-one.graphPngDpi)- DPI value for saving embedded console graphs as PNG. Default
600, range 72–1200.
- DPI value for saving embedded console graphs as PNG. Default
Syntax Highlighting and Code Completion
- Custom Command Highlighting (
stata-all-in-one.customCommands)- User-defined Stata commands to highlight as keywords (array of strings). Default:
reghdfe. - Example:
["reghdfe", "ivreghdfe", "gtools", "winsor2", "outreg2"] - Requires reloading window after configuration.
- User-defined Stata commands to highlight as keywords (array of strings). Default:
Hover Help
-
Enable Hover Docs (
stata-all-in-one.enableHoverDocs)true(default): Show official Stata help information when hovering over Stata commands.false: Disable hover help.
-
Additional ADO Paths (
stata-all-in-one.additionalAdoPaths)- Extra Stata ADO paths for scanning help files of community-contributed commands.
- Example:
["/Users/username/ado/personal", "C:\\Users\\username\\ado\\personal"]
Outline & Navigation
-
Display Multi-level Numbering (
stata-all-in-one.numberingShow)true: Outline displays1.1,1.2.1style numbering.false(default): Displays original headings.
-
Auto-update Heading Numbering (
stata-all-in-one.numberingAdd)true: When numbering is enabled, automatically update section titles in.dofiles to include numbers.false(default): Only displays numbering in outline, doesn’t modify file.
Note: Changes to
numberingShow,numberingAdd, andcustomCommandsrequire reopening.dofiles to take effect. WhennumberingAddis disabled, existing numbering in.dofiles will be automatically removed.
Code Style
-
Comment Style (
stata-all-in-one.commentStyle)//(default): Comment style used for toggling comments. Options include//,*, or/* ... */
-
Separator Length (
stata-all-in-one.separatorLength)- Total character length of the separator line (including the
** #prefix and separators). Default:60
- Total character length of the separator line (including the
- Separator Symmetric (
stata-all-in-one.separatorSymmetric)true: Add**at the end of separator lines to ensure visual symmetry (e.g.,** === Title === **).false(default): Separator lines without the suffix.
Buy me a coffee
If this extension has been helpful to you, feel free to scan the Alipay (left), WeChat (middle), or Buy Me a Coffee (right) QR code below to support ☕
Changelog
| Version | Changes | Release Date |
|---|---|---|
| 0.3.10 | Added theme-aware tab icons; fixed macOS Embedded Console crashes in complex prediction workflows, Console path highlighting, and run navigation. | 2026-08-06 |
| 0.3.9 | Added staged icon transitions for editor title actions to save title-bar space; fixed the Data Viewer failing to refresh after editor runs and auto-collapsing bottom-right notifications. | 2026-07-29 |
| 0.3.8 | Added Stata editor context menus, redesigned Embedded Console runs and navigation, and improved Data Viewer refresh; fixed some file paths not opening, execution stopping, and large-output freezes. | 2026-07-28 |
| 0.3.7 | Fixed standalone file-path detection in Embedded Console and corrected the duplicated Update Notice prefix. | 2026-07-24 |
| 0.3.6 | Added one-click file opening from Embedded Console output, improved Data Viewer interactions, and fixed graph ordering and Console reset behavior. | 2026-07-24 |
| 0.3.5 | Moved Stata AI Skill online, reducing the Stata All in One extension package to 2.48 MB; fixed Tab recognition between code tokens. | 2026-07-22 |
| 0.3.4 | Rebuilt the Data Viewer with direct.dta and Console-memory access and improved native stability on macOS and Windows. |
2026-07-22 |
| 0.3.3 | Improved Embedded Console command compatibility and multi-linebrowse routing, and refined which output rendering. |
2026-07-21 |
| 0.3.2 | Focused on improving Stata initialization and intelligent autocomplete, while adding multi-format Console export, built-in data browsing commands, and Stata AI Skill v1.1 | 2026-07-17 |
| 0.3.1 | Streamlined Stata startup setup with automatic installation discovery and runtime checks to minimize manual configuration | 2026-07-13 |
| 0.3.0 | Stable release: Fixed known issues from the preview releases | 2026-07-06 |
See CHANGELOG.md for full version history.
-
Stata Enhanced syntax engine was developed by Kyle Barron, providing comprehensive support for the Stata language. This extension follows the MIT License. Thanks to Kyle Barron for his contribution! ↩︎
-
Sorry~ This is a VS Code GUI setting, I cannot control it through the extension. ↩︎
-
Font credits: subframe7536/maple-font, fontsource, and ZeoSeven Fonts (443, 442). ↩︎
Click to view full image