问题描述
我想为评论定义一个片段,例如
//************//* foo A1 *//************
在我输入 foo A1
的地方,它会创建一个带有 (6+ len(${1}) 星号等的行 - 是否可行,如果可行,如何操作?
虽然我是
I would like to define a snippet for comments like
//************
//* foo A1 *
//************
where I enter foo A1
and it would create a line with (6+ len(${1}) asterisks etc. - is that doable and if so, how?
While I am a big proponent of HyperSnips (see
[VSCODE]: Is there a way to insert N times the same characters,
VS Code: how to make a python snippet that after string or expression hitting tab will transform it and
VSCode Advanced Custom Snippets for how to use it),
it is instructive to see how to do this with just the built-in snippet functionality in vscode. Here is a snippet that does what you want:
"Custom Comment": {
"prefix": ["cc2"], // whatever trigger you want, then tab, write your info and tab again
"body": [
"//***${1/./*/g}***",
"//* $1 *",
"//***${1/./*/g}***"
]
},
That just adds 3 asterisks to the beginning and 3 to the end of your added comment, each character of which is replaced by an asterisk as well.
这篇关于是否可以有一个考虑我输入长度的片段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!