Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode Ctrl + S

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.

like image 819
user3661407 Avatar asked Jul 14 '17 10:07

user3661407


4 Answers

Try disable extensions for auto-formatting javascript code. Sometimes Beautify, JS-CSS-HTML Formatter can mess things up.

Maybe auto-formatting is on in settings as well. Check File > Preferences > Settings and look at the "User settings"-tab. Look if "editor.formatOnSave" is set to 'true', change that to 'false' in that case.

Hope that helps. If not, please send a list of your activated extensions.

like image 159
Tuxedo Joe Avatar answered Sep 30 '22 19:09

Tuxedo Joe


You disable it "Format On Save"

  1. Press Ctrl + <
  2. Search "Format On Save" It's must be disabled. It's must be disabled
like image 30
Denys Denylson Avatar answered Sep 30 '22 20:09

Denys Denylson


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
like image 26
Sam Avatar answered Sep 30 '22 19:09

Sam


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

like image 29
Bonnie Nyambura Avatar answered Sep 30 '22 21:09

Bonnie Nyambura