source.organizeImports, remove unused imports, don't remove unused imports
When i put "source.organize Imports" in "editor.codeActionsOnSave" it removes my unused imports. It would be interesting to have a parameter for it to just organize but not remove.
Many developers save their files all the time, often without even realizing it. This feature is very interesting but ends up "disturbing" who has this habit.
If you can pass a few more configuration parameters (like not removing unused imports or not removing space between imports) this feature would be better taken advantage of.
I would love this feature.
It really helps if we have a parameter to decide if we want vscode to remove or not the unused imports.
I have many problems when I am coding and then suddenly the import disappear.
The solution is: all the time I have to add the import again or I have to add another third party plugin to control my imports instead of using the vscode functionality.
馃殌
We definitively need an option to grey out unused imports vs removing them. Here鈥檚 my use case. When I temporarily disable code blocks, the related imports are removed if not used elsewhere in the code. When I re-enable them, the imports are gone and the code is broken.
@RyanCavanaugh, is there a fix for this aside from disabling source.organizeImports?
We definitively need an option to grey out unused imports vs removing them. Here鈥檚 my use case. When I temporarily disable code blocks, the related imports are removed if not used elsewhere in the code. When I re-enable them, the imports are gone and the code is broken.
It happens to me all the time... And worse, I have a habit of saving every line of writing, so I often import, save, write the code I'm going to use that import... This is terrible for me ... I have to "fight the IDE" to program the way I'm used to...
Just found this via https://github.com/microsoft/vscode/issues/89263 - also was just bitten by this:
editor.codeActionsOnSaveTwo suggestions here:
@karlhorky I am no longer using organize because of this. In fact I am using it manually sometimes, when I have finished all changes to the file.
It would be nice if there were two separate features, one to organize and one to remove.
I believe that it would answer many other cases, without implementing any "new behavior".
People who just want to remove unused imports and / or people who want to organize imports.
I will close this issue because the problem is with vscode and not with typescript.
Most helpful comment
It happens to me all the time... And worse, I have a habit of saving every line of writing, so I often import, save, write the code I'm going to use that import... This is terrible for me ... I have to "fight the IDE" to program the way I'm used to...