是否可以为每个项目(甚至每个文件)在 Xcode 中设置缩进设置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3216426/
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-14 19:31:47  来源:igfitidea点击:

Is it possible to set indent settings in Xcode per project (or per file, even)?

xcodetabsindentation

提问by Michael Chinen

Some projects I work in uses tab key settings that equate to 3 or 4 spaces and another wants actual tabs. Another mixes the two depending on directory.

我工作的一些项目使用等于 3 或 4 个空格的制表键设置,而另一个需要实际的制表符。另一种根据目录将两者混合。

Is there some way to set these settings per project, or even better, per file? If not, does someone have a clever way of dealing with this? (besides "just remember which setting you should use and change it before you start editing")

有没有办法为每个项目设置这些设置,甚至更好,每个文件?如果没有,有人有聪明的方法来处理这个问题吗?(除了“请记住您应该使用哪个设置并在开始编辑之前更改它”)

采纳答案by Steven Kramer

Update: This answer only applies to Xcode3. For newer versions, see James Turner's answer.

更新:此答案仅适用于 Xcode3。对于较新的版本,请参阅 James Turner 的回答。

Yes, go to View > Text > Tab Settings...

是的,转到查看 > 文本 > 选项卡设置...

There you specify the (file-specific) indentation settings which will be saved in the project.

在那里指定将保存在项目中的(特定于文件的)缩进设置。

回答by James Turner

This seems to have changed with Xcode 4 ... if you click on a file, group or project, amongst the items in the Utilities bar (at the right-hand side, by default) is 'Text Settings'.

这似乎在 Xcode 4 中发生了变化……如果您单击文件、组或项目,实用工具栏中的项目(默认情况下位于右侧)是“文本设置”。

回答by Alex Gray

The accepted answer is no longer correct.. as of Xcode 5.1.. which forces you now to Edit "per file" indentation settings via..

接受的答案不再正确.. 从 Xcode 5.1 开始.. 这迫使您现在通过.. 编辑“每个文件”的缩进设置。

enter image description here

在此处输入图片说明

?

?

enter image description here

在此处输入图片说明

回答by Scott Gardner

You can set indentation per file, group, project, or for all new projects, and for all but per file indentation, new source code files will inherit the indentation settings of the closest parent.

您可以为每个文件、组、项目或所有新项目设置缩进,对于除每个文件之外的所有项目,新源代码文件将继承最近父项的缩进设置。

To set indentation per file, select the file in the Project Navigator, and set indentation in the File Inspector ? Text Settings.

要为每个文件设置缩进,请在项目导航器中选择文件,然后在文件检查器中设置缩进文字设置

Xcode indentation per file

每个文件的 Xcode 缩进

To set indentation per group, select the group in the Project Navigator, and set indentation in the File Inspector ? Text Settings.

要为每个设置缩进,请在项目导航器中选择该组,然后在文件检查器中设置缩进文字设置

enter image description here

在此处输入图片说明

To set indentation per project, select the project in the Project Navigator, and set indentation in the File Inspector ? Text Settings.

要为每个项目设置缩进,请在项目导航器中选择项目,然后在文件检查器中设置缩进文字设置

enter image description here

在此处输入图片说明

To set default indentation for new projects, select Xcode ? Preferences... ? Text Editing ? Indentation:

要为新项目设置默认缩进,请选择Xcode ? 喜好... ?文字编辑 ? 缩进

enter image description here

在此处输入图片说明

回答by BVP

Actually Alex Gray and James Turner are the most correct - XCode 5.1 allows you to modify the tab/indent from the File Inspector as you mention, but simply highlight the entire project and it will apply to everything within it (i.e. all files).

实际上,Alex Gray 和 James Turner 是最正确的——XCode 5.1 允许您按照您提到的方式从文件检查器中修改制表符/缩进,但只需突出显示整个项目,它将应用于其中的所有内容(即所有文件)。

回答by cajjed

As of 8.3 you can still select project in the navigator and then change the tab/space indent option in the inspector. Worth mentioning though is that it will only change files in folders that have been added with "Create groups" selected instead of "Create folder references" which is the default.

从 8.3 开始,您仍然可以在导航器中选择项目,然后在检查器中更改制表符/空格缩进选项。值得一提的是,它只会更改已添加的文件夹中的文件,这些文件夹已选择“创建组”,而不是“创建文件夹引用”,这是默认设置。