I really like Copilot however its comment suggestions can be nonsensical and really distracting.
Is there any way to leave the code suggestions on but turn Copilot off whenever I'm editing/adding a comment amidst the code?
I really like Copilot however its comment suggestions can be nonsensical and really distracting.
Is there any way to leave the code suggestions on but turn Copilot off whenever I'm editing/adding a comment amidst the code?
Here's a workaround I figured out for how to fix the comment suggestions problem! 🚀
The basic idea is to create a keyboard shortcut that we press in order to disable the inline suggestions from popping up. So before we write a comment, we can just press the keyboard shortcut to disable suggestions, then write the comment, and then press the keyboard shortcut to enable suggestions again. It's not a perfect solution, but it works!
To do this:
key
in order to have it work. (As of the time this comment was written, github.copilot.inlineSuggest.enable
is the setting we need to toggle here. If they ever change that setting name in the future you'd have to change the below snippet accordingly.){
"key": "shift+cmd+c", // set this to whatever works for you
"command": "toggle",
// By the way, this "when" expression was inspired from the "when" expression for Copilot
// extension's "Trigger Inline Suggestions" keyboard shortcut.
"when": "editorTextFocus && !editorHasSelection",
"args": {
// This id is just a unique name you come up with yourself
"id": "toggleGithubCopilotInlineSuggestionsBeingEnabled",
// The names and values of the setting you want to toggle. In this case, it's to enable/disable the
// `github.copilot.inlineSuggest.enable` setting.
"value": [
{
"github.copilot.inlineSuggest.enable": true
},
{
"github.copilot.inlineSuggest.enable": false
}
]
}
},
For more info on how to setup a toggle keyboard shortcut you can look at the extension page for the Toggle extension. You can also read more info about it here.
Note: This will allow you to disable inline suggestions from showing up. But it won't make a current inline suggestion, that's already showing, vanish. Just press Esc in that situation if it ever comes up. Ideally, you'd disable inline suggestions ahead of time before they'll pop up. That way you'll never have to press Esc.
I was annoyed at this too, and failed to find a decent automated solution anywhere on the web. So, I wrote a VSCode extension that watches the TextMate scopes wherever your active selection is, and if it detects a scope that contains comment
, temporarily disables Copilot's inline suggestions until your caret is anywhere without a scope that contains comment
.
Or, in short, it makes Copilot get out of your way whenever you're writing a comment, and lets it do its magic everywhere else.
Hopefully you can find some use for it as well.
Answer based on current state
I think Esc
does that (hide the inline suggestions in VSCode).
I use the Shift+Esc
shortcut to dismiss (hide) the inline suggestions in the editor. From here, we can see that the Esc
shortcut is mapped to editor.action.inlineSuggest.hide
. In my keybindings.json, I have the following
// Dismiss GitHub copilot suggestions
{
"key": "shift+escape",
"command": "editor.action.inlineSuggest.hide",
"when": "editorTextFocus"
}
I see @jaquinocode's answer probably has a better solution.
Press ctrl+shift+p
Enter GitHub Copilot: Enable/Disable Copilot complitions
Now you can assign any keybinding you desire. I use ctrl+capsLock ctrl+capsLock
.
© 2022 - 2025 — McMap. All rights reserved.