Visual Studio代码:在输入代码段时替换字符大小写 [英] Visual studio code: replace char case while typing in snippet

查看:80
本文介绍了Visual Studio代码:在输入代码段时替换字符大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to write code-snippet for Visual Studio Code and TypeScript. So far I managed to mirror typed word like this:

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

当我在#1位置键入单词时,它会像这样被镜像到#2位置:

When I type the word in place #1 it is mirrored to place #2 like this:

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

是否可以更改代码段,使位置#2像这样小写:

Is it possible to change snippet so the place #2 is in lower case like this:

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


推荐答案

转换片段的功能最近已添加vscode 1.25版。在您的情况下,请尝试以下代码段:

The ability to transform snippets has been more recently added in vscode v.1.25. In your case try this snippet:

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

触发前缀。输入您的组件名称(在本例中为Myname)后,按 tab ,它将按需要完成代码段。

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';

这篇关于Visual Studio代码:在输入代码段时替换字符大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