我的常用Eclipse Coding Style设置

本文详细介绍了如何在Eclipse中进行编码风格的设置,包括文本文件编码方式、插入空格代替制表符、显示打印边距及行号等。此外还讲解了XML文件编辑器、Java代码格式化配置等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用Eclipse的时候通常对coding style有一定的要求,通常最主要的就是Java和xml文件中tab和空格,Java格式的一些约定俗成的东西,把自己的常用设置保存在github上面,留个备份:Workspace设置


Windows->Preferences->General->Workspace

  • text file encoding: UTF-8
  • New text file line delimiter: Unix

Windows->Preferences->General->Editors->Text Editors

  • select insert spaces for tabs
  • select Show print margin (update pring margin column to 150)
  • select Show line numbers
  • select Show whitespace characters

Windows->Preferences->XML->XML Files->Editor

For insert whitespace before closing empty end-tags, select Indent using psaces, change size to 4

Windows->Preferences->Java->Code Style->Formatter

  • click New, input profile name
  • click edit, change Tab policy to Space only, set Indentation/tab size to 4

Windows->Preferences->Java->Editor->Save Actions

  • select Perform the selected actions on save
  • select Format source code Format edited lines for old projects and Format al lines for new projects
  • select Addional actions, click configure
  • In Code Organizing
    • select Remove trailing whitespace
    • select correct indentation
  • In Code Style
    • select blocks in if/while/for/do with Always except for single return or throw
    • select convert 'for' loops to enhanced
    • select use parentheses in expressions
    • select use modifier 'final' where possible
    • select convert funtional interface instances with use lambda where possible
  • In Member Accesses:
    • select user 'this' qualifier for field accesses
    • select user 'this' qualifier for method accesses
    • select qualify field access and qualify method access
  • In Unnecessary Code
    • select Remove unused imports
    • select Remove unused private members
    • Remove unused local variables

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值