Code Monkey home page Code Monkey logo

ide-style's Introduction

Eclipse | Formatter & CodeTemplates 格式化和代码注释

团队里面最好能统一风格,这样在看别人代码的时候就比较清晰。

CodeTemplates

写注释比不写好
注释的格式其实也有模板的

  • 没有用注释模板 image

  • 使用注释模板 image

/** */ 一般用在Method上面
// 单行注册用在代码的上面, 也有人用在代码的后面,但是个人不建议

Formatter

关于代码格式化目前只碰到大括号是否独立一行的情况
一下格式化是以大括号独立一行为标准

  • 格式化前 image

  • 格式化后 image

格式化后代码阅读起来比较清晰

Eclipse 配置Formatter

在Eclipse工具栏选择 Preferences -> Java -> Code Style -> Formatter

image

  • 选择 Edit... 或者 ‘New...’

image

Indentation 缩进

我个人习惯将Tab policy 选择为 Spaces only,因为可以保证在不同的IDE中代码的兼容性比较好
在使用Tab的时候实际上是空了4格

Brace positions 配置大括号

  • Same line 在同一行
  • Next line 换行(大括号独立一行)
  • Next line indented 换行并缩进
  • Next line on wrap 不知道

其他的配置没有研究过,有兴趣可以自己去研究
或者参考玩转Eclipse — 自动代码规范化 - CSDN博客

或者直接导入我的Formatter 模板

Eclipse 配置CodeTemplate

在Eclipse工具栏选择 Preferences -> Java -> Code Style -> Code Templates

Comments 中 配置各个类型的注释格式

选中类型后选择Edit...开始编辑 image Insert Variable... 可以选择各种参数

配置好后使用方式是在method上 输入/** + 回车 就会显示配置的注释

也可以下载我的CodeTemplate 模板导入
如果使用我的模板请将@author 改成你自己的名字

ide-style's People

Contributors

lixhbs avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.