eclipse基本设置----中文乱码、行数显示、缩进方式、行末空格和空行自动删除、常用注解

一、中文乱码

  window系统下,Eclipse中导入新的项目的时候,可能会遇到中文乱码的问题。

  解决方案:将系统默认的格式为GBK改成UTF-8。以下是具体解决方法,可以根据需要选择不同的方法。

1、设置整个工作空间的编码,此操作会影响整个工作空间的项目。

  设置步骤:菜单栏window --  Preferences -- General -- Workspace --Text file encoding--Other --UTF-8,保存配置(Apply and Close)。

  

2、设置项目的编码,此操作只影响被选中项目。

  设置步骤:选中项目右键 -- Properties -- Resource --Text file encoding--Other --UTF-8,保存设置。

  

3、设置单个文件的编码,此操作只影响被选中文件。

  设置步骤:选中文件右键 -- Properties -- Resource --Text file encoding--Other --UTF-8,保存设置。

  

二、eclipse中显示代码行数、空格(space)和制表符(tab)

  未设置前:

  

  设置步骤: 菜单栏Window -- Preferences -- Gerenal -- Editors -- Text Editors,保存设置。

  (显示行数也可以直接用Ctrl+F10, 然后勾选Show Line Numbers)

  

  设置后:

  

  

三、设置缩进方式(一个tab为四个空格)

  设置步骤:

   1)、设置缩进:菜单栏Window -- Preferences -- Gerenal -- Editors -- Text Editors--Insert spaces for tabs,保存设置;

  

   2)、将tab为4个空格配置到formatter中:

    i)、菜单栏Window -- Preferences -- Java -- Code Style -- Formatter;

    

    ii)、新建一个文件,配置如下所示,保存;

    

    iii)、Source -- Format,进行格式化。

四、保存时自动删除行末空格以及空行(现象是左图到右图)

        

  设置步骤:Window -- Preferences -- Java -- Editor -- Save Action -- Perform the ... -- Additional actions -- Configure... -- Remove trailing whitespace -- All lines

  

    

五、常用注解

  设置步骤:菜单栏Window -- Preferences -- Java -- Code Style --Code Templates -- Comments 

  1、Files -- Edit 

  /**   
  * @Description: 
  * @Package ${package_name} 
  * @Title: ${file_name}
  * @author sucb
  * @date ${date}
  */
Files

  

  

  2 、Types -- Edit 

/**@Description: 
 * @Package ${package_name} 
 * @Title: ${file_name}
 * @author sucb
 * @date ${date}
 */
Types

    

  3、Methods -- Edit

/**
 * ${tags}
 * @author sucb
 * @date ${date}
 */
View Code

  

    

  

  

猜你喜欢

转载自www.cnblogs.com/sucb/p/9459435.html
今日推荐