'VS Code is replacing text
Whenever I try to type console.log
, the moment I press the full stop, VS Code replaces that text with crossOriginIsolated
. The only way for me to actually type console.log
is to type .log
then type console
in front of it. I like having the suggestions but when I press full stop it just replaces whatever text I'm trying to type.
Solution 1:[1]
Place this in your 'settings.json' file :
"editor.acceptSuggestionOnCommitCharacter": false,
To open the 'settings.json' file:
- cmd + , or ctrl + ,
- List item
- scroll down until you see 'Files: Associations'
- Click on 'edit in settings.json' paste the code above and save.
Besides that, you can type log
and press Enter. It will autocomplete console.log
Solution 2:[2]
This happens when you make a very specific typo while attempting to write console.log
. Specifically, if you type consold or consolt. The D and T keys are both near the E key, so it's a plausible mistake to make.
The reason this occurs is that, when you type a non-existent symbol in vscode, it will attempt to auto-correct it by matching your with a real symbol that has all of those letters in that same order. This is a helpful rule often, especially for correcting missing-letter typos. For instance, "cosole" would autocorrect to "console" using this rule. There is exactly one valid JS symbol which has the letters c-o-n-s-o-l-d in that order and it's crossOriginIsolated:
There is unfortunately no way to disable just this one autocorrect suggestion by itself, but if you really feel you can't tolerate it, there is a more targeted solution than disabling autocorrect entirely. You can suppress this behavior by disabling autocorrect for variables only:
In my opinion, losing variable autocorrect is too great a price to pay to correct this behavior, so personally I've decided to just live with it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Avetik Nersisyan |
Solution 2 | Matt Korostoff |