Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What you’re wanting to do can be achieved through Xcode’s “User Scripts”—and it helpfully comes with a pair of scripts that almost do what you want. (I’m using Xcode 3.2 here, but I think these were also there in 3.1)</p> <p>Look in <code>/Developer/Library/Xcode/User Scripts/</code>; there are two applescripts there, <code>Move Line Up.scpt</code> and <code>Move Line Down.scpt</code>. Here’s what’s in <code>Move Line Up</code>:</p> <pre><code>(* To edit this script, choose Save As... and save it in your home directory, then re-add it to the User Scripts list. *) using terms from application "Xcode" tell first text document set {startLine, endLine} to selected paragraph range if startLine &gt; 1 then set theText to (paragraphs startLine through endLine) set theText to (theText as string) delete (paragraphs startLine through endLine) make new paragraph at beginning of paragraph (startLine - 1) with data theText set selected paragraph range to {startLine - 1, endLine - 1} else beep 1 end if end tell end using terms from </code></pre> <p>These almost do what you want, except they select the whole line afterwards; I’m no applescript expert, but you probably want to store the <code>selected character range</code>. Have a look at the Xcode scripting dictionary (in AppleScript Editor, File -> Open Dictionary -> Xcode) to find out the types of objects you can manipulate.</p> <p>You can add your own scripts to Xcode with the “Edit User Scripts”menu item in the script menu; and assign shortcut keys to the scripts in that window also, by double-clicking in the right-hand column beside the entry for the script menu item.</p> <p>You can also use shell scripts (perl, python, bash, whatever) in the User Scripts menu, but these process only the selection or the whole file, so might be a bit heavyweight for moving a single line up or down.</p> <p>See all the docuemntation on User Scripts here: <a href="http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/XcodeWorkspace/310-User_Scrips/user_scripts.html" rel="noreferrer">http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/XcodeWorkspace/310-User_Scrips/user_scripts.html</a></p> <p>I hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload