Add document comment shortcuts in eclipse

Source: Internet
Author: User

Add document comment shortcuts in eclipse

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 of ${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 effect of this method)
* TODO (This method is described here to apply the condition – optional)
* TODO (described here for the execution process of this method – optional)
* TODO (Describe 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 view) 1.1
*/
</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= "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 under the Corporation ${year}
* All rights reserved
*
*/
</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" >
/**
* ${bare_field_name}
*
* @return The ${bare_field_name}
* @since codingexample Ver (code example 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 means 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}
* Modify NOTES:
* @version
*
*/</template>

</templates>

Add document comment shortcuts 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.