search

Home  >  Q&A  >  body text

How to add custom suggestions in VS Code?

How do I add this so that when I type a word "key" into VS Code it changes it to "keyhole" (dumb example I know)?

I tried looking at the settings but got no further.

P粉207483087P粉207483087454 days ago439

reply all(2)I'll reply

  • P粉752479467

    P粉7524794672023-09-08 10:24:48

    If you have complex text segments with fields, you can use fragments.

    If you just want to replace text, check out

    Complete from file

    reply
    0
  • P粉920485285

    P粉9204852852023-09-08 09:21:40

    In the simple case shown above, you can write a custom code snippet. (See Snippets in Command Palette: Configuring User Snippets Commands) For example.

    {
        "key": {
            "prefix": "key",
            "body": "key hole",
            // "scope": "java" // uncomment to make it only apply for Java files
        }
    }
    

    I think that aside from writing or using an extension that helps achieve this, the suggestion (outside of snippets) could be to use plain (no extension) VS Code for configuration.

    reply
    0
  • Cancelreply