Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode: Sort imports vs. Organize Imports

When I enter option + shift + o on my Mac in a Python file in VSCode, I am given two options - "Sort imports" and "Organize Imports". They both organize the inputs nicely but in a different way, so I can keep flipping back and forth between the two of them. Why are there two different commands for this and is one preferred (i.e. more PEP8 compliant) than the other?

like image 450
jss367 Avatar asked Feb 03 '26 20:02

jss367


1 Answers

There are two because the Python extension created the Sort Imports command before VS Code introduced the Organize Imports command. So the Sort Imports command is the more "official" one for now.

There is an open issue, though, to transition over to Organize Imports at some point. Feel free to 👍 the issue if you would like to help bump its priority.

like image 199
Brett Cannon Avatar answered Feb 06 '26 09:02

Brett Cannon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!