The PSESHelperLibrary module provides tools to assist in interacting with PowerShell Editor Services along with some commands for general editing use.
This project is at a very early stage and does not currently have an official release. But feel free to try it out and let me know needs to change.
Tag functions as editor commands with the PSEditorCommand attribute. Import them with the Import-EditorCommand function to automatically add the Context parameter and register them with Editor Services.
#requires -Module PSESHelperLibrary
using module PSESHelperLibrary
function Invoke-MyEditorCommand {
[PSEditorCommand(DisplayName='Invoke my editor command')]
[CmdletBinding()]
param()
if ($Context) {
$Context.CurrentFile.InsertText('I am an editor command!')
}
}
Import-EditorCommand -Command Invoke-MyEditorCommand
Or import all the editor commands tagged in a module with Import-EditorCommand -Module MyModule
.
Expand normal member expressions with private members to working reflection statements.
Replace selected text with it's return value.
More demos for existing features are coming soon, as well as commands and tools for command creators.