Is there an easy way to get selected text into a variable similar to native variable ${lineNumber} which is the current selected line number? It would be very useful as a parameter for link to online help etc. Thank you.
get selected text into a variable VSCode
Asked Answered
the easiest way you can get the current selected text I know of is... const editor = vscode.window.activeTextEditor; var selection = editor.selection; var text = editor.document.getText(selection); –
Ils
It will be $(selectedText} once this vscode github code is released.
Edit: It's actually available now.
Can you please explain how to use this variable in VSCode? –
Bandmaster
this variable is to be used in debugging and task configurations: code.visualstudio.com/docs/editor/variables-reference –
Hsiuhsu
© 2022 - 2024 — McMap. All rights reserved.