Gauchi
Gauchi

Reputation: 101

Xcode 4: Open arbitrary files in assistant editor

Is it possible to open a file that is not part of any project in the assistant editor? Open Quickly can open files in the assistant, but only searches the project itself. If I open an outside file in Xcode, it gets a new window that cannot access the project in its assistants.

Upvotes: 5

Views: 2657

Answers (5)

julz12
julz12

Reputation: 417

My preferred way to do this is to #include whatever file I want to open in some C file, like this:

#include "/home/julius/path/to/file"

Command-clicking the path will open the file. It's a shame Xcode forces you to use this workaround.

Upvotes: 0

David Ben Yosef
David Ben Yosef

Reputation: 21

Here is what I do (Xcode 9.3) :

  • Add wanted file to the Xcode project
  • Open assistant editor with that file
  • delete this file (references only) from the Xcode project. Xcode will remove the file from the assistant editor.
  • Now go to the assistant editor "recent files", the file will be there. Select it.

Upvotes: 1

Ray Perea
Ray Perea

Reputation: 5851

Yes, it's possible.

@What. Your answer only works if the file is in the project. You can only drag a file to the Jumplist at the top of the assistant editor if the file is displayed within the file list on the left. This means you would have to add the file to the project before opening. Sometimes, this is not desirable as you may want to open a file from another project for reference while coding.

Steps that I use are: (Tested in Xcode 6 and Xcode 7 Beta)

  1. In Xcode, make sure your Tab Bar is shown. If it is not, click on "View -> Show Tab Bar" in the top menu
  2. Open the file... Go to "File -> Open". Select the arbitrary file you want to open. This will open the file in a new window. (Screenshot 1 below)
  3. Drag the tab in the new window to the tab bar in your main editor. Now, you will have 2 tabs in your main editor and your new window will be gone (Screenshot 2 below)
  4. Next, click on your original tab (Where your main and assistant editor is) and the file will be available in the recent files list. Simply select the file from the recent files list in the assistant editor and you now have the file open in the assistant editor. You can also close the other tab as you no longer need it. (Screenshot 3 below)

Screenshot 1. Simply drag the tab from the new window to the main tab bar. Combine tabs

Screenshot 2, you will now have 2 tabs. 2 tabs

Screenshot 3. Back at your original tab, you now have the option to open the new file within the recent files list in the assistant editor. Click it and you are done. Recent Files List

Screenshot 4. Final result... we have our arbitrary file open in the assistant editor. Final Result

Upvotes: 3

whostolemyhat
whostolemyhat

Reputation: 3123

With the assistant editor open, drag the file from the left-hand list onto the Jumplist at the top of the assistant editor (where the currently open file is).

Upvotes: 9

Vidu
Vidu

Reputation: 7

You can drag an arbitrary file on the assistant editor. Then it will be opened there.

Upvotes: -1

Related Questions