Run Javascript macros to transform the content of documents in VS Code.
cd ~/.vscode/extensions
git clone [email protected]:eduardoportilho/jsmacros.git
Macros can be created by adding javascript files to the folder macros
inside of the extension folder. Depending on your platform it is located:
- Windows
%USERPROFILE%\.vscode\extensions\jsmacro
- Mac
$HOME/.vscode/extensions/jsmacro
- Linux
$HOME/.vscode/extensions/jsmacro
Your JS macro should contain the body of a function that recieves the current document content through the documentContent
parameter and should return the modifyed content, like in the following example:
// Macro short description
return documentContent.replace(/\s/g, "");
The file name will be used as the macro name and a comment on the first line will be used as the description.
Command+shift+P
- Type "jsmacro", hit enter
- Chosse a macro, hit enter
- Boom, done
- Set breakpoints
- F5 (Run > Start Debugging)
- Debug configuration on
.vscode/launch.json
- Debug configuration on
- A new VSCode instance will open where you can execute the macros
MIT