Java Net Beans 中的自动换行

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

Word Wrap in Net Beans

javaidenetbeansjavabeans

提问by

Netbeans is great but there's no way to wrap text in it (or hopefully I haven't found it yet). Is there any way to do this, and if not, is there any similarly good IDE for Java with this functionality (hopefully free as well).

Netbeans 很棒,但是没有办法在其中包装文本(或者希望我还没有找到它)。有没有办法做到这一点,如果没有,是否有任何类似的具有此功能的 Java IDE(希望也是免费的)。

回答by

Except Eclipse does not support word wrap either, and they even don't have set up a target for this. Just like Netbeans, this has been asked by many users, but was never included. It appears it requires much change, and as well does not seem to be a high priority for devs. There was once a beginning of a plugin trying to word wrap in a limited way, but of course it does not work on recent versions.

除了 Eclipse 也不支持自动换行,他们甚至没有为此设置目标。就像 Netbeans 一样,很多用户都问过这个问题,但从未包括在内。看起来它需要很多改变,而且似乎也不是开发人员的优先考虑事项。曾经有一个插件试图以有限的方式自动换行,但当然它不适用于最近的版本。

回答by

There's word-wrap eclipse plugin: see http://ahtik.com/blog/eclipse-word-wrap/

有 word-wrap eclipse 插件:见http://ahtik.com/blog/eclipse-word-wrap/

回答by Joseph Burley

When you get to where you want the line to end, just start a new line without ending the statement. It may underline it in red until you end the statement, but it won't cause any exceptions.

当您到达您希望该行结束的位置时,只需开始一个新行而不结束该语句。它可能会用红色下划线直到您结束该语句,但它不会导致任何异常。

I find that it is also a good way to organize long println() statements.

我发现这也是组织长 println() 语句的好方法。

回答by Jeroen van Bergen

Like Joseph said: why would you need this. Java is not white space sensitive and having very long statements does not make your code easy to read.

就像约瑟夫说的:你为什么需要这个。Java 对空格不敏感,并且很长的语句不会使您的代码易于阅读。

回答by Sarel Botha

Get a bigger monitor.

买个更大的显示器。

At 1920 x 1080 you don't need no steenkin word-wrap.

在 1920 x 1080 分辨率下,您不需要 steenkin 自动换行。

Update:Wow, still getting downvotes. Maybe it's just how I said it. At least it hasn't caught up to the Eclipse answer yet.

更新:哇,仍然得到downvotes。也许这就是我所说的。至少它还没有赶上 Eclipse 的答案。

I really thought this was a legitimate suggestion. I never thought that having a bigger monitor would make as much of a difference to coding as it has for me. If you're using a small monitor to code please consider getting a nice big new one. It does eliminate the need for word wrap in a lot of cases.

我真的认为这是一个合理的建议。我从没想过拥有一个更大的显示器会对我的编码产生如此大的影响。如果您正在使用小型显示器进行编码,请考虑购买一台新的大型显示器。在很多情况下,它确实消除了自动换行的需要。

回答by Sarel Botha

It always goes back to Ultraedit.

它总是回到 Ultraedit。

Why can't we as a human race figure this out? netbeans, eclipse, zend studio (eclipse), etc don't do something very simple for programming, that most programmers -need to have- to keep a sound coding convention. Sure, it's true that coding style contributes to length of lines (erm microsoft programmers, perk your ears), but sometimes one cannot avoid long string literals. This is insanity! And yet I can't be mad or ungrateful because it's open source. And i -am- grateful. Still, one has to wonder wtf programmers who make these editors are actually using themselves.

为什么我们人类不能解决这个问题?netbeans、eclipse、zend studio (eclipse) 等不会为编程做一些非常简单的事情,大多数程序员 - 需要 - 保持良好的编码约定。当然,编码风格确实会影响行的长度(嗯,微软程序员,振作起来),但有时无法避免长字符串文字。这是疯狂!但我不能生气或忘恩负义,因为它是开源的。我 - 很 - 感激。尽管如此,人们不得不怀疑制作这些编辑器的 wtf 程序员实际上是在使用自己。

I want an editor to wrap at column 80 or 120, not at the window's edge like notepad++. The only tool I've found that does hard/soft wrapping is ultraedit, so maybe I should try to see if I can get it to run under wine, since UE is the only 'real' editor that does it's job other than something weird / ugly / takes forever to learn and configure like emacs. And I am not going down that road- it gives me migranes to look at it because it's 2009 and we have cleartext and guis.

