visual-studio-codevscode-keybinding

How to trigger "inline suggestion" in VSCode?


There're two built-in commands for showing "inline suggestion":

I've tried both, but nothing happened, in what circumstance could an inline suggestion be triggered?


Solution

  • For v1.58+, see Inline Suggestions:

    Inline Suggestions

    The inline suggestions API allows extensions to provide inline suggestions that are decoupled from the suggestion widget. An inline suggestion is rendered as if it was already accepted, but with a gray color. Users can cycle through suggestions and accept them with the Tab key.

    vscode.languages.registerInlineCompletionItemProvider(
      { pattern: '**' },
      {
        provideInlineCompletionItems: async (document, position) => {
          return [{ text: '< 2) {\n\treturn 1;\n\t}' }]
        },
      },
    )
    

    Demo:

    enter image description here