5

I'm new to VSCode and I want to test it to compare with my sublime text configuration. I want to create a very simple snippet that allow me to write ruby code <%= %> when I only press < key.

Here is my snippet's code :

    "My snippet": {
        "prefix": "<",
        "body": [
            "<%= $1 %>"
        ],
        "description": "My snippet"
    }

So this code works but I have to press Ctrl+Space in my file to show the IntelliSense list (with my snippet). I just want to press < and Tab to complete this, not to press Ctrl+Space always.

Do you know if there's a configuration to do it ?

Thanx

1
  • 1
    I'm interested in the opposite. My vscode provides suggestion after the first character, which I find annoying. I'd rather it do that only after the third character, but I was unable to find such a setting.
    – Leo
    Oct 11, 2018 at 20:06

3 Answers 3

8

It is a long time since your question, but I think it may help others.

In settings you need to enable editor.tabCompletion, then you can press tab even if there is no IntelliSense.

3

To have the snippet auto-injected into the VS Code Editor when you press Tab after the prefix (even this is only one character), you need to set the editor.tabCompletion setting to onlySnippets, neither off nor on.

    "editor.tabCompletion": "onlySnippets",

personally, I think this is a very strange behavior, and that, in theory, with the value on the tabCompletion option should also work. but somehow this option works like that, at least for me.

1

There are two configuration values you can set in order to let VSCode show suggestions and snippets immediately.

    // Controls if quick suggestions should show up or not while typing
    "editor.quickSuggestions": true, 

    // Controls the delay in ms after which quick suggestions will show up
    "editor.quickSuggestionsDelay": 0,

With this setup suggestions popup as soon as possible.

2
  • 1
    Thanx for your response. I tried your 2 lines in my settings, but when i press "<" and "tab" nothing appears (my snippet no works). Press "<" and "ctrl + space" works always but this is not my need :) When I specify a letter in my snippet, for example, "prefix": "p" instead of "prefix": "<", it works when I press "p + tab" in my file.
    – John
    Dec 8, 2016 at 12:41
  • @John hello John, i have the problem that same you, have you solved it yet? Jul 26, 2023 at 19:55

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.