5

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

  • editor.action.inlineSuggest.showPrevious
  • editor.action.inlineSuggest.showNext

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

Wenfang Du
  • 8,804
  • 9
  • 59
  • 90
  • 1
    There is also `editor.action.inlineSuggest.trigger` but in my testing I can't get it to work in Stable or Insiders. Make sure you have `Editor > Inline Suggest: Enabled` enabled, but it just doesn't work for me in Stable. In the Insiders, I can get the inline suggestions to show up, but your commands you asked about do nothing. So these new commands and the `inlineSuggestions` functionality are not ready IMO. – Mark Jul 06 '21 at 04:58
  • 1
    The answer here is for extensions, but as of v1.66 this can be enabled for users. See https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_66.md#quick-suggestions-as-inline-completions and https://stackoverflow.com/a/71622262/836330 – Mark Mar 25 '22 at 19:42

2 Answers2

5

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

Wenfang Du
  • 8,804
  • 9
  • 59
  • 90
Mark
  • 143,421
  • 24
  • 428
  • 436
2

VS Code now allows you to choose how you'd like to code suggestions to appear.

By default, they appear in a widget, but you can also choose them to appear in-line as you write.

If you want the code suggestions to be shown in-line, then go to Settings by pressing down CTRL + , (comma) and type in quick suggestions.

Edit the item labeled other and select the inline value.

enter image description here

The in-line code suggestion looks like this:

enter image description here

Source

Carol-Theodor Pelu
  • 906
  • 2
  • 10
  • 26