Xcode - 如何并排查看两个文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46553129/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:28:11  来源:igfitidea点击:

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

xcodeeclipse

提问by stackoverflowuser2010

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

我是一名经验丰富的 Eclipse 用户,正在转向 Xcode(我现在有 9 版)。

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?

在 Xcode 中,如何垂直并排查看两个源代码文件(即左侧一个文件,右侧另一个文件)?在 Eclipse 中,要获得拆分视图窗口,只需将一个选项卡从左向右拖动即可。我如何在 Xcode 中执行此操作?

Here is what I mean in Eclipse:

这是我在 Eclipse 中的意思:

Eclipse IDE with side-by-side files

带有并排文件的 Eclipse IDE

回答by Tamás Sengel

In Xcode, you should use the Assistantfor this.

在 Xcode 中,您应该为此使用助手

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

Xcode 11 及更高版本(感谢更新,@Uthen!

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

单击编辑器右上角的Add Editor on Right按钮:

Add Editor on Right button

在右侧按钮上添加编辑器

To add an editor to the bottominstead, hold down the Optionkey while pressing the button, it will change to Add Editor Below:

要将编辑器添加到底部,请在按下按钮的同时按住Option键,它将更改为“在下方添加编辑器”

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

Xcode 10 及更早版本

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 Manualto 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 Editorand change the view. Here, you can also add and remove new assistant editorsif display more than two files at the same time.

如果要将布局更改为水平/垂直,请导航到“视图/助手编辑器”并更改视图。在这里,如果同时显示两个以上的文件,您还可以添加和删​​除新的助理编辑器

View/Assistant Editor

查看/助理编辑

回答by SafeFastExpressive

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!

一个更简单的方法是在 Xcode 项目视图中选择单击您想要的文件,它将在助手编辑器位置打开(通常在当前文件的右侧)。不再用助手中可怕的导航菜单进行繁琐的搜索!