Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 775
Undistraction Avatar asked May 03 '19 13:05

Undistraction


People also ask

How do I organize imports in entire project in Eclipse?

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.

How do you organize imports or codes?

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.


1 Answers

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.

like image 87
ontimond Avatar answered Oct 09 '22 20:10

ontimond