如何在VSCode的代码段中将转换应用于变量?

使用下面的代码,我想将$ 2中的变量转换为小写字母,但我无法完全使它起作用。

    "Build Model": {
        "prefix": "mod","body": [
            "import '${1:../backend.dart}';","","class ${2:Class} extends ManagedObject<_$2> implements _$2 {}","${2/(*)/${2:/downcase}/}","${2:/downcase}" //would be nice to be able to do this
            "@Table(name: \"${2/(*)/${2:/downcase}/}\")","class _$2 {","@Column(primaryKey: true,autoincrement: true,indexed: true)","int id;","$3","}",""
        ],"description": "Build a data model"
    },
hualushui1129 回答:如何在VSCode的代码段中将转换应用于变量?

通过如下更改使它起作用:

"${2/([a-zA-Z]*)/${1:/downcase}/}",

这里$ 1是指此表达式中的变量(即$ 2),而不是$ 1较高的变量。

编辑: 请参阅下面有关使用(。*)代替的答案。

本文链接:https://www.f2er.com/3155927.html

大家都在问