在 eclipse 3.5 中更改编辑器选项卡宽度

发布于 2024-08-09 16:14:53 字数 124 浏览 3 评论 0原文

我正在尝试从 Window -> 调整选项卡的宽度首选项->一般->编辑->文本编辑器,其中有一个“显示选项卡宽度”字段。但无论我输入什么,当我在 Java 文件中开始换行时,缩进的大小都是 4。有什么想法吗?

I am trying to adjust the width of tabs from Window -> Preferences -> General -> Editors -> Text Editors where there is a field for "Display Tab Width". But no matter what I enter there the size of indentations when I start a newline in a Java file is 4. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

岛徒 2024-08-16 16:14:53

Java 文件有一个特殊的位置可以编辑此设置。您需要转到

Window ->;首选项-> Java->代码风格-> Formatter

并编辑配置文件。

Java files have a special place to edit this setting. You need to go to

Window -> Preferences -> Java -> Code Style -> Formatter

And edit the profile.

椒妓 2024-08-16 16:14:53

更改窗口 ->首选项->一般->编辑->文本编辑器选项卡首选项与文本文件相关,而不是与此处所示的 java 文件相关。您可以在 Eclipse 中创建一个文本文件并检查制表符大小是否确实更改。

Changing Window -> Preferences -> General -> Editors -> Text Editors tab preference is relevant for text files, not for java files as indicated here. You may create a text file in Eclipse and check that your tab size is really changed.

何时共饮酒 2024-08-16 16:14:53

检查您的 Java->Code Style->Formatter 设置,看看您是否使用制表符或空格;您可能正在使用空格!

Check your Java->Code Style->Formatter settings, to see whether you're using tabs or spaces; you might be using spaces!

寂寞笑我太脆弱 2024-08-16 16:14:53

对于 Java,此设置由代码样式格式化程序中的设置取代。

它可以在Java/代码样式/格式化程序(单击编辑)/缩进选项卡/缩进中找到

This setting is superseded for Java by the setting from the Code Style Formatter.

It can be found in Java / Code Style / Formatter (click Edit) / Indentation tab / Indentation

留一抹残留的笑 2024-08-16 16:14:53

如何在 Eclipse 或 Eclipse CDT 中设置制表符大小(按 Tab 时的空格数):

