关闭所选代码区的Eclipse格式化程序? [英] Turn off Eclipse formatter for selected code area?

查看:132
本文介绍了关闭所选代码区的Eclipse格式化程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我 ctrl + 移动 + f 的项目代码,它的工作就好了,无处不在。

When I ctrl+shift+f up the project code, its doing its job just fine, everywhere.

但是它搞乱了CSS,特别是那些过滤器部件,并添加了一些空格。

But its messing the CSS, specially those filter parts and adding bunch of spaces.

另外我如何指定一些Java部分

Also how do I specify some portion of Java code to not be formated by that command ?

推荐答案

为了防止Java代码的特定部分被格式化,请转到窗口>首选项> Java> Code Style> Formatter。点击编辑...按钮,进入关/开标签选项卡并启用标签。之后,您可以将这些标签简单地嵌入到Java代码中,以禁止它们之间的格式化。如果您不更改默认标签,则可以执行以下操作:

To prevent specific portions of Java code from being formatted, go to "Window > Preferences > Java > Code Style > Formatter". Click the "Edit..." button, go to the "Off/On Tags" tab and enable the tags. Afterwards, you can simply embed those tags in Java code to disable the formatting in-between them. If you don't change the default tags, something like this will do :

//@formatter:off
this.
    portion.of(code
); // will not be touched by the formatter
//@formatter:on
but this will be
       reformatted.

IIRC,此选项仅适用于Eclipse 3.6。

IIRC, this option only exists since Eclipse 3.6.

对于css代码,如果您已安装Eclipse WTP,请转到窗口>首选项> Web> CSS文件>编辑器,您将在那里找到一些基本的格式化选项。

As for css code, if you have installed Eclipse WTP, go to "Window > Preferences > Web > CSS Files > Editor" and you will find some basic formatting options there.

这篇关于关闭所选代码区的Eclipse格式化程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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