1. 程式人生 > >IntelliJ IDEA生成live template(代碼模板)

IntelliJ IDEA生成live template(代碼模板)

編輯 .com style list esc 指定 int result 粘貼

IntelliJ IDEA生成live template(代碼模板)

一、進入live template模板

快捷鍵:Ctrl+Shift+A進入Find Action,輸入live template

技術分享圖片

回車進入模板設置

二、添加模板組

技術分享圖片

輸入組名點擊確認

三、添加模板

技術分享圖片

四、編輯模板

技術分享圖片

五、指定變量函數

技術分享圖片

將以下代碼賦值粘貼到上面param對應處

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

另外附上我的代碼模板

*
 * @Author 
 * @Date $time$ $date$
 * @Description 
 
 $param$ 
 
 * @Return $return$ 
 * @Exception $exception$
 */

六、快捷鍵生成模板

在方法體上面輸入/**,然後按tab鍵就可以生成如下註釋

技術分享圖片

IntelliJ IDEA生成live template(代碼模板)