Eclipse Formatter允许多行; [英] Eclipse Formatter Allow Multi Line ;

查看:58
本文介绍了Eclipse Formatter允许多行;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Eclipse格式化程序配置为允许我尽可能多地做一个衬板.但是有时候我想要在同一行上的相关命令,例如

I have the Eclipse formatter configured to allow me to do one liners as much as possible. However sometimes I want related commands on the same line such as

temp.add;temp.flush(); ⇦问题

我还配置了格式化程序以允许我的if语句看起来像这样

Also I configured the formatter to allow my if statements to look like this

if(true)return;

但是如果我有多个命令,它将把它向下推到下一行,但是我希望它像这样格式化 if(true){n ++;return;} ⇦问题

But if I have multiple commands it will push it down to the next line but I want it to format like this if(true) {n++; return;} ⇦Problem

它的格式如下

if(true) {
n++;
return;
}

是否有设置可以保留这些多行命令,但仍设置间距和所有内容的格式?由于我讨厌在多行上执行一个逻辑步骤,所以我故意尽可能多地使用三元运算符.如果没有办法配置它或使用插件来解决这个问题,我想我将关闭格式化程序.我知道我只能使用ctrl + shift + f,但是每次运行程序时我都喜欢格式化它.

Is there a setting to retain these multi line commands but still format the spacing and everything? It gets to the point that I purposely use ternary operators as much as possible because I hate doing one logical step on multiple lines. If there is no way to configure this or a plugin to fix this I think I am going to just turn the formatter off. I know I can just use ctrl+shift+f but I enjoy it formatting every time I run my program.

推荐答案

您可以使用 off/on 标签来避免在编辑器的某些区域中进行格式化.如果您使用的是Eclipse 3.6及更高版本.

You can use off/on tags to avoid formatting in certain regions of editor. if you are using eclipse version 3.6 onwards.

这篇文章解释了如何执行此操作

This post explains how to do this How to turn off the Eclipse code formatter for certain sections of Java code?

这篇关于Eclipse Formatter允许多行;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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