Visual Assist has a plethora of features, and it’s difficult to know them all. It’s an even greater challenge to use all of them at every opportunity.
We had one user, Tom, write recently that his “very small favourite feature” in Visual Assist is Sort Lines. Sort lines, we wondered. We don’t often sort when writing code. After a bit of thought, we acknowledged that if one does need to sort, however infrequently, a built-in sort can be very handy.
In this blog post, I touch on a few use cases for Sort Lines, some of which might resonate with you.
If you have enums not dependent on order, consider sorting them for readability. Sort all or a subset, remembering to exclude a count that must be the last item.
Select your lines and invoke sort from the Tools submenu of VAssistX:
Sorting is always alphabetic, and done in place. Only complete lines of a selection are sorted; sort Lines ignores the line with the text caret—whether or not the line includes any selected text.
In unmanaged code, #defines are sometimes good candidates for a sort. If circumstances allow, sort before assigning values to your macros. Sorting operates at the line level, so don’t attempt a sort if your macros and their comments span multiple lines.
Finally, if you are confident your C/C++ headers don’t need to be included in order, sort them so they are easier to browse.
If you find yourself sorting manually, however infrequently, remember that Visual Assist makes the task simple. Our user Tom uses Sort Lines so much he assigned a shortcut to the command.
Finally, if you have a different use case for Sort Lines, we’d love to hear about it. Please share your case in a comment.
You must log in to post a comment.