idea comment template configuration code

Replaced after the eclipse from the idea, a little difficult, one of which is code comments, feel better to eclipse easy to use, here are some of the configuration, and then finished with almost able to achieve the effect of the eclipse.

1, comments configuration Class as an example, similar to other files, open the File - After settings, locate the following figure, select and modify Class notes, variables and parameters with eclipse almost do not speak. Here you configure the new class will be applied after the new note template, but I can only find when the new application, or if the existing methods are not automatically references, can only be maintained manually.

 

 

 

 

 

Free to define your own notes format, only the demo here
/**
* TODO
* @version 1.0
* @author ${USER}
* @date ${DATE} ${TIME}
*/

 

2, comments configuration method, this would more complicated than some of the above. Create the team in the following figure, the name just lose.

 

 

 

Then create a new template in the group, according to the input parameters of the screenshot, Reformat the box in order to avoid problems after wrapping indentation

 

 

 

 

 

*
 * 
 * $params$ 
 * @author $user$ 
 * @date $date$ $time$ 
 * @return $return$
 */
Note that the above is not an asterisk wrong, so you must write variables $$ wrap, also set the following variables. Format or just set yourself, here are just examples

 

设置变量,点击页面上的Edit variables按钮,然后将上面$$中的变量跟idea的内置参数关联起来,其中params内置的变量的没有很合适的,在下面写了个脚本,可以直接复制

 

 

 

groovyScript("def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) {if(params[i] == '') return result;if(i==0) result += '\\n'; result+=' * @param ' + params[i] + ((i < params.size() - 1) ? '\\n' : '')}; return result", methodParameters())

点确定保存之后,在代码上面输入 /** 后按回车,可以自动引用配置的模板,如下图的效果,我找了找没找到像eclipse类似的快捷键,只能这么输入

 

 

我是刚刚换成idea,很多功能也不太会用,针对注释模板暂时就发现了这么多,如果谁有更好的方法,欢迎跟我说说

 

Guess you like

Origin www.cnblogs.com/yanh0606/p/11990863.html