Favorite Xcode Tips and Tricks

I just came across a fantastic blog post by @detroitLabs regarding Xcode tips and tricks. I learned a few great ones, which I’ve listed below, but I wanted to add my own contribution that I’ve learned recently.

If you want to view git diffs of any file in Xcode, you can tap the button shown below. I had not realized this existed until recently!

This is useful for two things

  1. Viewing any git changes from any branch for any file within the Xcode IDE.Previously, I was always going to the commit diff viewer for my current changes, or to the command line and using Apple’s “FileMerge” program to see previous changes against other commits, but that was always a PITA to find the correct files, etc. (yes, I know about external, visual git applications)
  2. But it’s especially useful if I want to look at the text of the .pbxproj file within the IDE. I hadn’t found a way to simply display that within Xcode, and could only look at the visual interface:

But, by showing the diff, the underlying text is revealed, which is sometimes useful!

My favorites from the original post (numbered according to original post):

1) Moving a selection of a line or multiples lines of code up or down using: ⌘ ⌥ { to move up and ⌘ ⌥ } to move down. If you have text selected, Xcode will move each line containing your selection; otherwise, it’ll move the line the cursor is in.

SOoooo nifty
4) Open the file in the Assistant Editor. When using “Open Quickly” (⌘ ⇧ O), hold while also hitting return.

Genius!! esp. after a lot of messy refactoring
10) Auto-indent code by hitting ⌘ A, ^ I

Confession Time: I didn’t know you could open more than 1 assistant editor!!
12) Hitting ⌥ ⇧ then clicking on a file in the Project navigator opens a selection box to allow you to choose where to open a file.

More nifty!
13) Hold and click a file in the Project Navigator and it opens the file in the Assistant Editor.

I had only known to use ⌘ 0 or ⌘ ⌥ 0 to reveal the panes –>
14) Think of the Navigator pane (which shows up on the left side of the Xcode window) as the “Command” pane. That’s because holding and pressing a number opens the corresponding “tab” within that pane. For instance, ⌘ 1 opens the Project Navigator. ⌘ 7 opens the Breakpoint Navigator. Similarly, think of the Utilities Panes as the “Command Option” pane. ⌘ ⌥ 1 opens the first tab in that pane, the File Inspector.

Bonus) Someone added a link in the comments to a fascinating tip. Hold down while selecting, and only the text within the selection rectangle is copied. Just make sure cursor is not over a word when you press the  key, or else it will try to give you option to look up definition of word. Not a tip you need a lot, but if, for example, you want to select out the right-hind-side of a series of assignments, you can do that in one shot.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s