1、注释设置 【重要可以保存使用】
在菜单栏Window--->Preferences--->Java--->Code Style--->Code Templates然后展示Comments节点就是所有需设置注释的元素。可以直接导入如下设置的xml文件。
添加注释的快捷键:Alt+Shift+J 或者 右键--->Source--->Generate Element Comment。
<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="true" context="gettercomment_context" deleted="false" description="Comment for getter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name="gettercomment">/** * @return the ${bare_field_name} */</template><template autoinsert="true" context="settercomment_context" deleted="false" description="Comment for setter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.settercomment" name="settercomment">/** * @param ${param} the ${bare_field_name} to set */</template><template autoinsert="false" context="constructorcomment_context" deleted="false" description="Comment for created constructors" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment">/** * @Title * @Description * ${tags} */ </template><template autoinsert="false" context="filecomment_context" deleted="false" description="Comment for created Java files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.filecomment" name="filecomment">/** * @FileName ${file_name} * @Package ${package_name} * @Description ${todo}[what the file to do] * @Author * @Date date{time} * @Version V1.0.1 */</template><template autoinsert="false" context="typecomment_context" deleted="false" description="Comment for created types" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.typecomment" name="typecomment">/** * @ClassName ${type_name} * @Description ${todo}【what the class to do】 * @Author * @Date date{time} * ${tags} */ </template><template autoinsert="false" context="fieldcomment_context" deleted="false" description="Comment for fields" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name="fieldcomment">/** * @Fields field{todo}【what the field to do】 */</template><template autoinsert="false" context="methodcomment_context" deleted="false" description="Comment for non-overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name="methodcomment">/** * @Title ${enclosing_method} * @Description ${todo}【what the method to do】 * ${tags} * @Return ${return_type} * @Throws */ </template><template autoinsert="false" context="overridecomment_context" deleted="false" description="Comment for overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name="overridecomment">/** * @Title ${enclosing_method} * @Description * ${tags} * ${see_to_overridden} */ </template><template autoinsert="false" context="delegatecomment_context" deleted="false" description="Comment for delegate methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name="delegatecomment">/** * ${tags} * ${see_to_target} */ </template><template autoinsert="true" context="newtype_context" deleted="false" description="Newly created files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.newtype" name="newtype">${filecomment} ${package_declaration} ${typecomment} ${type_declaration}</template><template autoinsert="true" context="classbody_context" deleted="false" description="Code in new class type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.classbody" name="classbody"> </template><template autoinsert="true" context="interfacebody_context" deleted="false" description="Code in new interface type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name="interfacebody"> </template><template autoinsert="true" context="enumbody_context" deleted="false" description="Code in new enum type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.enumbody" name="enumbody"> </template><template autoinsert="true" context="annotationbody_context" deleted="false" description="Code in new annotation type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name="annotationbody"> </template><template autoinsert="true" context="catchblock_context" deleted="false" description="Code in new catch blocks" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.catchblock" name="catchblock">// ${todo} Auto-generated catch block ${exception_var}.printStackTrace();</template><template autoinsert="true" context="methodbody_context" deleted="false" description="Code in created method stubs" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodbody" name="methodbody">// ${todo} Auto-generated method stub ${body_statement}</template><template autoinsert="true" context="constructorbody_context" deleted="false" description="Code in created constructor stubs" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name="constructorbody">${body_statement} // ${todo} Auto-generated constructor stub</template><template autoinsert="true" context="getterbody_context" deleted="false" description="Code in created getters" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.getterbody" name="getterbody">return ${field};</template><template autoinsert="true" context="setterbody_context" deleted="false" description="Code in created setters" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.setterbody" name="setterbody">${field} = ${param};</template></templates>
2、格式化代码设置
在菜单栏Window--->Preferences--->Java--->Code Style--->Formatter然后点击右侧的Edit进行修改。
3、代码智能提示 【可不设置如此多,否则提示反而影响编程速度,可是使用快捷键alt+/提示】
在菜单栏Window--->Preferences--->Java--->Editor--->Content Assist,右侧Auto Activation中Auto activation delay设为1,Auto activation triggers for Java设为.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW。
4、设置代码区背景色
在菜单栏Window--->Preferences--->General--->Editors--->Text Editors,右侧Appearance color options中Background color设为:色调85 饱和度123 亮度205。
5、设置“空格”和“=”号不上屏
在菜单栏File--->Import--->Plug-in Development--->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--->Plug-in Development--->Deployable plug-ins and fragments。导出后将生成的文件覆盖安装目录中plugins文件夹下的对应文件即可。