Stop Visual Studio Code From Automatically Adding Semicolons In .vue Files

Viewed 41684

I use Visual Studio Code with Vetur extension, when I right click on my .vue file and chose "Format Document" option Visual Studio Code automatically add the semicolons that intentionally removed them.

How do I stop this?

11 Answers

Put this in your user settings and it won't change your semis:

"vetur.format.defaultFormatter.js": "vscode-typescript",

Forget the earlier answer, gives me runtime issues.

Install Prettier- code formatter extension and disable the addition of semi colons by unchecking the Prettier:Semi as in the screenshot below

Note : Dont forget to reload your vs code after you install the extension and before u do the config changes

enter image description here

Adding .prettierrc file in project root worked for me with following settings:

{
  "semi": false,
  "singleQuote": true
}

Changing prettier settings in VSCode Workspace did not work in my case.

  1. go to settings

enter image description here

  1. Go to Text Editor's Settings enter image description here

    "javascript.format.semicolons": "remove",
    "typescript.format.semicolons": "remove",
    "typescriptHero.imports.insertSemicolons": false, 
    "typescript.preferences.quoteStyle": "single",
    "javascript.preferences.quoteStyle": "single",   
    
  2. Editor enter image description here

YouTube Video

You can add in your VSCode settings.json

"vetur.format.defaultFormatterOptions": {
    "prettier": {
        "semi": false
    }
},

May be, you have different extensions installed where the usage of semicolons (;) is defined. Try to go to VSCode settings and search for "semicolon". All settings regarding the usage of semicolon will be shown and you can configure it as you like.

This is what worked for me:

"typescript.format.semicolons": "remove"

Add this line to your custom settings in VSCode (helps with js files):

"autoimport.useSemiColon": false

setting organizedimports to false worked for me

"editor.codeActionsOnSave": {
"source.organizeImports": false
},

Easiest fix is go to "Settings" in vs code, Search for ";"

In the search result that follows, remove ";" as demonstrated in the below screenshots.

Before the change: Before the change

After the change: After the change

Related