rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

`remove all unused imports` should remove all unused imports of the file.

Open oriongonza opened this issue 1 year ago • 3 comments

Currently it only removes all unused imports of the current use item and we have no way of doing it for the entire file.

oriongonza avatar Aug 13 '24 14:08 oriongonza

If you select all the use items (or the whole file), I think the assist will work on all of them. Agree that it should maybe do that by default.

flodiebold avatar Aug 14 '24 07:08 flodiebold

I haven't figured out how to do that in neovim

oriongonza avatar Aug 14 '24 09:08 oriongonza

I haven't figured out how to do that in neovim

I think that you can do that with the visual mode

ShoyuVanilla avatar Aug 16 '24 06:08 ShoyuVanilla

in VS Code there is no way to select all unused?

Removing all unused for a single line saves a well-caffeinated developer maybe hundredths of a second, removing all unused for the file saves seconds.

evbo avatar Jan 27 '25 17:01 evbo

@evbo you can select the whole file (or just the uses), then trigger the assist. You don't have to go through each of them.

lnicola avatar Jan 30 '25 07:01 lnicola

@lnicola thanks and the only reason I don't currently do this is for some reason it also can remove more than what is unused (underlined by the yellow squiggly):

https://github.com/rust-lang/rust-analyzer/issues/18941

evbo avatar Feb 08 '25 17:02 evbo