idea 模版之自定義類與方法注釋
很多公司都有要求的代碼注釋規范,我們每新建類或者方法的時候從新復制粘貼很麻煩,而且容易粘錯。
當然自定義模板還可以用到很多地方,比如系統自帶的 sout
就是system.out.print();
當你輸入某文本的時候,系統會自動替換成目標文本。
首先介紹一下類模板
不只是java類,所有支持的文件頭都可以自定義
File -- Settings -- Editor -- Code Style -- File and Code Templates
將對應文本替換就可以了,根據自己需求。 這些變量在Descriptions里面有定義 我先粘出來方便查找吧。
${PACKAGE_NAME}
name of the package in which the new file is created
${NAME}
name of the new file specified by you in the New <TEMPLATE_NAME> dialog
${USER}
current user system login name
${DATE}
current system date
${TIME}
current system time
${YEAR}
current year
${MONTH}
current month
${MONTH_NAME_SHORT}
first 3 letters of the current month name. Example: Jan, Feb, etc.
${MONTH_NAME_FULL}
full name of the current month. Example: January, February, etc.
${DAY}
current day of the month
${HOUR}
current hour
${MINUTE}
current minute
${PROJECT_NAME}
the name of the current project
但是這個暫時不知道怎么修改。
然后就是方法模板
其實就是文本替換,也很簡單
settings > live templates
abbreviation 就是縮寫 比如sout。
底下的是作用域,這里面的變量又不一樣, 點擊右側 Edit variables可以編輯
其實是很多函數。 這個有需求的自己去查一查吧。