Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode - How to view two files side-by-side?

Tags:

xcode

eclipse

I'm an experienced Eclipse user and am moving over to Xcode (I have version 9 right now).

In Xcode, how do I view two source code files side-by-side vertically (i.e. one file on the left, and another on the right)? In Eclipse, to get a split view window, it's a simple matter of dragging one tab from the left to the right. How do I do this in Xcode?

Here is what I mean in Eclipse:

Eclipse IDE with side-by-side files

like image 808
stackoverflowuser2010 Avatar asked Oct 03 '17 20:10

stackoverflowuser2010


People also ask

How do I open two windows side by side in Xcode?

Option + Shift + Click on the file in the project navigator. In the popup that appears, the leftmost choice is "Open in a new window".

How do I open a new window in Xcode?

Open in a new editor as another new windowUpon open the little popup, click on to the + of a tilted little window on the left and press ↩. A new window will appear outside the Xcode.

What is assistant editor in Xcode?

The Assistant Editor in Xcode is a second editor that automatically displays files that Xcode determines are most helpful to you based on the work you are performing in the primary editor. It's been used a lot in the Objective-C days where MyClass. h would be opened while editing MyClass. m.


2 Answers

Xcode 11 and above (thanks for the update, @Uthen!)

Click on the Add Editor on Right button in the top right corner of the editor:

Add Editor on Right button

To add an editor to the bottom instead, hold down the Option key while pressing the button, it will change to Add Editor Below:

Add Editor Below button

If you want to choose a different file to show, navigate to a different file using the folder buttons above the editor:

Folder buttons


Xcode 10 and earlier

Simply click on the button in the top right corner with two overlapping circles to access it or navigate to View/Assistant Editor/Show Assistant editor (⌥⌘^↩).

Assistant editor button

If you want to choose a different file to show, click on the button right to the navigation arrows in the right side of the screen and select an option from the context menu. Choose Manual to pick any file you want.

Button right to the navigation arrows

Context menu for picking the file being shown

If you want to change the layout to horizontal/vertical, navigate to View/Assistant Editor and change the view. Here, you can also add and remove new assistant editors if display more than two files at the same time.

View/Assistant Editor

like image 92
Tamás Sengel Avatar answered Oct 02 '22 16:10

Tamás Sengel


A much easier method is to option-click the file you want in the Xcode project view, and it will open in the assistant editor position (typically to the right of the current file). No more tedious searching around with the horrible navigation menu in the assistant!

like image 39
SafeFastExpressive Avatar answered Oct 02 '22 17:10

SafeFastExpressive