eclipse添加註釋

一、多行註釋快捷鍵

1.選中你要加註釋的區域,用ctrl+shift+C 或者ctrl+/ 會加上//註釋
2.先把你要註釋的東西選中,用shit+ctrl+/ 會加上/*    */註釋

3.以上快捷在重複按一下就會去掉加上的註釋
4.要修改在eclispe中的命令的快捷鍵方式我們只需進入windows -> preference -> General -> key設置就行了

二、Eclipse中添加文檔註釋快捷鍵

1.例如默認的文檔註釋:

       /**

         * @author XX

         *

         */

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文件

######################################################################

 

<?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 [email protected]  
 *  @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>

 

 

 

######################################################################

發佈了26 篇原創文章 · 獲贊 10 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章