“Sort Lines in Selection” for Xcode 4

前端 未结 5 1580
孤街浪徒
孤街浪徒 2021-02-01 20:09

I like Textmate\'s \"Sort Lines in Selection\" feature a lot. Is there something similar for Xcode 4? If not, what would be the best way to integrate such a feature (a plugin, A

5条回答
  •  醉酒成梦
    2021-02-01 21:01

    There's a bug on 10.7 and 10.8 where the shortcuts for Automator services don't always work until the services menu has been shown once from the menu bar. You can still select them from the context menu, but another option would be to assign a shortcut to a script like this:

    try
        set old to the clipboard as record
    end try
    try
        tell application "System Events" to keystroke "c" using command down
        do shell script "export LC_CTYPE=UTF-8; pbpaste | sort -fn | pbcopy"
        tell application "System Events" to keystroke "v" using command down
        delay 0.05
    end try
    try
        set the clipboard to old
    end try 
    

    Trying to get the clipboard when it's empty results in an error. pbpaste and pbcopy don't support Unicode by default in the environment used by do shell script.

提交回复
热议问题