Eclipse 有线宽标记吗?

发布于 2024-07-30 19:34:33 字数 240 浏览 2 评论 0原文

我有一个特定的项目,需要将每个代码行包装为 65 个字符。 我已经为此正确设置了 eclipse Java 代码格式化程序。 但我真正想要的是在编辑器中绘制一条垂直线,显示我打字时的最大线宽,而不仅仅是在运行格式化程序时。 我知道此功能在某些方面可用,因为它显示在代码格式化程序属性页中。

我在 Eclipse 中没有看到任何打开此功能的选项,并且在 Eclipse Plugin Central 上也没有看到任何可以执行此操作的插件

I have a specific project where I need to wrap every code line at 65 characters. I have set up the eclipse Java code formatter properly for this. But what I really want is a vertical line to be drawn in the editor showing where the max line width while I am typing, not just when I run the formmater. I know this feature is available in some capacity because it is displayed in the code formatter property page.

I don't see any option in eclipse to turn this on and I didn't see any plug-ins that do it on Eclipse Plugin Central

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

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

发布评论

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

评论(4

演出会有结束 2024-08-06 19:34:33

使用 Espressif 几个月后,以及插入其他品牌的 Eclipse 后,我找到了如何放大最大线宽。 我做了很多尝试并展示了如何使用 Espressif-IDE:

右键单击项目 -> 属性 -> C/C++ 常规 -> 格式化程序
->启用项目特定设置->
新建 -> 为您的配置文件命名并基于内置格式化程序:我选择 BSD/Allman -> 编辑此新配置文件 -> 在“换行”选项卡中键入,例如最大线宽为 200 -> 应用更改。

格式化源文件:您将看到很长的行。

在我从以下位置开始进行相同的操作之前:
窗口->首选项->C/C++->代码样式->格式化程序...:从来没有工作过。

After some months with Espressif, but also with other brands plugged-in Eclipse, I found how to enlarge maximum line width. I made a lot of attempts and show how to do for Espressif-IDE:

Right click a project->properties->C/C++ General->Formatter
->Enable Project specific settings->
New->Give your profile a name and base it on a built-in formatter: I choose BSD/Allman->Edit this new profile->within Line Wrapping tab type for example 200 for Maximum line width->Apply changes.

Format source files: you'll have long lines.

Before I did the same manouvres starting from:
Window->Preferences->C/C++->code Style->Formatter... : that never worked.

别理我 2024-08-06 19:34:33

在 Eclipse Luna (4.4) 中:
选择菜单 Window\Preference 。 查看左上角,在搜索框中输入过滤文本,输入:边距
< br>
在此处输入图像描述

外观颜色选项部分中,选择打印边距。 选择显示打印边距。 在文本框中 打印边距列 中,输入您想要的 65

In Eclipse Luna (4.4):
Choose menu Window\Preference . Look at top-left corner, in search box type filter text, type: margin.

enter image description here

In section Apperance color option, Choose Print margin. Choose Show print margin. In text box Print margin column , type 65 as what you want.

今天小雨转甜 2024-08-06 19:34:33

查看 Windows / 首选项(至少在 Windows - IIRC 上它会针对不同的操作系统移动),然后:

General -> Editors -> Text Editors -> Show Print Margin

勾选此选项,它应该显示该行。

作为找到此内容的快速方法,请使用顶部的搜索过滤器并过滤“边距”。

评论中的注释 - 未经我验证,但我没有理由怀疑它们:

它在 2016 年发生了某种变化:有关详细信息,请参阅[此处] ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=495490#c2) 您必须在格式化程序中设置它:从菜单 [Window]-->[Preferences],选择 [ Java]-->[代码风格]-->[格式化程序],然后编辑您的格式化程序配置文件。 在【换行】标签页中,您可以找到名为“最大线宽”的设置。 更改此设置,Java 源代码编辑器中的打印边距也会更改。

Look in Windows / Preferences (at least on Windows - IIRC it moves around for different operating systems) then:

General -> Editors -> Text Editors -> Show Print Margin

Tick this and it should show the line.

As a quick way of finding this, use the search filter in the top and filter on "margin".

Notes from the comments - unverified by me, but I have no reason to doubt them:

It has changed somehow in 2016: For details see [here] (https://bugs.eclipse.org/bugs/show_bug.cgi?id=495490#c2) You have to set it in the formatter: From menu [Window]-->[Preferences], select [Java]-->[Code Style]-->[Formatter], and then edit your formatter profile. In the tab page [Line wrapping], you can find a setting named "Maximum line width". Change this setting, and the print margin in Java source editor will be changed too.

兮颜 2024-08-06 19:34:33

@Jon Skeet 的回答不完整。

(1/2) 首先,按照他说的做:

Window --> 首选项 --> 常规 --> 编辑器 --> 文本编辑器 --> 选中显示打印边距复选框,

勾选此框将显示垂直线。

输入图片此处描述

作为查找此内容的快速方法,请使用顶部的搜索过滤器并过滤“边距”。

但是,这仅显示行,但在大多数情况下,“打印边距列”值会被完全忽略。


设置行所在位置的列号,执行 @John Percival Hackworth 此处提到的操作:

(2/2) 转到:

Window --> 首选项 --> C/C++ [或您使用的任何语言] --> 代码风格 --> 格式化程序 --> 单击编辑 --> 在换行选项卡下设置您想要的最大线宽值。

输入图片此处说明

旁注:

  1. 使用 Alt + Shift + Y 打开和关闭软换行。 但是,它将在屏幕末尾进行软换行(即:无回车),而不是在您上面设置的列处。

如何在上面设置的列中强制强制换行(即:添加回车符)? 我还不知道。如果你弄清楚了请告诉我。 在 Sublime Text 3 中(一个更好的编辑器,但索引器/函数定义查找器更差:(),它是 Alt + Q

更新:我认为使用 clang-format 的“CppStyle”插件,通过使用 Ctrl + Shift + F 是可能的 应用自动格式,但我还不知道使其工作的确切说明。

相关:

  1. 设置选项卡宽度:在 eclipse 3.5 中更改编辑器选项卡宽度

@Jon Skeet's answer is incomplete.

(1/2) First, do what he said:

Window --> Preferences --> General --> Editors --> Text Editors --> check the box for Show Print Margin

Ticking this box will show the vertical line.

enter image description here

As a quick way of finding this, use the search filter in the top and filter on "margin".

However, this only shows the line, but under most situations the "Print margin column" value there is flat-out ignored.


To set the column number for where the line should be, do what @John Percival Hackworth mentions here:

(2/2) Go to:

Window --> Preferences --> C/C++ [or whatever language you are using] --> Code Style --> Formatter --> click Edit --> under the Line Wrapping tab set the value you desire for Maximum line width.

enter image description here

Side note:

  1. Use Alt + Shift + Y to toggle soft line wrapping on and off. It will soft wrap (ie: no carriage return) at the end of the screen, however, not at the column you set above.

How do you enforce hard line wrapping at the column you set above (ie: that adds a carriage return)? I don't know yet. If you figure it out let me know. In Sublime Text 3 (a much better editor but with a much worse indexer/function definition finder :() it's Alt + Q.

Update: I think it may be possible with the "CppStyle" plugin, which uses clang-format, by using Ctrl + Shift + F to apply the auto-format, but I don't know the exact instructions to make it work yet.

Related:

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