19

I can get some suggestions by copilot in .md files, But when I keydowned Tab, it only added a space, not autocompletes the suggestion, What should I do can autocomplete the suggestion?

enter image description here

2 Answers 2

45

To enable suggestions for GitHub Copilot with a Tab key, follow the steps below.

  1. Open the file keybindings.json in Visual Studio Code. This can be done by pressing Ctrl + Shift + P, and typing Open Keyboard Shortcuts (JSON).

  2. In keybindings.json, add the following (inside the existing square brackets []):

    {
        "key": "tab",
        "command": "editor.action.inlineSuggest.commit",
        "when": "textInputFocus && inlineSuggestionHasIndentationLessThanTabSize && inlineSuggestionVisible && !editorTabMovesFocus"     
    }
    

Make sure to restart VS Code after this.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for your answer, I tried a while, editor.action.inlineSuggestion.commit is a invalid command, but editor.action.inlineSuggest.commit is a valid command, base on your code, I wrote a seems correct keybinds Comments cnat't add block code, so I edited my question for adding keybinds Thanks again
json { "key": "tab", "command": "editor.action.inlineSuggest.commit", "when": "textInputFocus && inlineSuggestionHasIndentationLessThanTabSize && inlineSuggestionVisible && !editorTabMovesFocus" },
You are a god. I looked for 1 full day on how to resolve this junk and only you gave me a working solution. Thank you so much, truly.
Do not forget to restart your VS code after this.
4

Solution-

For me Right arrow key works to accept suggestion. Try Right arrow key.

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.