`

eclipse xml format

阅读更多

以前很喜欢在Eclipse中使用CTRL+ALT+F来进行自动排版.不过今天发现以后要绝对慎用这项功能,尤其是在xml和html中,尽量不要使用..因为今天发现,本来运行得很好的配置文件,只要一自动排版,就会报出一些莫名其妙的错误,而且这种错误是你检查配置检查不出来的,因为配置看起来根本就没变!!
猜测是由于在xml的entity中加了空格或者换行符的缘故.

 

 

 
有同感,在格式话的时候会加入空格,而很难检查出问题。
像数据库的连接地址,要保证中间没有空格,但格式化后会加入空格。导致数据库连接出错

 

 

eclipse  中的 code format 中的问题看来不只我一个人遇到,特别是在xml文件中format代码。

 

一般的解决办法有如下途径:

 

eclipse code format设置

eclipse code format设置

上面仅仅是针对Eclipse基本的Editor设置。对于Java/HTML/Ant等扩展编辑器,你还不得不单独去设定
      * Preference:
       1). For Java: sets java code style in eclipse
           windows->preferences->java->Code style->Formatter
           add a new profile , for more detail, test it in eclipse please
       2). For Ant: sets build.xml in eclipse
           windows->preferences->Ant>Editor->Formatter
           uncheck [Use tab character instead of spaces] option.
       3). For Html:
           windows->preferences->Web and XML->HTML Files->HTML Source
           select "Indent using tabs" and set space =2
       4). For XML:
           windows->preferences->Web and XML->XML Files->XML Source
           select "Indent using tabs" and set space =2
       5). For Properties
    3). 如何配置jsp,properties等文件默认使用UTF-8编码创建或者阅读?
     (Eclipse3.2+) Windows->General->Content Types下选择指定的扩展名,然后说明相应的编码,然后Update.
    4). 转换存在文件的回车换行格式

 

 

我在xml中遇到这种问题,我改到的地方只是在windows->preferences->myeclipse->files and editors->xml->xml source 下面的formatting栏中将line width 设置成172 ,默认是72.

我想,可能是因为line width 过小,导至在fomat时自动把xml 标签split掉,然后又加了一些多余的空格,因而改变了xml 实际内容。

分享到:
评论

相关推荐

    eclipse格式化format.xml文件

    打开eclipse>window>preferences>java>code style>formatter把改文件引进去就行了,可以格式化写的代码,让自己代码看起来规整

    eclipse-format-1.4.xml

    eclipse-format文件,对代码进行格式化

    eclipse intellij idea xml 自动格式化代码

    Settings->Editor->Code Style->XML 第二类:Eclipse使用: 1.在菜单栏中选中『windows』-〉 『Preferences』。 2.在出现的对话框的左边树中展开『Java』下的『code style』。 3.其中有两项,一项是『Formatter』,...

    android studio Eclipse Code Formatter配置文件xml下载

    androidstudio java代码eclipse风格的代码格式化配置文件。 1.插件安装:Androidstudio插件市场安装Adapter for Eclipse ...3.xml配置文件在附件中 4.默认快捷键 CTRL+ALT+L快速格式化代码,比如缩进、对齐、空格等

    eclipse-java-code-format.xml.zip_format

    eclipse 格式化,优秀的代码格式话文档那个;可共享下载与分享

    google-format.xml

    格式化 idea eclipse 格式化文件,用于格式化代码使用

    编码规范(三)之Eclipse formatter配置

    NULL 博文链接:https://xm-koma.iteye.com/blog/2103643

    eclipse注释替换已经编码格式调整

    使用注释模版: ...打开 Eclipse -> Window -> Preferences -> Java -> Code Style--> Formatter 右侧窗口有import按钮,点击import选择 format.xml文件打开,然后点击下方apply 再点击OK则已经使用模版

    codeformatter.xml

    代码规范 codeformatter.xml的模板。

    idea代码格式化模版

    idea 安装 Eclipse Formater 插件,选择CodeConvention_Eclipse.xml导入即可。

    华为项目标准代码模版。格式化【FormatterTemplates】

    华为项目标准代码模版。为个人项目开发提供标准的规范。

    codetemplates.xml

    Eclipse代码注释模板

    eclipse快捷键

    (4)Ctrl+Pg~对于XML文件是切换代码和图示窗口 (5)Ctrl+Alt+I看Java文件中变量的相关信息 (6)Ctrl+PgUp对于代码窗口是打开“Show List”下拉框,在此下拉框里显示有最近曾打开的文件 (7)Ctrl+/ 在代码窗口中...

    ECLIPSE快捷键大全

    ECLIPSE快捷键大全 (1)Ctrl+M------->切换窗口的大小 (2)Ctrl+Q------->跳到最后一次的编辑处 (3) Ctrl+1------->快速修复 (4) Ctrl+3------->快速查找想要的工具,和所有匹配的东西 (5) Ctrl+D------->删除当前行...

    JSP标准标签库(jstl)

    JSTL 1.0 发布于 2002 年 6 月,由四个定制标记库(core、format、xml 和 sql)和一对通用标记库验证器(ScriptFreeTLV 和 PermittedTaglibsTLV)组成。core 标记库提供了定制操作,通过限制了作用域的变量管理数据...

    jspFormat 格式化

    把庞大的tr,td们对对齐 格式化jsp,xml等 Eclipse插件

    eclipse-testng 离线包下载

    eclipse-testng 离线包<?xml version="1.0" encoding="UTF-8"?> xmlns:math="http://exslt.org/math" xmlns:testng="http://testng.org"> indent="yes" omit-xml-declaration="yes" doctype-public="-//...

    fmt-maven-plugin:有思想的Maven插件可格式化Java代码

    如果您希望IDE保持相同的格式,则按照上的安装说明,google-java-format还包括IntelliJ和Eclipse IDE的集成。 用法 标准pom.xml 要在每个构建中自动格式化源,请添加到pom.xml中: < groupId>...

    sense-app:Web应用程序找出最佳去处

    默认的Sun Java / Eclipse代码样式(可以在项目根目录eclipse-rgb-format.xml中找到eclipse的默认配置)。 如果您仅更改微小的内容,则仅重新格式化实际上已更改的内容。 否则,审查真的很难。 我们在所有文件...

    springmybatis

    2. Configuration.xml 里面 的<mapper resource="com/yihaomen/mybatis/model/User.xml"/>是包含要映射的类的xml配置文件。 3. 在User.xml 文件里面 主要是定义各种SQL 语句,以及这些语句的参数,以及要返回的类型...

Global site tag (gtag.js) - Google Analytics