如何禁用VS Code中按下"."键触发的自动补全功能?
Got it, I totally get how frustrating it is when pressing "." automatically completes a suggestion instead of just showing the list—especially when you're trying to type React.Component and it jumps to a completion before you're ready. Here's how to fix this:
1. Disable Global Auto-Completion on Commit Characters
The main culprit is VS Code's default setting that lets certain characters (like ".") auto-accept suggestions. Here's how to turn it off:
- Open VS Code Settings: Press
Ctrl+,(Windows/Linux) orCmd+,(Mac), or go to File > Preferences > Settings. - In the search bar, type
editor.acceptSuggestionOnCommitCharacter. - Uncheck the box next to this setting. This will prevent any commit character (including ".") from automatically accepting the top suggestion.
2. (Optional) Apply Only to React/JSX Files
If you don't want to disable this globally and only want it for React files, you can set this per language:
- In the Settings search bar, type
[javascriptreact](for JSX) or[typescriptreact](for TSX). - Click on Edit in settings.json for the language-specific section.
- Add this line inside the curly braces:
Your settings will look something like this:"editor.acceptSuggestionOnCommitCharacter": false"[javascriptreact]": { "editor.acceptSuggestionOnCommitCharacter": false }
3. Verify the Fix
After changing the setting, go back to your React file:
- Type
Reactand you'll see the suggestion list pop up. - Press "." now—it won't auto-complete the top suggestion; instead, it will just add the "." and show the list of properties/methods (like
Component) for you to select with Tab or Enter.
This should resolve the issue without needing to switch to alternative extensions. The setting targets VS Code's core IntelliSense behavior, which is what's causing the auto-completion on ".".
内容的提问来源于stack exchange,提问作者Marko Antonić

