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?

1 Answers

2
Community On Best Solutions

I think there is an extension that resembles what you're looking for

https://marketplace.visualstudio.com/items?itemName=bierner.folder-source-actions

You just have to organize the imports from the root folder as explained on the extension page.