我希望编辑器在第 80 或 120 列换行,而不是像记事本 ++ 那样在窗口边缘换行。我发现做硬/软包装的唯一工具是 Ultraedit,所以也许我应该尝试看看我是否可以让它在 wine 下运行,因为 UE 是唯一一个“真正的”编辑器,除了一些奇怪的东西之外,它还能完成它的工作/ 丑 / 像 emacs 一样需要永远学习和配置。而且我不会走那条路 - 它让我看它偏头痛,因为它是 2009 年,我们有明文和 guis。

Is it really that difficult a problem to solve? If you draw a line down from column x and your word crosses over it, then put the beginning of the word under the indention of the line from which it started and mark the spill over row as a wrap row. Done.

问题真的有那么难解决吗?如果您从 x 列向下画一条线并且您的单词越过它,则将单词的开头放在它开始的行的缩进下,并将溢出行标记为换行行。完毕。

回答by Darrell

Komodo Edit. In addition to its many other marvelous features, it actually wraps lines.

科莫多编辑。除了许多其他奇妙的功能外,它实际上还可以包裹线条。

回答by domi

2 points:

2分:

  • Just found that wrapping is really needed if one wants to look into those damn SVG sources auto-generated when putting components from SVG palette...

  • I'm going to solve my current problem with seeing full SVG source by copy-paste to jEdit which is as configurable as Ultraedit (in the aspect of wrapping) and FoC!

  • 刚刚发现,如果想要查看从 SVG 调色板放置组件时自动生成的那些该死的 SVG 源,则确实需要包装...

  • 我将解决我当前的问题,通过复制粘贴到 jEdit 来查看完整的 SVG 源,jEdit 与 Ultraedit(在包装方面)和 FoC 一样可配置!

回答by webdev

If you do web development you are going to understand why text wrapping is important.

如果您从事 Web 开发,您将了解为什么文本换行很重要。

A programmer who has never gotten their hands dirty with HTML has never seen the real web. You can insist on MVC all you want to but 99.9% of the world wide web since its inception wasn't built that way. Unless you're always developing from a clean slate and can use MVC to separate the HTML out AND assuming you have an on-staff web designer who does html/css/javascript or you have an interface developer who you can fob it off on you WILL have to deal with everything that has been developed/kludged/hacked together with what ever technologies were at hand or popular or affordable at the time and now more or less functions as a 'web application'. And 99.9% of the time what you will have to work with is a mix of some kind of a programming language, most likely an interpreted one, with html and javascript all mixed in the same page.

一个从未接触过 HTML 的程序员从未见过真正的网络。您可以随心所欲地坚持使用 MVC,但 99.9% 的万维网自成立以来都不是以这种方式构建的。除非你总是从头开始开发,并且可以使用 MVC 将 HTML 分离出来,并且假设你有一个负责 html/css/javascript 的在职网页设计师,或者你有一个界面开发人员,你可以把它关在你身上将不得不处理所有已经开发/混合/黑客攻击的所有技术,以及当时手头或流行或负担得起的技术,现在或多或少地充当“网络应用程序”。在 99.9% 的情况下,您必须使用某种编程语言的混合,很可能是解释型语言,html 和 javascript 都混合在同一页面中。

And this means no nice short lines of neat clean java code that oh so conveniently end before 80 characters.

这意味着没有简洁干净的 Java 代码的短行,那么方便地在 80 个字符之前结束。

And when you deal with this -- which, dear hearts, is most of the web -- you magically discover the crying need for text wrapping to keep the long lines from making you scroll waaaay to the right to get to the end of it.

当你处理这个——亲爱的心,这是网络的大部分内容时——你神奇地发现了对文本换行的迫切需求,以防止长行让你向右滚动 waaaay 到达它的结尾。

Some people. Sheesh. They think the whole universe of development has always fit on 80 characters per line, and from some of these comments, they seem to think it always will.

有些人。嘘。他们认为整个开发领域总是每行 80 个字符,并且从其中一些评论中,他们似乎认为总是如此。

回答by CoCoMo

Actually i heard netbeans is going to add word wrap feature in 6.7 release but then they decided to include this feature in 7.0 . hopefully we would see word wrap in the next release, according to few developers this isn't a necessary feature but for web developers this is totally needed.

实际上,我听说 netbeans 将在 6.7 版本中添加自动换行功能,但后来他们决定在 7.0 中包含此功能。希望我们会在下一个版本中看到自动换行,据少数开发人员称,这不是必需的功能,但对于 Web 开发人员来说,这是完全需要的。