有多个地方需要检查和要做的事情:

  1. 全局首选项:
  2. 窗口 -->偏好设置 -->一般-->编辑们-->文本编辑器 -->将“显示的选项卡宽度”从 4 更改为 2
  3. 窗口 -->偏好设置 --> Java 或 C/C++ [取决于您使用的] -->代码风格 -->格式化程序 -->单击“活动个人资料”的“编辑”按钮 -->单击左上角的“缩进”选项卡 -->将“缩进大小”更改为 2,将“制表符大小”更改为 2,将“制表符策略”更改为“仅空格”。
  4. 项目首选项(这些会覆盖给定项目的全局设置):
  5. 项目 -->属性(或者只需右键单击左侧文件夹列表中的项目,然后转到“属性”--> Java 或“C/C++ General”[取决于您所使用的] -->格式化程序 -->取消选中“启用项目特定设置”框,或者选中该框并确保您的设置正确(请参阅上面的 1.2,从单击“编辑”按钮步骤开始,但从这里开始这次的菜单)。
  6. 要测试您的新设置:返回到编辑器并按 Enter,光标紧位于左花括号 ({) 后面。它应该转到一个新行,并带有您在上面设置的正确缩进。
  7. 注意:小心!如果您在缩进与上面设置不同的行上或之后按 Enter,它将复制错误的缩进(通过复制上面行的样式),而不是接受新的缩进设置。不要认为它在这种情况下不起作用!它正在工作!只需删除所有旧的缩进,然后在 { 之后按 Enter,您就会发现一切正常。

经过测试的版本: 全部在面向 C/C++ 开发人员的 Eclipse IDE 中进行了测试,版本:Oxygen.3a Release (4.7.3a)。

重复或相关的问题和问题答案:

  1. Google 搜索“Eclipse 更改选项卡大小” - https://www.google.com/search?q=eclipse+change+tab+size&oq=eclipse+change +&aqs=chrome.0.69i59l3j0l3.2483j0j4&sourceid=chrome&ie=UTF-8
  2. https://superuser.com/questions/462221/how-do-i-reliously-change-the-indentation-width-in-eclipse
  3. Eclipse 选项卡宽度不变

另相关

  1. 设置线宽竖线标记/打印边距 - 有 Eclipse 线宽标记吗?

How to set tab size (number of spaces when you press Tab) in Eclipse or Eclipse CDT:

There are multiple places to check and things to do:

  1. Global Preferences:
  2. Window --> Preferences --> General --> Editors --> Text Editors --> change "Displayed tab width" from 4 to 2
  3. Window --> Preferences --> Java OR C/C++ [depending on which you're using] --> Code Style --> Formatter --> click "Edit" button for your "Active profile" --> click "Indentation" tab on top-left --> change "Indentation size" to 2, "Tab size" to 2, and "Tab policy" to "Spaces only".
  4. Project Preferences (these override the global settings for a given project):
  5. Project --> Properties (or just right-click on project in the folder list at the left, and go to "Properties") --> Java OR "C/C++ General" [depending on what you're using] --> Formatter --> either uncheck the box for "Enable project specific settings", OR check that box and ensure your settings are correct (refer to 1.2 above, beginning with the click "Edit" button step, but do it from this menu this time).
  6. To test your new settings: return to your editor and press Enter with the cursor sitting immediately after an opening curly brace ({) somewhere. It should go to a new line with the proper indentation you've set above.
  7. NB: watch out! If you press Enter on or after a line with different indentation from what you've set above, it will duplicate that wrong indentation (by copying the style of the lines just above) rather than accepting your new indentation settings. Do NOT think it isn't working in this case! It IS working! Just delete all of the old indentation and press Enter right after a { and you'll see everything works just fine.

Version tested: All tested in Eclipse IDE for C/C++ Developers, Version: Oxygen.3a Release (4.7.3a).

Duplicate or Related Questions & Answers:

  1. Google search for "Eclipse change tab size" - https://www.google.com/search?q=eclipse+change+tab+size&oq=eclipse+change+&aqs=chrome.0.69i59l3j0l3.2483j0j4&sourceid=chrome&ie=UTF-8
  2. https://superuser.com/questions/462221/how-do-i-reliably-change-the-indentation-width-in-eclipse
  3. Eclipse tab width not changing

Also Related

  1. Set line width vertical bar marker / print margin - Is there an Eclipse line-width marker?
梦年海沫深 2024-08-16 16:14:53

在更深入地研究这个问题之后,我想我已经弄清楚了:

Java file tab DISPLAY width

令人困惑的是,这是在首选项中的“Formatter”下(就像接受的答案所说的那样)。但这与非 java 文件编辑器的选项卡显示宽度选项所在的位置不一致。

<代码>/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.formatter.indentation.size=16

文本文件选项卡显示宽度

/instance/org.eclipse.ui.editors/tabWidth=2


我强调DISPLAY,因为这只是为了在Eclipse 中渲染。它不会更改文件的内容,并且对“源 -> 格式”没有影响。

After digging into this more deeply, I think I've figured this out:

Java file tab DISPLAY width

Confusingly, this is under "Formatter" in preferences (like the accepted answer says). But this is inconsistent location-wise with where the option for tab display width for the non-java file Editor is located.

/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.formatter.indentation.size=16

Text file tab DISPLAY width

/instance/org.eclipse.ui.editors/tabWidth=2


I emphasize DISPLAY because this is just for rendering in Eclipse. It does not change the contents of your file, and has no effect on "Source -> Format".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文