在触发之前,如何将输入到Visual Studio代码用户定义的代码段

发布于 2025-01-24 17:35:07 字数 656 浏览 2 评论 0原文

我知道如何在VSCODE中制作代码片段。例如,要构建一个1-D数组,我已经定义了一个代码片段,如下所示 -

"Create a 1-dimensional Array": {
        "prefix": "darr",
        "body": [
            "${1:Type}[] ${2:name} = new ${1:Type}[${3:Size}];",
            "$4"
        ],
        "description": "Creating a 1-dimensional Array"
    }

工作正常。但是,这里有些事情正在减慢我的生产力,因为我必须在触发后一次又一次地按下该片段,从而给予数组类型,名称及其大小。

是否可以在触发vscode用户定义的片段中将这些详细信息提供给它?例如 - 如果我编写booleanarr10,则将创建一个代码为 - boolean [] arr = new boolean [10]; 或者,如果我编写Intarr50,则它将创建一个代码为 - int [] arr = new Int [50];

甚至可以做到的扩展名也对我来说很好。 请建议。

I am aware of how to make code snippets in VSCode. For example, to build a 1-d array, I have defined a code snippet as shown below-

"Create a 1-dimensional Array": {
        "prefix": "darr",
        "body": [
            "${1:Type}[] ${2:name} = new ${1:Type}[${3:Size}];",
            "$4"
        ],
        "description": "Creating a 1-dimensional Array"
    }

Which is working perfectly fine. But here something is slowing down my productivity as I have to give array type, name and its size by pressing tab again and again to this snippet after triggering.

Is it possible to give these details to the vscode user defined snippet before triggering it? For example -
If I write booleanarr10, then it will create a code as - boolean[] arr = new boolean[10];
Or If I write intarr50, then it will create a code as - int[] arr = new int[50];

Even an extension that can do it is fine for me.
Please suggest.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文