get selected text into a variable VSCode
Asked Answered
R

1

8

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.

Ro answered 25/5, 2017 at 8:7 Comment(1)
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
S
2

It will be $(selectedText} once this vscode github code is released.

Edit: It's actually available now.

Sage answered 13/3, 2018 at 16:59 Comment(2)
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-referenceHsiuhsu

© 2022 - 2024 — McMap. All rights reserved.