前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Eclipse/MyEclipse的快捷键以及文档注释、多行注释的快捷键

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

作者头像
黑泽君
发布2018-10-11 11:03:14
4.2K0
发布2018-10-11 11:03:14
举报
文章被收录于专栏:黑泽君的专栏

一、多行注释快捷键

  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             */

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

    打开Eclipse

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

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

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

代码语言:javascript
复制
<?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文件如下:

代码语言:javascript
复制
<?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

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018-04-18 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档