Add document comment shortcuts in Eclipse

Source: Internet
Author: User

For example:

/**
* @param
* @return

*/

Shortcut keys are:ALT + SHIFT +j

To change to a different shortcut key:

window-->preferences-->general-->keys; Find "Add Javadoc comment" To change your favorite shortcut keys.

In addition, if you feel that comments can also be modified, there are two methods of modification:

1. Modify directly under Eclipse-given template

2. Write an XML document yourself and import it in

Let's talk about the first method first:

Open Eclipse

window-->preferences--> Java -->code Style ---Code Templates---Comments--types---Edit

/**
*
* Project name: ${project_name}
* Class name: ${type_name}
* Class Description:
* Creator: ${user}
* Creation time: ${date} ${time}
* Modified by: ${user}
* Modified: ${date} ${time}
* Modify NOTES:
* @version
*
*/

The second method is:

Click the Import button on the right to select the template you have written. xml file

The following is a comment line template codetemplates.xml, which can be imported directly using. Put out the source code for everyone to reference

<?xml version= "1.0" encoding= "UTF-8"? ><templates><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 ">/*** create a new instance ${enclosing_ type}.** ${tags}*/</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=" Methodcomment_context "deleted=" false "description=" Comment for non-overriding methods "enabled=" true "Id=" org.eclipse.jdt.ui.text.codetemplates.methodcomment "name=" Methodcomment ">/*** ${enclosing_method} ( Here is a word describing the function of this method) * TODO (described here to apply conditions – optional) * TODO (described here for the execution process of this method – optional) * TODO (here describes how this method is used – optional) * TODO (this method is described here for considerations – optional) *@param name* @param @return Settings file * @return String DOM Object * @Exception Exception Object * @since codingexample Ver (code example) 1.1*/</templa Te><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= "false" context= "Filecomment_context" Deleted= "false" description= "Comment for created Java files" enabled= "true" id= " Org.eclipse.jdt.ui.text.codetemplates.filecomment "Name=" filecomment ">/*** file name: ${file_name}** version Information: * Date: ${date} * Copyright **/</template><template autoinsert= "false" context= "Gettercomment_ ${year}* Context "deleted=" false "description=" Comment for getter Method "enabled=" true "id=" Org.eclipse.jdt.ui.text.codetemplates.gettercomment "Name=" gettercomment ">/*** ${bare_field_name}** @return The ${bare_field_name}* @since codingexample Ver (codedExample view) 1.0*/</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><template autoinsert= "false" context= "Fieldcomment_context" deleted= "false" Description= "Comment for Fields" enabled= "true" id= "Org.eclipse.jdt.ui.text.codetemplates.fieldcomment" Name= " Fieldcomment ">/*** ${field}:${todo} (describe what this variable says in a sentence) * * @since Ver 1.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 ">/**** Project name: ${project_name}* class Name: ${type_ name}* class Description: * Creator: ${user}* creation time: ${date} ${time}* Modified by: ${user}* modified: ${date} ${time}* Modified NOTE: * @version **/</template>& Lt;/templates>

Add document comment shortcut keys in Eclipse

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.