1

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

1 Answer 1

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';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.