How to disable VSCode Copilot auto-completion unless shortcut key is pressed?
I want to prevent VSCode Copilot from automatically completing code as I type, and only have it provide suggestions when I explicitly use the shortcut key ALT+\ (which I’ve remapped to Tab). Currently, Copilot is auto-completing code fragments like “props.” to “preProcess” or “UNSAFE_WithComponentsProps” as soon as I type a period or space.
I’ve tried the following settings in my VSCode settings.json file:
- “github.copilot.enable”:
- “github.copilot.inlineSuggest.enable”: false
- “github.copilot.editor.enableAutoCompletions”: false
None of these settings have any effect, even after completely closing and reopening VSCode. What is the correct way to disable auto-completion while still allowing manual triggering with the shortcut key?
Brief Answer
To disable VSCode Copilot’s auto-completion while keeping manual triggering, you need to set "github.copilot.editor.enableAutoCompletions": false
in your VSCode settings.json file alongside "github.copilot.inlineSuggest.enable": false
. Additionally, ensure your manual trigger shortcut is properly configured in keybindings.json. The key is to keep Copilot enabled globally while disabling automatic completions.
Contents
- Understanding Copilot’s Auto-completion Behavior
- Correct Settings Configuration
- Shortcut Key Configuration
- Troubleshooting Steps
- Alternative Approaches
- Conclusion
Understanding Copilot’s Auto-completion Behavior
VSCode Copilot has two main modes of operation that might be causing your issue:
- Inline suggestions that appear automatically as you type
- Manual suggestions triggered explicitly by shortcut keys
The behavior you’re experiencing—where code completes automatically when you type a period or space—is likely the inline suggest feature providing real-time suggestions without explicit user action. This is distinct from traditional IntelliSense completions and is specifically controlled by Copilot’s own settings.
The confusion often arises because Copilot integrates with VSCode’s suggestion system but operates independently of it. Even when traditional auto-completion is disabled, Copilot’s inline suggestions may still appear if not properly configured.
Correct Settings Configuration
Based on your attempts, here’s the precise configuration that should work in your VSCode settings.json file:
{
"github.copilot.enable": true,
"github.copilot.inlineSuggest.enable": false,
"github.copilot.editor.enableAutoCompletions": false
}
Let me clarify what each setting controls:
"github.copilot.enable": true
- Keeps Copilot active but doesn’t enable completions"github.copilot.inlineSuggest.enable": false
- Prevents inline suggestions from appearing automatically"github.copilot.editor.enableAutoCompletions": false
- Disables Copilot’s integration with the editor’s auto-completion system
Important note: The setting
"github.copilot.enable": { "*": false }
you tried uses pattern matching which might not work as expected. Instead, use a simple boolean value.
If you want to be more specific, you can also add language-specific settings:
{
"[javascript]": {
"github.copilot.enable": true,
"github.copilot.inlineSuggest.enable": false,
"github.copilot.editor.enableAutoCompletions": false
}
}
Shortcut Key Configuration
Since you’ve remapped ALT+\ to Tab for accepting suggestions, you’ll need to configure this in your VSCode keybindings.json file. Here’s how to set it up properly:
{
"key": "alt+\\",
"command": "github.copilot.generate",
"when": "editorTextFocus"
}
This configuration will trigger a Copilot suggestion when you press ALT+. If you want Tab to accept the suggestion when it appears, add this as well:
{
"key": "tab",
"command": "github.copilot.acceptNextSuggestion",
"when": "suggestWidgetVisible && copilotSuggestionsAvailable"
}
Pro tip: You can find all available Copilot commands by searching for “copilot” in the VSCode Command Palette (Ctrl+Shift+P).
Troubleshooting Steps
If your settings still aren’t working after applying the correct configuration, try these troubleshooting steps:
-
Verify JSON syntax: Ensure your settings.json file has valid JSON syntax. A syntax error could cause your settings to be ignored.
-
Check for workspace overrides: Your settings might be overridden by workspace-specific settings. Try setting these in your User settings instead of Workspace settings.
-
Reload VSCode completely: After making changes, close all VSCode windows and reopen it. Sometimes changes require a full restart.
-
Check for conflicting extensions: Other auto-completion extensions might interfere with Copilot. Try disabling other extensions temporarily.
-
Check Copilot authentication: Ensure Copilot is properly authenticated via GitHub. If authentication fails, Copilot might behave unpredictably.
-
Check for beta features: If you’re using beta versions of VSCode or Copilot, settings might differ from stable releases.
-
Reset Copilot settings: As a last resort, you can reset all Copilot settings to default and reconfigure them:
json{ "github.copilot.enable": true, "github.copilot.inlineSuggest.enable": false, "github.copilot.editor.enableAutoCompletions": false }
Alternative Approaches
If the standard settings approach doesn’t work for your setup, consider these alternatives:
-
Use Copilot in CLI mode: You can use Copilot through the command line for more control over when suggestions appear.
-
Create a custom command: Define a custom command to toggle Copilot completions on and off:
json{ "key": "ctrl+shift+c", "command": "github.copilot.toggleCopilot", "when": "editorTextFocus" }
-
Workspace-specific settings: If you only want to disable auto-completion for specific projects, create a .vscode/settings.json in your workspace directory.
-
Check for updates: Ensure you’re using the latest version of both VSCode and the Copilot extension, as bugs in older versions might cause this behavior.
-
Report the issue: If none of these solutions work, report the issue to the Copilot GitHub repository, as it might be a bug in the extension.
Conclusion
To summarize the key points for disabling auto-completion while keeping manual triggering:
- Use
"github.copilot.enable": true
to keep Copilot active - Set
"github.copilot.inlineSuggest.enable": false
to disable automatic inline suggestions - Configure
"github.copilot.editor.enableAutoCompletions": false
to disable editor integrations - Properly configure your shortcut key in keybindings.json for manual triggering
If you continue to experience issues, consider checking for conflicting extensions, updating your software, or reaching out to the Copilot support team. With these configurations, you should be able to enjoy the benefits of Copilot’s suggestions while maintaining full control over when they appear.