Note
This document is provided under the CC0 1.0 Universal license (Creative Commons Zero).
This license allows anyone to freely use, modify, and distribute the content without requiring attribution, effectively placing it in the public domain.
It is primarily intended for co-workers, friends, and acquaintances.
In Visual Studio Code, the suggestion widget interferes with GitHub Copilot’s inline suggestions,
leading users to frequently press Escape to access Copilot’s suggestions or disable the suggestion widget entirely,
disrupting their workflow and causing frustration.
This issue occurs because pressing Tab defaults to the suggestion widget, sidelining Copilot's functionality.
Note
Simply removing the Tab shortcut for the suggestion widget causes the editor to insert tab characters instead of accepting inline suggestions, making it an ineffective solution.
This document addresses this conflict by subtly modifying keybindings to prioritize Copilot’s inline suggestions when both features are visible, without compromising the usability of the suggestion widget.
Key changes:
- Adding
!inlineSuggestionVisibleto theacceptSelectedSuggestioncommand prevents the suggestion widget from overriding Copilot suggestions. - Remove
!suggestWidgetVisiblefrom theeditor.action.inlineSuggest.commitcommand allows Copilot’s suggestions to be accepted even when the suggestion widget is visible.
These refinements retain default behaviors wherever possible, offering a more seamless integration of Copilot and IntelliSense in VS Code.
Caution
- Backup your current keybindings before making changes.
- If you've previously modified your keybindings, adjust the following instructions accordingly.
- Default keybinding values are provided below for reference.
You can modify your keybindings by following these steps:
- Press
Ctrl + Shift + P(Windows/Linux) orCmd + Shift + P(macOS) to open the command palette. - Start typing
Preferences: Open Keyboard Shortcuts (JSON)and select it. This opens thekeybindings.jsonfile. - Modify the
whenclauses of corresponding commands as detailed below.
Note
Alternatively, modify keybindings via the UI by pressing Ctrl + K, then Ctrl + S (Windows/Linux) or Cmd + K, then Cmd + S (macOS) to open the Keyboard Shortcuts interface.
tab:
No changes required.
{
"key": "tab",
"command": "tab",
"when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus"
}acceptSelectedSuggestion:
Add !inlineSuggestionVisible to the when clause.
{
"key": "tab",
"command": "acceptSelectedSuggestion",
"when": "!inlineSuggestionVisible && suggestWidgetHasFocusedSuggestion && suggestWidgetVisible && textInputFocus"
}Accept Inline Suggestion (editor.action.inlineSuggest.commit):
Remove !suggestWidgetVisible from the when clause.
{
"key": "tab",
"command": "editor.action.inlineSuggest.commit",
"when": "inlineSuggestionHasIndentationLessThanTabSize && inlineSuggestionVisible && !editorHoverFocused && !editorTabMovesFocus || cursorAtInlineEdit && inlineEditIsVisible && !editor.hasSelection && !editorHoverFocused && !editorTabMovesFocus || inlineEditIsVisible && inlineSuggestionHasIndentationLessThanTabSize && inlineSuggestionVisible && !editorHoverFocused && !editorTabMovesFocus || cursorAtInlineEdit && inlineEditIsVisible && inlineSuggestionVisible && !editor.hasSelection && !editorHoverFocused && !editorTabMovesFocus"
}To revert to default keybindings:
- Right-click the modified keybinding in the UI and select
Reset Keybinding. - If a keybinding was deleted, search for the command in the Keyboard Shortcuts UI and reset it from there.
Tip
If a command retains another keybinding, use it to quickly add a new keybinding with the original key, allowing you to reset it to the default.
Alternatively, copy the relevant default keybindings below into your keybindings.json file:
tab:
{
"key": "tab",
"command": "tab",
"when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus"
}acceptSelectedSuggestion:
{
"key": "tab",
"command": "acceptSelectedSuggestion",
"when": "suggestWidgetHasFocusedSuggestion && suggestWidgetVisible && textInputFocus"
}Accept Inline Suggestion (editor.action.inlineSuggest.commit):
{
"key": "tab",
"command": "editor.action.inlineSuggest.commit",
"when": "inlineSuggestionHasIndentationLessThanTabSize && inlineSuggestionVisible && !editorHoverFocused && !editorTabMovesFocus && !suggestWidgetVisible || cursorAtInlineEdit && inlineEditIsVisible && !editor.hasSelection && !editorHoverFocused && !editorTabMovesFocus && !suggestWidgetVisible || inlineEditIsVisible && inlineSuggestionHasIndentationLessThanTabSize && inlineSuggestionVisible && !editorHoverFocused && !editorTabMovesFocus && !suggestWidgetVisible || cursorAtInlineEdit && inlineEditIsVisible && inlineSuggestionVisible && !editor.hasSelection && !editorHoverFocused && !editorTabMovesFocus && !suggestWidgetVisible"
}