码迷,mamicode.com
首页 > 系统相关 > 详细

Eclipse用4个空格代替tab

时间:2015-02-12 14:13:57      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:eclipse   tab   space   

Java代码规范中提到,tab其实是占8个字符,因此我们可以使用4个空格(4个字符)来代替tab,这样既减少了代码的存储大小,也提供了一种美观的代码。

技术分享

因此修改Eclipse的编码格式有助于我们不用改变我们的习惯而达到替换。

具体步骤如下:

  1. 编辑时,对tab的替换。Windows -> Preferences -> General -> Editors -> Text Editors,勾选上Insert spaces for tabs.

    技术分享

  2. 使用Ctrl + Shift + F格式化代码时,对tab的替换。Windows -> Preferences -> Java -> Code Style -> Formmater -> Active profile 选择一个格式化风格,然后点击Edit。在Indentation选项卡中,找到General settings,在Tab policy中选择Spaces Only。

    技术分享


    如果选择后出现下面的情况,返回Active profile,然后点击new一个profile,名字随意输入。然后选择新建的profile,再做上述操作即可。

    技术分享

本文出自 “SG-YYZ” 博客,请务必保留此出处http://sgyyz.blog.51cto.com/5069360/1613955

Eclipse用4个空格代替tab

标签:eclipse   tab   space   

原文地址:http://sgyyz.blog.51cto.com/5069360/1613955

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!