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?
For Eclipse Helios, open the "Project Explorer" view, clic right on your src folder, go under the source menu, and clic "organize imports" that should work for all your project. or just hit the combination Ctrl + Shift + O on the src folder.
In VSCode, go to File -> Preferences -> Settings and click on the icon in the top right hand corner to open up the settings in JSON. Et voilà! Your imports will now be organized every time you save a file.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With