Visual Studio代码:在输入代码片段时替换字符大小写

2023-11-30

我正在尝试为 Visual Studio Code 和 TypeScript 编写代码片段。到目前为止,我成功地镜像了这样的输入单词:

import { ${1:Name}Component } from './${1:name}.component';

当我在第 1 处输入单词时,它会镜像到第 2 处,如下所示:

import { MynameComponent } from './Myname.component';

是否可以更改代码片段,使#2 的位置变为小写,如下所示:

import { MynameComponent } from './myname.component';

vscode v.1.25 最近添加了转换代码片段的功能。在你的情况下尝试这个片段:

"import components": {
    "prefix": "isml",
    "body": [
      "import { ${1/(.*)/$1Component } from '.\\/${1:/downcase}/}.component'",
    ],
    "description": "small"
  },

Trigger the prefix. Then hit tab after you enter your component name (Myname in this example) and it will complete the snippet as you wanted.

import { MynameComponent } from './myname.component';
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Visual Studio代码:在输入代码片段时替换字符大小写 的相关文章

随机推荐