tweekmonster / impsort.vim

Sort and highlight Python imports in Vim
MIT License
37 stars 6 forks source link

Wrong sorting #18

Closed heliomeiralins closed 7 years ago

heliomeiralins commented 7 years ago

So, I was testing impsort today for the first time and I opened a random django file with the imports:

from django import forms
from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm
from django.utils.translation import ugettext_lazy as _

After :ImpSort or :ImpSort! we get:

from django import forms
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm

After :!isort % we get back to the original.

tweekmonster commented 7 years ago

This is the default sort method which prioritizes module length and depth before alphabetic sorting. I prefer sorting and grouping that favors my ability to discern shapes vs my ability to mentally alphabetize (which I'm terrible at doing quickly).

You can customize this to make alphabetic sorting the priority. Check the section Sort customization under :h impsort-config. I think you could set all of the sorting options to ['alpha', 'length'] to get it to sort like isort.

heliomeiralins commented 7 years ago

Thanks.