
ScriptBox
Extend VS Code without creating extensions.
ScriptBox enables you to extend VS Code using custom JavaScript code.
To programmatically modify text, use Run Script
- Run your predefined scripts on your current selection
- Run your predefined scripts on the active editor
To create a new script, use Create Script.
To modify your existing scripts, use Edit Script.
To evaluate a JavaScript snippet, use Run Selection
- Run the currently selected text as JavaScript
- Run the active editor as JavaScript
Run Script
Execute a predefined script on your current text selection.

Usage
- Open the Command Palette (
Ctrl+P
/ Cmd+P
)
- Select ScriptBox: Create Script
- Give your script a name. e.g.
To Upper Case
- Modify the new script to manipulate selected text as needed
- Select text in another editor
- Use the Run Script command
- Select the <your script name>.js option
- Your text selection has been transformed
Script API
Each script is expected to export a single function:
function (currentSelection) {
// manipulate and return the currentSelection string
// ...
}
Each ScriptBox script is passed the current text selection as a string
(or the entire contents of the active editor if nothing is selected).
Script return value
The current text selection is replaced with the return value if a string
is returned.
The current text selection is unchanged if the return value is undefined
, null
, or false
.
Using the vscode
API
You can explicitly import the vscode
module in your script:
const vscode = require('vscode');
module.exports = function () {
// Use the vscode API here...
};
### Binding a script to a keyboard shortcut
In your keyboard shortcuts JSON file:
```json
{
"key": "cmd+u",
"command": "scriptbox.runScript",
"args": "To Upper Case.js"
}
Can I use NPM packages in my scripts?
Yes, just use npm
/yarn
/etc... to add packages.json
to your ~/.scriptbox/
directory, add the packages needed, and then require('the-package')
within your scripts.
Run Selection
Execute the currently selected JavaScript text (or the entire content of the active editor, if nothing is selected).

Known Issues
None
Credits
Logo based on Hexagon by Chris Kerr from the Noun Project
Release Notes
The CHANGELOG contains release notes for each release.