vscode-ext-selection
v1.0.1
Published
VS Code Selection helper functions
Downloads
24
Maintainers
Readme
vscode-ext-selection
This module contains a set of helper functions to work with text selection while developing VS Code extensions.
Installation
npm install vscode-ext-selection
Usage
import { Directions, selectLines, expandSelectionToPosition, shrinkSelectionToPosition } from "vscode-ext-selection";
...
if (selectWordAtCursorPosition(editor)) {
vscode.env.clipboard.writeText(editor.document.getText(editor.selection));
} else {
vscode.commands.executeCommand("editor.action.clipboardCopyAction");
}
...
const lines: number[] = [];
for (const bookmark of bookmarks.activeBookmark.bookmarks) {
lines.push(bookmark.line);
}
selectLines(vscode.window.activeTextEditor, lines);
...
const line = 10;
const column = 20;
const nextPosition = new vscode.Position(line, column);
expandSelectionToPosition(vscode.window.activeTextEditor, nextPosition, Directions.Forward);
shrinkSelectionToPosition(vscode.window.activeTextEditor, nextPosition, Directions.Backward);
Support
If you find it useful, please consider supporting it.
License
MIT © Alessandro Fragnani