Can GitHub Copilot stop auto-suggesting, instead be triggered by a keystroke?
Asked Answered
W

6

62

I find Github Copilot very helpful in some specific situations, but fairly unhelpful in its verbosity in most situations.

By default, it's always on, always suggesting (and frequently getting in my way.) I want it to be less aggressive, disabling the auto-suggestion, but still have it readily available at a keystroke.

What I've tried already:

In a helpful post, I see that Alt\ is the default key for triggering Copilot suggestions. Great, that's half of the solution.

In settings.json, setting the following seems to disable copilot entirely! It is no longer available using the keyboard shortcut.

    "github.copilot.inlineSuggest.enable": false

I wonder if that's a bug, because there's already multiple ways to disable copilot entirely.

Winshell answered 22/2, 2022 at 16:30 Comment(2)
Exactly, copilot seems no longer to work. – Nebo
In case you came here looking for how to turn it off in Visual Studio 2022, there's a sub menu inside Edit which turns it on and off. – Writer
W
63

In settings.json (under File, Preferences, Settings), I found that setting the more general option:

    "editor.inlineSuggest.enabled": false,

Seems to work as I'd hoped. Copilot suggestions are now only provided on-demand, when I press Alt\, and accepted when I press Tab

I worry that this might disable other types of suggestions I rely on... but language auto-completion still seems to work. I'll update this answer if I find anything I miss.

BTW, changing the keyboard shortcuts:

Under File, Preferences, Keyboard Shortcuts, if you search for inlinesuggest, you see the keystrokes for both triggering inline suggestion and for committing (aka, accepting) inline suggestions. Double-click the row to change the key (but watch out for conflicts.)

VSCode settings for inline suggestions

Winshell answered 22/2, 2022 at 16:30 Comment(6)
Did you miss other suggestions in the end, or is this solution still working? I am trying out copilot, but like you I cannot take the continuous dumping of BS in my code – Frenchify
@Frenchify - I still have it off, haven't missed anything. πŸ‘ Sadly, my copilot trial ran out, so I can't comment on the current state of that. – Winshell
Well, my company pays for copilot, so I can turn it back on. Sadly, I can't get a nice UX without switching inlineSuggest on and off. When it's on, it suggestions show up too often and conflict with intellisense / completion. When it's off, it's hard to trigger and I can't get it to accept (tab doesn't accept copilot suggestions, only intellisense.) I want both, but usually intellisense, and copilot only upon `ALT-` request – Winshell
It doesn't work for me either. Asking ChatGPT is way more bang for you buck IMO. Maybe Copilot X will change things.. – Frenchify
While this solution still works, there is a new propper setting (since April 23) that fixes this: "github.copilot.editor.enableAutoCompletions": false – Linus
see also this thread: github.com/orgs/community/discussions/7323?sort=new – Corrigan
C
18

For Jetbrains IDE (e.g. Webstorm).

You can uncheck automatically show completions in the IDE's settings (Settings > Languages & Frameworks > GitHub Copilot). enter image description here

and then still TRIGGER completion with a keystroke Alt+\ or any keymap you are comfortable with (Settings > Keymap > "Copilot" in the search bar): enter image description here

Corporeity answered 20/12, 2022 at 14:46 Comment(1)
Is there a way to do this in Visual Studio 2022? – Vacla
T
12

The top rated solution does not seem to work anymore. However the above solution by @BiasInput also works in VSCode.

Open user settings.json and set "github.copilot.editor.enableAutoCompletions": false enter image description here

Then trigger copilot suggestions with the keyboard shorcut you assigned to the command editor.action.inlineSuggest.trigger. enter image description here

Timekeeper answered 11/5, 2023 at 8:54 Comment(1)
@jeff-ward's solution seems to still work in VS Code for me. Disabled editor.inlineSuggest.enabled and I can trigger inline suggestion by keyboard shortcut if desired – Thermosetting
M
6

UPDATE 2024

I've made this extension in VS Code, which makes this whole process much easier: https://marketplace.visualstudio.com/items?itemName=Bubulus.copilot-inline-toggle

Old Post

For anyone who just needs to temporarily disable the inline suggestion that overrides intellisense --> a convenient solution that worked for me, was toggling this setting:

"github.copilot.editor.enableAutoCompletions"

When true, Copilot will work as expected, and give you his inline greyed-out suggestions that can be accepted with tab.

When false, Copilot will still work, but the inline suggestions and autocomplete on tab will be disabled. Thus if you are seeking to temporarily only go for intellisense autocompletion, then this does the trick well.

For toggling, I choose the Settings Cycler VS Code extension.

To configure this, you need to add the toggle behavior with a corresponding unique id to your settings.json file. For example, I have this config:

 "settings.cycle": [
    {
      "id": "copilotInline",
      "overrideWorkspaceSettings": false,
      "values": [
        {
          "github.copilot.editor.enableAutoCompletions": true
        },
        {
          "github.copilot.editor.enableAutoCompletions": false
        }
      ]
    }
  ],

Then to toggle between those two provided values, just add a preferred keybinding to the command by citing the chosen id like this in the keybindings.json file:

  {
    "key": "ctrl+oem_3",
    "command": "settings.cycle.copilotInline"
  }

In my case on ctrl + ΓΆ I toggle between those states now!

Monosome answered 31/8, 2023 at 20:7 Comment(1)
This is fantastic. Thanks for taking the time to explain it and make an extension for it. It happens to be exactly what I've been looking for for weeks – Sha
E
0

As of May 2024, to simply toggle the Copilot suggestions on and off, go to "Settings" > "Keyboard Shortcuts" ("⌘K + ⌘S). Search for "toggleCopilot" (github.copilot.toggleCopilot). Hover over that row. Click the "+" that displays on the far left. Then type in your preferred keyboard shortcut.

I use ⌘A + ⌘I as my shortcut.

Eldrida answered 21/5, 2024 at 23:13 Comment(0)
C
-2

The below image is from Pycharm. It seems to do the trick for me. enter image description here

Cumae answered 15/4, 2024 at 6:19 Comment(0)

© 2022 - 2025 β€” McMap. All rights reserved.