VSCode Ctrl + S

Viewed 28656

I am working on a React project using a Visual Studio Code. When I press Ctrl+S in the Visual Studio Code to save file, it removes all the JavaScript formatting or scatters all the code in the file.

Any help would be appreciated.

7 Answers

You disable it "Format On Save"

  1. Press Ctrl + <
  2. Search "Format On Save" It's must be disabled. It's must be disabled

To expand on Tuxedo Joe's answer, your issue might be with your formatter extension:

Check if "Format On Save" is disabled

  1. Press Ctrl + <
  2. Search "Format On Save". Set to disabled.

Disable formatting on save in formatter.json:

  1. Press F1
  2. Enter "Formatter Config"
  3. In formatter.json set "onSave" to false
  4. Save formatter.json
  5. Restart VSCode

select language mode by clicking on your bottom right hand from javascript/html to react

First of all, check whether 'Format on Safe' is enabled or not.

  • Cntrl + < , (or File > Preferences > Settings)
  • Search 'Format on Safe',
  • Disable 'Format on Safe'.

If you've got it disabled, check the format text. It's probably that you've got javascript or html format. Change it to 'react' or 'javascript react' format.

  • 'Select Language Mode',
  • Search 'react',
  • Select 'react', 'javascript react' or 'typescript react'.

In my case it was due to enabled Default HTML formatter:

Push Ctrl + >, then Extentions > HTML:

Screenshot: enter image description here

Related