Eclipse/MyEclipse的快捷键以及文档注释、多行注释的快捷键

一、多行注释快捷键

  1.选中你要加注释的区域,用 Ctrl+Shift+C 或者 Ctrl+/ 会加上 // 注释,再重复按一下就会去掉 // 注释。(.js文件中只有 Ctrl+Shift+C 管用,.java文件中都管用)

  2.选中你要加注释的区域,用 Ctrl+shit+/  会加上 /*...*/ 注释,再用 Ctrl+shit+\  会去掉 /*...*/ 注释。(注意:正斜杠是加注释,反斜杠是去掉注释)

  3.要修改在eclispe中的命令的快捷键方式我们只需进入 Windows -> Preferences -> General -> keys 设置就行。

二、Eclipse中添加文档注释快捷键

  1.例如默认的文档注释:

    /**   
    * @author xxx
    * 
    * 
    */

  2.快捷键为:Alt+Shift+J

  3.修改文档注释的注释格式内容,修改的方法有两种:

    A.直接在eclipse给的模板下进行修改

    打开Eclipse

    Window --> Preferences --> Java --> Code Style  --> Code Templates --> Comments --> types --> Edit...

    例如:

    /**   
    * 项目名称:${project_name}   
    * 类名称:${type_name}   
    * 类描述:   
    * 创建人:${user}   
    * 创建时间:${date} ${time}   
    * @version        
    */

Eclipse/MyEclipse的快捷键以及文档注释、多行注释的快捷键

    B.自己编写一个xml文档导入进去

    打开Eclipse

    Window --> Preferences --> Java --> Code Style --> Code Templates --> Comments --> types --> Import...

       选择你写好的模板.xml文件

Eclipse中默认的模板.xml文件如下:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="true" context="constructorcomment_context" deleted="false" description="Comment for created constructors" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment">/**
 * ${tags}
 */</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">/**
 * @author ${user}
 *
 * ${tags}
 */    </template><template autoinsert="true" context="fieldcomment_context" deleted="false" description="Comment for fields" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name="fieldcomment">/**
 * 
 */</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="true" context="filecomment_context" deleted="false" description="Comment for created Java files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.filecomment" name="filecomment">/**
 * 
 */</template><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="methodcomment_context" deleted="false" description="Comment for non-overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name="methodcomment">/**
 * ${tags}
 */</template><template autoinsert="true" 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="overridecomment_context" deleted="false" description="Comment for overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name="overridecomment">/* (non-Javadoc)
 * ${see_to_overridden}
 */</template></templates>

自己写好的模板.xml文件如下:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><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"/><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">
/**
 *  Description:
 *  @author hp  DateTime ${date} ${time}
 *  ${tags}
 */
 </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">
/**
 *  Description:
 *  @author hp  DateTime ${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">
/**
 *  Description:
 *  @author hp  DateTime ${date} 
 *  
 */</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">
/**
 *  Class Name: ${file_name}
 *  Description: 
 *  @author hp  DateTime ${date} ${time} 
 *  @company bvit 
 *  @email hu.peng@bvit.com.cn  
 *  @version 1.0
 *  ${tags}
 */</template><template autoinsert="false" context="gettercomment_context" deleted="false" description="Comment for getter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name="gettercomment">
/**
 * @return get ${bare_field_name}
 */</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">
/**
 *  Description:
 *  @author hp  DateTime ${date} ${time}
 *  ${tags}
 */</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">
/**
 * Description:
 * @author hp DateTime ${date} 
 * ${tags}
 * ${see_to_target}
 */</template><template autoinsert="false" context="settercomment_context" deleted="false" description="Comment for setter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.settercomment" name="settercomment">
/**
 * @param ${param} set ${bare_field_name}
 */</template></templates>

参考博客链接:https://my.oschina.net/u/590763/blog/70166

我的GitHub地址:https://github.com/hei*gjun
我的博客园地址:http://www.cnblogs.com/chenmingjun
我的蚂蚁笔记博客地址:http://blog.leanote.com/chenmingjun
Copyright ©2018 黑泽明军
【转载文章务必保留出处和署名,谢谢!】
上一篇:【SpringCloud-Alibaba系列教程】12.日志链路追踪


下一篇:Spark机器学习1·编程入门(scala/java/python)