eclipse的默认代码风格

由于eclipse的默认代码风格很不实用,本文针对性的给出一些个性化设置。 
    统一代码风格,是方便项目管理,为整个团队建立良好的环境,减少阅读成本;所有的强大的团队协作,都是点滴积累的。 
    本文以eclipse3.6.2_javaee为例,其他版本是否兼容,暂不清楚. 
1.【window】/【preferences】/【Java】/【code style】/【formatter】/【edit】 

2.面板【indentation】 
tab policy = spaces only 
indentation size = 4 
tab size = 4 
他的作用是只适用空格缩进,不使用table,这样可以去除不同平台下的txt识别问题 

选中align fields in columns 
他的作用是对其类中定义的属性 

3 面板【line wrapping】 
maximum line width = 400 
他的作用是不让代码自动换行 

【method declarations】/【Parameters】 
line wrapping policy = wrap all elements, exception first element if not necessary 
选中 force split, even if line shorter than maxmum width 
indentation policy = indent on column 
这的作用是在方法声明的时候,一个参数一行,尤其是spring mvc里一个方法十几个参数的时候,看着非常爽 

4 面板【comments】 
去掉 Enable line comment formatting 
他的含义是去掉单行注释的格式化 

猜你喜欢

转载自yinger-fei.iteye.com/blog/1498038