Home > Net >  How to change autocompletes in VS Code?
How to change autocompletes in VS Code?

Time:10-06

Whenever I have a form, and I want to create an object or something, I use document.getElementById('example').value. Thing is, the first time I type 'value' in a new JS file and then enter my comma or semicolon, 'value' changes to ariaValueMax. I know this is a minor inconvenience at worst, but is there any way I can change this? This happens everytime I make a project with JavaScript.

Also, when I'm in my server.js file, sometimes I forget to create a variable before trying to do something with it in express. So if I type something like this:

const express = require('express');
app.listen.....

I end up with this:

const express = require('express');
const { appendFile } = require('fs');

appendFile.listen......

Is there any way I can change this settings as well? (the one where it auto creates the require('fs') line)

CodePudding user response:

I can only answer your first question: You have to edit settings.json to tell Intellisense to not accept autocomplete on your "commit character" (in this instance, the semicolon). So first, you have to edit that file:

  • Windows %APPDATA%\Code\User\settings.json
  • MacOS $HOME/Library/Application Support/Code/User/settings.json
  • Linux $HOME/.config/Code/User/settings.json

Then, add the following JSON node:

"editor.acceptSuggestionOnCommitCharacter": false

Finally, restart your editor, and it should be good to go. Here is an example of my settings.json file:

{
    "go.formatTool": "goimports",
    "editor.acceptSuggestionOnCommitCharacter": false
}
  • Related