Eclipse 有线宽标记吗?
我有一个特定的项目,需要将每个代码行包装为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 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.
在 Eclipse Luna (4.4) 中:
选择菜单
Window\Preference
。 查看左上角,在搜索框中输入过滤文本
,输入:边距
。< br>
在
外观颜色选项
部分中,选择打印边距
。 选择显示打印边距
。 在文本框中打印边距列
中,输入您想要的65
。In Eclipse Luna (4.4):
Choose menu
Window\Preference
. Look at top-left corner, in search boxtype filter text
, type:margin
.In section
Apperance color option
, ChoosePrint margin
. ChooseShow print margin
. In text boxPrint margin column
, type65
as what you want.查看 Windows / 首选项(至少在 Windows - IIRC 上它会针对不同的操作系统移动),然后:
勾选此选项,它应该显示该行。
作为找到此内容的快速方法,请使用顶部的搜索过滤器并过滤“边距”。
评论中的注释 - 未经我验证,但我没有理由怀疑它们:
Look in Windows / Preferences (at least on Windows - IIRC it moves around for different operating systems) then:
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:
@Jon Skeet 的回答不完整。
(1/2) 首先,按照他说的做:
Window
-->首选项
-->常规
-->编辑器
-->文本编辑器
--> 选中显示打印边距
复选框,勾选此框将显示垂直线。
作为查找此内容的快速方法,请使用顶部的搜索过滤器并过滤“边距”。
但是,这仅显示行,但在大多数情况下,“打印边距列”值会被完全忽略。
设置行所在位置的列号,执行 @John Percival Hackworth 此处提到的操作:
(2/2) 转到:
Window
-->首选项
-->C/C++
[或您使用的任何语言] -->代码风格
-->格式化程序
--> 单击编辑
--> 在换行
选项卡下设置您想要的最大线宽
值。旁注:
如何在上面设置的列中强制强制换行(即:添加回车符)? 我还不知道。如果你弄清楚了请告诉我。 在 Sublime Text 3 中(一个更好的编辑器,但索引器/函数定义查找器更差:(),它是 Alt + Q。
更新:我认为使用
clang-format
的“CppStyle”插件,通过使用 Ctrl + Shift + F 是可能的 应用自动格式,但我还不知道使其工作的确切说明。相关:
@Jon Skeet's answer is incomplete.
(1/2) First, do what he said:
Window
-->Preferences
-->General
-->Editors
-->Text Editors
--> check the box forShow Print Margin
Ticking this box will show the vertical line.
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
--> clickEdit
--> under theLine Wrapping
tab set the value you desire forMaximum line width
.Side note:
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: