---
title: "eclipse 内置注解设置"
author: "zhb8015"
date: "2015-07-21T19:12:55Z"
tags: ["Eclipse"]
categories: ["编程语言"]
slug: "eclipse"
draft: false
lastmod: "2015-07-21T19:12:55Z"
id: 2229163
url: "https://peter8015.iteye.com/blog/2229163"
---

**1、注释设置** 

在菜单栏Window---&gt;Preferences---&gt;Java---&gt;Code Style---&gt;Code Templates然后展示Comments节点就是所有需设置注释的元素。

添加注释的快捷键：Alt+Shift+J 或者 右键---&gt;Source---&gt;Generate Element Comment

文件（Files） 注释标签：

/\**  
\* @FileName ${file\_name}  
\* @Package ${package\_name}  
\* @Description ${todo}【用一句话描述该文件做什么】  
\* @Author   
\* @Date date{time}  
\* @Version V1.0.1

\*/

类（Types）注释标签： 

/\**  
\* @ClassName ${type\_name}  
\* @Description ${todo}【这里用一句话描述这个类的作用】  
\* @Author   
\* @Date date{time}  
* ${tags}

\*/ 

字段（Fields） 注释标签：

/\**  
\* @Fields field{todo}【用一句话描述这个变量表示什么】  
\*/

构造函数标签： 

/\**  
\* @Title   
\* @Description   
\* ${tags}

\*/ 

方法（Methods）标签：

/\**  
\* @Title ${enclosing\_method}  
\* @Description ${todo}【这里用一句话描述这个方法的作用】  
\* ${tags}   
\* @Return ${return\_type} 返回类型  
\* @Throws 

\*/ 

重写方法（Overriding Methods）标签： 

/\**  
\* @Title ${enclosing\_method}  
\* @Description   
\* ${tags}  
\* ${see\_to\_overridden}

\*/ 

委托方法（Delegate Methods）标签： 

/\**  
\* ${tags}  
\* ${see\_to\_target}

\*/ 

Getters标签： 

/\**  
 * @return the ${bare\_field\_name}

 \*/ 

Setters标签： 

/\**  
 * @param paramthe{bare\_field\_name} to set  
 \*/

**2、格式化代码设置** 

在菜单栏Window---&gt;Preferences---&gt;Java---&gt;Code Style---&gt;Formatter然后点击右侧的Edit进行修改。

**3、代码智能提示** 

在菜单栏Window---&gt;Preferences---&gt;Java---&gt;Editor---&gt;Content Assist，右侧Auto Activation中Auto activation delay设为1，Auto activation triggers for Java设为.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW。

**4、设置代码区背景色** 

在菜单栏Window---&gt;Preferences---&gt;General---&gt;Editors---&gt;Text Editors，右侧Appearance color options中Background color设为：色调85 饱和度123 亮度205。

**5、设置“空格”和“=”号不上屏**

在菜单栏File---&gt;Import---&gt;Plug-in Development---&gt;Plug-ins and Fragmets，选择Import As Projects with source folders，点击“下一步”，选择org.eclipse.jface.text。在Project Explorer视图中修改org.eclipse.jface.text的源码【如果在项目里没有src，则需要下载Eclipse SDK】，选择org.eclipse.jface.text.contentassist，修改CompletionProposalPopup.java文件中下面的代码：

if (contains(triggers, key))  
修改为  
if (key!=';'&&key!='='&&key!=0x20&& contains(triggers, key))

然后鼠标右键点击org.eclipse.jface.text项目，选择Export---&gt;Plug-in Development---&gt;Deployable plug-ins and fragments。导出后将生成的文件覆盖安装目录中plugins文件夹下的对应文件即可。

**6、自动换行** 

在菜单栏Help---&gt;Install New Software，选择Add，在“Name”中填入“WordWrap”，“URL”中填入“http://ahtik.com/eclipse-update/” 按照提示安装就可以了。安装完成后，在代码编辑界面点击右键，会出现“WordWrap”属性，将这个属性选上就可以实现自动换行了。