Visual studio code: replace char case while typing in snippet

让人想犯罪 __ 提交于 2019-12-11 12:32:48

问题


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

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

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

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

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

回答1:


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"
  },

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


来源:https://stackoverflow.com/questions/48487060/visual-studio-code-replace-char-case-while-typing-in-snippet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!