To prevent Visual Studio Code from automatically organizing or sorting our imports on save, we can disable the corresponding setting in the editor configuration. Here’s how we can do it:

  • Open Visual Studio Code.
  • Go to the “Settings” by either clicking on the gear icon in the bottom left corner and selecting “Settings” or by using the shortcut Ctrl + , (Cmd + , on Mac) to open the settings.
  • In the search bar at the top of the settings, type “editor.codeActionsOnSave”.
  • Look for the setting Editor: Code Actions On Save and click on “Edit in settings.json”
  • Add the following configuration to the settings.json file:
"editor.codeActionsOnSave": {
    "source.organizeImports": false
}
  • Save the settings.json file.

After making this change, Visual Studio Code should no longer automatically organize or sort our imports when we save the file.

By Shabazz

Software Engineer, MCSD, Web developer & Angular specialist

Leave a Reply

Your email address will not be published. Required fields are marked *