numt
ali50m's VS Code toolbox.
https://marketplace.visualstudio.com/manage/publishers/ali50m
https://open-vsx.org/publish
Features
Multi-cursor numbering
Use numt.numtxt to fill multiple selections with sequential numbers.
- Default shortcut:
Ctrl+K Ctrl+N
- macOS shortcut:
Cmd+K Cmd+N
- Works when the editor has multiple selections
- Supports optional top-to-bottom sorting
- Supports optional leading zero padding
Use numt.format to format JSONC files and normalize configured properties.
- Default shortcut:
Ctrl+K Ctrl+U
- Parses JSONC with comments
- Formats the whole document using the configured indentation
- Converts configured properties to upper or lower case
- Saves the document after formatting
- Warns when duplicate configured property values are found
The formatter safely ignores missing properties, non-string values, and configured nodes that are not arrays.
ST (Structured Text) formatting
Use numt.stfmt to format IEC 61131-3 Structured Text files, targeting TwinCAT 2.
- Default shortcut:
Ctrl+K Ctrl+T
- Supports
IF / CASE / FOR / WHILE / REPEAT control structures with automatic indentation
- Normalizes operator spacing (
:=, =, <>, +, -, *, /, etc.)
- Preserves comments (
// and (* ... *)) and string literals unchanged
- Formats
PROGRAM / FUNCTION / FUNCTION_BLOCK / METHOD / VAR declaration blocks with colon alignment
- Formats
TYPE / STRUCT blocks
- Supports AT address modifiers (
AT%I*, AT%Q*, AT%M*)
- Normalizes type keywords to uppercase (
INT, BOOL, REAL, etc.)
- Supports format-on-save for
.st files
numt.stfmt.keywordCase: upper (default) uppercases recognized ST keywords, built-in types and Boolean constants; preserve retains their original case. User identifiers, comments, strings and typed literals retain their case.
If the formatter cannot safely preserve the document, it leaves the text unchanged. The manual numt.stfmt command shows the reason; details are also written to the numt stfmt output channel. Format-on-save may invoke the standard VS Code formatting provider.
For ST files, Ctrl+/ (Cmd+/ on macOS) toggles (* ... *) comments. The command refuses ambiguous or unsafe selections, including existing comments and the tc2txt implementation separator. See ST comment rules for details.
Project design notes and operational guides are collected in the documentation index.
Optional ST language server
numt can connect to the separate stlsp executable for ST document symbols, completion, hover, definition and semantic highlighting. Completion is also triggered after member-access punctuation such as . when the server advertises it. The VSIX does not include the server. Build the server from the stlsp source with cargo build --release --manifest-path stlsp/Cargo.toml, or obtain a compatible server separately, then place it at a stable local path. The current client accepts server version 0.1.x.
In VS Code User Settings, set an absolute path (JSON backslashes must be escaped):
"numt.stlsp.path": "C:\\Tools\\stlsp\\stlsp.exe"
在 VS Code 用户设置中配置库索引目录(绝对路径):
"numt.stlsp.libraryPaths": [
"C:\\Tools\\tc2-library-index"
]
The path is empty by default, so the server does not start until configured. Set numt.stlsp.enabled to false to disable it; use ST Language Server: Restart after replacing the executable or library paths. The executable path and library paths are read from machine/user settings, not from project settings. The server starts only in trusted workspaces; granting trust starts it automatically when configured. It reads local ST files for analysis and does not format them. Existing highlighting and formatting remain available without it.
The initial server is intended for local TwinCAT 2 text exports. It provides conservative results for supported declarations; complex member chains, pointers and type aliases are not fully resolved. Only local file: documents are supported. numt.stlsp.trace.server is off by default; enabling it may include source code in the ST Language Server output.
Configure numt.buttons to add custom command buttons to the VS Code status bar.
User and workspace buttons are combined by name (case-sensitive). Workspace buttons replace the entire user button with the same name; other user buttons remain available. User buttons keep their order, and new workspace buttons are appended in workspace order. An empty workspace array adds no buttons and keeps user buttons. For example, keep your save button in User Settings and configure only project scripts in .vscode/settings.json.
"numt.buttons": [
{
"name": "Save Without Formatting",
"icon": "$(save)",
"command": "workbench.action.files.saveWithoutFormatting",
"color": "#FFFFFF"
}
]
Use buttons to collect related actions under one status bar button. Clicking the group opens a Quick Pick at the top of the VS Code window. Choose an action to run it, or press Esc to cancel. Child buttons appear only in the picker and keep their own command arguments, script variables and terminal options.
"numt.buttons": [
{
"name": "设备",
"icon": "$(folder)",
"buttons": [
{ "name": "格式化", "icon": "$(file-code)", "command": "numt.format" },
{
"name": "PLC",
"icon": "$(circuit-board)",
"script": "${workspaceFolder}/scripts/open-plc-from-current-file.ps1",
"args": ["-CurrentFile", "${file}"],
"cwd": "${workspaceFolder}",
"presentation": { "close": true }
}
]
}
]
Each top-level entry specifies exactly one of command, script, or buttons. Only one level of grouping is supported; children must be command or script buttons. Empty groups and invalid children are not displayed. Group colors apply to the status bar entry; the picker uses the current theme. User/workspace merging still uses top-level names: a workspace group replaces the entire same-name user entry, including its children. Child names do not merge across groups. Existing standalone buttons need no changes.
Use script to run a .ps1 file without a tasks.json entry. Existing command buttons and their argument behavior remain unchanged. Each button must specify exactly one of command or script.
"numt.buttons": [
{
"name": "PLC",
"icon": "$(circuit-board)",
"script": "${workspaceFolder}/scripts/open-plc-from-current-file.ps1",
"args": ["-CurrentFile", "${file}"],
"cwd": "${workspaceFolder}",
"presentation": { "reveal": "always", "panel": "shared", "clear": true, "close": true }
},
{
"name": "Build Release",
"icon": "$(tools)",
"script": "${workspaceFolder}/rust/scripts/workspace.ps1",
"args": ["-Action", "Build"],
"cwd": "${workspaceFolder}/rust"
}
]
Script paths, args and cwd support these variables, resolved when clicked:
| Variable |
Value |
${workspaceFolder} |
Folder containing the active file; falls back to the only workspace folder |
${file} |
Full path of the active file on disk |
${fileDirname} |
Active file's parent directory |
${fileBasename} |
File name including extension |
${fileBasenameNoExtension} |
File name without its final extension |
${selectedText} |
Primary selection (empty if nothing is selected) |
${lineNumber} |
Cursor line, starting at 1 |
File variables also work with active binary and custom-editor tabs that represent local files. Selection and line variables require an active text editor; other tab types do not reuse a previous editor. Missing context or unsupported variables produce an error instead of executing the script. In multi-root workspaces, open a file in the desired folder to resolve ${workspaceFolder}. Untitled documents cannot supply file path variables. Substitution applies only to script buttons; command arguments stay unchanged.
args: one string or an array of strings, passed as separate arguments. Each entry is passed as a literal PowerShell argument, including empty strings. Do not add shell quoting around paths.
cwd: absolute working directory after substitution; defaults to the resolved workspace folder. Relative script paths resolve against this directory. Without a workspace, use absolute paths.
noProfile: default false, so PowerShell loads its profiles before running the script. Set "noProfile": true on a script button to skip profile loading.
presentation.reveal: always (default), silent, or never.
presentation.panel: dedicated (default), shared, or new.
presentation.clear: default true.
presentation.close: close terminal after execution, default false.
presentation.focus: focus terminal, default false.
Scripts run as VS Code process tasks using PowerShell 7 (pwsh, must be installed and available on PATH) on all platforms by default, with -NonInteractive -ExecutionPolicy Bypass -OutputFormat Text -EncodedCommand. Profiles load by default; noProfile: true adds -NoProfile. The selected executable determines which PowerShell profiles are loaded. The encoded invocation passes the script path and argument values with PowerShell literal quoting (parameter names such as -CurrentFile remain switches), protecting selected text from shell parsing and a second round of VS Code variable substitution. Output and exit status appear in the task terminal. Repeated clicks on the same running button are rejected. Separate buttons may run concurrently; keep cross-script locking (such as build/clean mutual exclusion) in scripts. Script execution requires a trusted workspace. Paths refer to the extension host, including remote workspaces.
PowerShell profiles (1.4.4)
Starting with 1.4.4, script buttons load PowerShell profiles by default. Functions and environment variables defined in the profile are available to the script. Defining a function such as pon does not run it automatically; call it from your script when needed.
To run a button without loading profiles, set noProfile on the button itself, alongside script (not inside args):
"numt.buttons": [
{
"name": "Build without Profile",
"script": "${workspaceFolder}/tools/build.ps1",
"noProfile": true
}
]
Omit noProfile or set it to false to load profiles. Existing buttons now load profiles automatically; add "noProfile": true to retain the behavior of 1.4.3 and earlier.
PowerShell executable (1.4.5)
Script buttons now default to PowerShell 7 (pwsh) on Windows as well as other platforms. Install PowerShell 7 and make it available on PATH before running a button. The extension does not fall back to Windows PowerShell automatically and does not use the VS Code default terminal profile.
Set numt.powershellPath in user, workspace, or workspace-folder settings to choose an executable. Supply its name or full path without extra quotes or startup arguments. Changes apply on the next button click. For example, to keep using Windows PowerShell 5.1:
"numt.powershellPath": "powershell.exe"
Or select an explicit PowerShell 7 installation:
"numt.powershellPath": "C:\\Program Files\\PowerShell\\7\\pwsh.exe"
On Windows, PowerShell 7 normally loads Documents/PowerShell/Microsoft.PowerShell_profile.ps1; Windows PowerShell 5.1 loads Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1. Use $PROFILE in the selected shell to find its actual path. The button-level noProfile option still controls whether profiles load.
Settings
{
"numt.numtxt.alwayssort": "no",
"numt.numtxt.prefix": "yes",
"numt.format.indentation": 2,
"numt.format.cap": "upper",
"numt.format.sections": [
{
"node": "Items",
"property": "LinkTo"
},
{
"node": "Alarms",
"property": "LinkTo"
},
{
"node": "Recipes",
"property": "LinkTo"
}
]
}
Thank Syncfusion Metro Studio for icon.