阅读 sminippets文档片段主体在摘要前缀之后键入它。
假设我有一个带有 log
前缀的摘要,我想在 log> log(*+)
之类的内容中转换前缀以捕获文本之后。
如果我键入 loganObject
,则剪切应捕获“ AnObject”,并致电我的摘要以插入一些文本,例如 console.log(“ AnObject的值为:”,AnObject); 。
有可能吗?
我认为不可能是不可能的,因为VSCODE应该认识到我仍在键入摘要的前缀,并且在摘要主体内应捕获和使用前缀后的文字,但我希望他们意识到这样的东西。
After reading the snippets documentation I'm still searching a way to pass some text inside the snippet body by typing it after the snippet prefix.
Let's say I have a snippet with log
prefix, I would like to transform the prefix in something like log(*+)
to capture the text after.
If I type loganObject
, the snipped should capture "anObject" and call my snippet to insert some text like console.log ("the value of anObject is: ", anObject);
.
Is that possible?
I think that it is not possible because vscode should recognize that I'm still typing the prefix of the snippet and the text after the prefix should be captured and used inside the snippet body, but I hope they realized something like this.
发布评论
评论(1)
这是一个可以执行您想要的操作的键绑定,但您必须首先选择文本 Shift+Home,这是该行中唯一的文本。
使用
log.myTextHere
作为匹配文本,即开头的log.
只是为了清楚起见。在您的
keybindings.json
中:另外,更简单、更灵活的是使用我编写的扩展,查找并变换,执行此操作。使用此键绑定:
如果您只想使用
log
而不是log.
,则可以更改substring(4)
。Here is a keybinding that does what you want, but you have to select the text first Shift+Home and that is the only text on the line.
Using
log.myTextHere
as the matched text, i.e.,log.
at the beginning just to be clear.In your
keybindings.json
:Alternatively, and a little easier and more flexible, is to use an extension I wrote, Find and Transform, to do this. Use this keybinding:
You could change
substring(4)
if you just want to uselog
and notlog.
.