从线包裹中止日食? [英] Stop eclipse from line wrapping?

查看:150
本文介绍了从线包裹中止日食?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让eclipse停止擦除现有换行符?如果我有一个这样的方法签名,我不知道如何让eclipse离开它:

  void foo (
int arg1,
int arg2,
int arg3,
int arg4)
{
// ...
}

使用各种设置,它将会将参数折叠到一行,或者以如下方式将其包围:

  void foo(
int arg1,int arg2,
int arg3,int arg4)
{
// ...
}

使用包装所有元素,新线上的每一个元素它都保留了这个空格,但它总是包装,这不是我想要的。我希望eclipse应用缩进和大括号的格式,只要不删除(或插入)任何换行符。

解决方案

p>参数的格式化是一个旧主题,但是3.5中引入了一种新的格式化功能是:





现在,Java代码格式化程序现在可以通过不加入代码或注释中的行来选择保留用户换行符。



例如,以下测试用例中的return语句的包装行:





格式化代码示例



将当使用从不加入行首选项时,格式化程序保留,现在生成以下结果:





编码格式化为从不加入行



首选项可以在 Java>代码样式>格式化器首选项。请参阅不要在线条包裹评论之间加入行选项>标签。



这可能有所帮助,但是否则3.5的这个方面没有太多的新功能。


Is there a way to get eclipse to stop erasing existing line breaks? If I have a method signature like this, I can't figure out how to get eclipse to leave it alone:

void foo(
    int arg1,
    int arg2,
    int arg3,
    int arg4)
{
    // ...
}

With various settings it will either collapse the arguments down to one line, or wrap them at some margin like this:

void foo(
    int arg1, int arg2,
    int arg3, int arg4)
{
    // ...
}

With "Wrap all elements, every element on a new line" it does preserve this whitespace, but it will ALWAYS wrap, which isn't what I want. I'd like eclipse to apply formatting for indentation and braces and such, just without ever deleting (or inserting) any line breaks.

解决方案

The formatting of arguments is an old subject, but the one new formatting feature introduced in 3.5 is:

  • eclipse3.5M4 "Formatter option to preserve user line breaks"

The Java code formatter can now optionally preserve user line breaks by not joining lines in code or comments.

For example, the wrapped lines of the return statement in following test case:


Example of Code to Format

will be preserved by the formatter when the "Never Join Lines" preference is used, and now produces the following result:


Coded Formatted with Never Join Lines

This preference can be configured on the Java > Code Style > Formatter preference page. See the Never join lines option on the Line Wrapping and Comments tab.

That may help, but otherwise there is not much new features on that front in 3.5.

这篇关于从线包裹中止日食?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