Eclipse:自动换行到指定宽度 [英] Eclipse: Automatic line wrapping to specified width
问题描述
我希望我的线条,特别是在评论中,被自动管理,所以他们不会太长。
I'd like for my lines, especially within comments, to be automatically managed so they don't get too long.
我记得一旦我有一个 vim
的配置,它会自动将我打字的单词移动到下一行一次我达到了72个字符如果我编辑它,那么这个段落是不够聪明的,但这是一个开始。
I remember once I had a configuration for vim
which automatically moved the word I was typing to the next line once I reached 72 characters. It wasn't smart enough to rearrange the paragraph if I edit it, but it was a start.
有没有什么可以管理我的?我有一个倾向,在我的代码中写出很长的评论,它有助于使它们看起来整洁,因为宽度一致,但总是很痛苦,因为经常编辑一个句子需要编辑段落的其余部分。
Is there something that can manage these for me? I have a tendency to write really long comments in my code, and it helps to make them look neat by having consistent width, but it's always a pain to do this because oftentimes editing a sentence requires editing the entire rest of the paragraph.
我刚刚发现了 Ctrl + Shift + F 功能。这是惊人的,优于 Ctrl + 我这是我直到现在使用的,但我注意到,它没有做任何事情来清理我的意见。
I have just recently discovered the Ctrl+Shift+F feature. It is amazing and superior to Ctrl+I which is what I was using up till now, but I noticed that it does not do anything to clean up my comments.
更新:在Eclipse中使用Java时,答案是正确的。看来我必须等待CDT来整合这个功能。
Update: The answers are correct when working with Java in Eclipse. It seems like I have to wait for the CDT to incorporate this feature.
推荐答案
在Windows - >首选项中,转到Java - >代码样式 - >格式化当您单击 Ctrl + Shift + F 时调用。在注释标签中,您可以设置注释的最大行宽度(可以与代码的行宽度不同)。
In "Windows -> Preferences", go to "Java -> Code style -> Formatter" to customize the formatter (called when you click Ctrl+Shift+F). In the tab "comment", you can set the maximum line width for comments (it can be different then the line width for code).
提示:在首选项中, Java - >编辑器 - >保存操作,您可以使Eclipse在保存文件时自动格式化文件,因此您的代码始终正确缩进!
Tip: in the preferences, "Java -> Editor -> Save actions", you can make Eclipse to automatically format your file when you save it, so your code is always correctly indented !
这篇关于Eclipse:自动换行到指定宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!