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