I have a .py file with lots of classes:
class First(Second):
#code
class Third(Fourth):
#code
Is it possible to sort the definitions by class name in vim?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Suggestion for manual sorting.
With a reasonable amount of classes, manual sorting is not so tedious. I also propose it since I think it makes much more sense to group superclasses together and make sure superclasses are defined before subclasses — otherwise your module won’t even be importable.
Enable folding in Vim:
you can open a fold with zo, close with zc. Close all in the document with zM, open all in the document with zR.
Close all folds in the document. Now each class spans only two lines, and it’s easy to delete and reinsert in its proper place.