![mac text edit alphabetize mac text edit alphabetize](https://help.apple.com/assets/615275A338285545FE1AA968/615275A438285545FE1AA96F/en_US/c377bae4ed5de72c56b1cbb86ef11adb.png)
The OSX System Preferences > Keyboard > Keyboard Shortcuts preferences pane lets you assign keyboard shortcuts to menu items. The final step is to assign it to a keyboard shortcut. Keyboard PowerĬreating a Service menu item is one step closer to adding custom text manipulations that aren't available by default in applications like Xcode. ⌘S to save the Service and name it something like "Sort Lines."Īfter saving the Sort Lines service it becomes available via the Services menu whenever you have text selected, or by right-clicking any piece of selected text.You can use sort -f | uniq to get rid of duplicate lines which is useful for things like #import statements.
![mac text edit alphabetize mac text edit alphabetize](https://www.ultraedit.com/assets/images/powertips/ue/sort-1.png)
![mac text edit alphabetize mac text edit alphabetize](https://www.addictivetips.com/app/uploads/2011/08/EditText.jpg)
Check the Output replaces selected text option.Here's how you add a Sort Lines service (originally from epatel on Stack Overflow). Automator lets you define services that are available to other applications from the Services menu in the menu bar and context menu. The above technique is pretty quick, but it could be quicker, especially if we could make it a single action. Something I regularly do is sort header #import statements, property names, forward-declarations, etc…so not being able to quickly sort lines is kind of irritating. Many text-editors have built-in commands to sort lines of text, however Xcode doesn't. These steps will copy the selected text to the clipboard, run it through the sort command, then copy it back to your clipboard. Here's a simple workflow to quickly sort lines of text: