Automating Visual Studio Code
Automate Visual Studio Code with PowerShell
Overview
Using PowerShell Pro Tools for Visual Studio Code you can automate the editor itself. This allows you to script repetitive actions you may take within Visual Studio Code. You can edit documents, show information and more.
Getting Started
To automate Visual Studio Code, you will need to first import the PowerShell Pro Tools VS Code module.
Once the module is loaded, you can begin running commands.
Available Commands
Opening Documents
Open documents by file name.
Closing Text Editors
Close editors that are already open.
Getting Document Text
Get the text of a document. You can also pass in a range to select only a partial section of the text.
Inserting Text
Inserts text into a particular position in the selected document. This creates an edit but does not save the file.
Removing Text
Removes a range of text from a document. This creates an edit but does not save the file.
Setting Text Decorations
Decorates a range of text with an optional set of colors, outlines, borders, and text.
You can clear decorations by using the Clear-VSCodeTextEditorDecoration cmdlet. If you want to only clear a single decoration, you can specify the key.
Sending Text to a Terminal
Sends text to the specified terminal. You can commit this text by including the -AddNewLine parameter.
Showing Messages
Show a message to the user. You can show information, warning, and error messages.
Showing a Message with a Response
Show a message to the user and provide an option for them to select.
Showing a Quick Pick List
Shows a quick pick list for a user to select items from. This cmdlet will return the user’s selection to PowerShell.
Showing an Input Box
Shows an input box for the user to enter arbitrary text. This cmdlet will return the result to PowerShell.
Set Status Bar Message
Sets the status bar message.
Last updated