Important: The information in this document is obsolete and should not be used for new development.
When you edit a file in Xcode, you have the choice of using a standalone editor window or editing the file directly in any of the other Xcode windows, such as the project window, debugger window, build results window, and so forth. Regardless of your choice, Xcode uses a common interface for the editor. When you open a file in Xcode’s editor, you see a view similar to that in Figure 15-1.
Here’s what the Xcode editor contains:
Gutter. The gutter displays file line numbers, as well as information about the location of breakpoints, errors, or warnings in the file. See “Displaying the Editor Gutter” to learn more about the contents of the gutter, as well as how to show and hide the gutter.
Editor. The text editing pane displays the contents of the file.
Navigation bar. The bar along the top of the editor contains several menus and buttons that let you quickly see, and jump to, locations within the current file and in other files open in the editor. “The Navigation Bar” describes the contents of the navigation bar and how to use it to navigate source code files.
Note: You can also modify the attributes of the file reference associated with a file open in the editor, as described in “Inspecting File, Folder, and Framework References.”
Editing Files in a Separate Editor Window
Using the Attached Editor
Splitting Code Editors
If you prefer, you can use a dedicated window for editing source files in Xcode. Regardless of your preference for whether Xcode automatically opens the attached editor in Xcode windows, you can always open a file in a separate editor by doing any of the following:
Double-click the file in the Groups & Files list or the detail view in the project window.
Select the file and choose View > Open in Separate Editor.
Control-click the file and choose Open in Separate Editor from the contextual menu.
Figure 15-2 shows the Xcode editor in a separate window.
In addition to the basic editor interface, the standalone editor window also contains a toolbar and a status bar. The status bar is similar to the status bar of other Xcode windows, described in “The Project Window Status Bar.” Like the toolbar in other Xcode windows, the editor window toolbar provides easy access to common tasks. By default, it includes buttons to build, run, and debug the current target. It also contains the following two buttons:
The Project button lets you quickly jump to the file in the project window. Clicking this button brings the project window to the front.
The Grouped and Ungrouped buttons control whether opening a file, using any of the methods described above, opens a new standalone editor window for that file or opens the file in the current window. Clicking the button toggles the state. If the button is Grouped, indicated by the icon of a single window, double-clicking a file opens it in the current editor. If the button is Ungrouped, indicated by an icon of multiple layered windows, each file opens in a new editor window.
To preserve the state of any open editor windows when you close a project, choose Xcode > Preferences, click General, and select “Save window state” in the Environment options.
You can also edit your source files from within other Xcode windows, such as the project window and the debugger window. To open a file in the attached editor, make sure that the editor is visible in the window. If the editor is not already visible, you can open it by clicking the Editor button or choosing View > Zoom Editor In. This opens the attached editor to its maximum size. If the editor was already at its maximum size, clicking the Editor button or choosing View > Zoom Editor Out returns the attached editor pane to its previous size. To adjust the size of the attached editor to a different size, drag the separator to the size that you prefer.
Selecting a file, an error or warning, a bookmark, a find result or a project symbol opens the associated file in the editor as long as the editor is visible. You can also have Xcode automatically show the attached editor when you select one of these items in the detail view. To specify that Xcode automatically open the attached editor, select “Automatically open/close attached editor” in the Editing options in the General pane of the Xcode Preferences window.
Xcode allows you to simultaneously view multiple files or multiple sections of the same file without increasing the number of open windows. It does this by splitting a code editor. The figure seen here shows an editor that has been split to display two parts of the same file.
Note that you can split an editor whether that editor appears in a separate window or as an attached editor.
To split a code editor, make sure that the editor has focus and do one of the following:
To split the editor vertically, choose View > Split filename Vertically, or click the split button. The split button—identical to the split button in the Groups & Files list, described in “Splitting the Groups & Files View”—appears above the scrollbar of the editor window.
To split a code editor horizontally, hold down the Option key and choose View > Split filename Horizontally, or Option-click the split button.
To close a split, choose View > Close Split View, or press the Close Split button. You can resize the panes of a split editor by dragging the resize control between them.
Last updated: 2006-11-07