javascriptimportvisual-studio-code

Organise imports for all files in project


VSCode includes a setting for organising imports, either via the action menu or automatically on every file save. Executing this command removes any unused imports and reorders imports alphabetically and grouped by package imports followed by local/relative imports.

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

Tutorial here.

Is there any way to apply this to all files in a project without opening and saving each file separately?


Solution

  • set

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

    and run search and replace "import"

    enter image description here