for TM_CURRENT_LINE:
use document.lineAt(editor.selection.active).text; or
let pos = editor.selection.active;
let range = new vscode.Range(pos.line,0,pos.line,pos.character-2) //delete snippet "bk"
let text=document.getText(range);
vscode.window.activeTextEditor.edit(editBuilder => {
editBuilder.delete(document.lineAt(pos).range);
});
rv=text;
e.g.
snippet bk "test" iA
\left(``
let pos = editor.selection.active;
let range = new vscode.Range(pos.line,0,pos.line,pos.character-2) //delete snippet "bk"
let text=document.getText(range);
vscode.window.activeTextEditor.edit(editBuilder => {
editBuilder.delete(document.lineAt(pos).range);
});
rv=text;
``\right)
endsnippet
then you will get:
this code seems ugly but at least it works 😂. Thanks to @OrangeX4 .
add these into your
.hsnips
file:then:
for
TM_SELECTED_TEXT
: add the code betweenglobal
andendglobal
:and use that in your snippet like:
rv=selectedText; selectedText=""
e.g.:result:
for
TM_CURRENT_LINE
: usedocument.lineAt(editor.selection.active).text;
ore.g.
then you will get:
this code seems ugly but at least it works 😂. Thanks to @OrangeX4 .
Originally posted by @yfzhao20 in https://github.com/draivin/hsnips/issues/81#issuecomment-970168548