热门搜索 :
考研考公
您的当前位置:首页正文

IDEA中file template设置

来源:东饰资讯网
Paste_Image.png

前言

IDEA已经成为了Java程序员眼中最好的编辑器,虽然工作中的大多数还是Eclipse,但是IDEA的便捷和智能早已经超过了Eclipse,即便编程工具不会很大的影响写出代码质量的高低,但是有一款称心如意的IDE也是很开心的,这次主要是总结一下File-Template的设置。

目录

  • 1.什么是File Template
  • 2.如何设置File Template

一、什么是File Template

File Template就是文件模板,可能在Eclipse中大家都用过,就是对文件、类,方法等有一个统一的标识,每家公司都对自己的代码有一套规范,但是我们如果对这些非关键字符(代码中的描述、包名、时间等)进行手写输入,一是会觉得很烦,二也没有效率,这就出现了文件模板。

二、如何设置File Template

IDEA的默认文件模板是这样的:

Paste_Image.png

对于这种注释对用户不友好,这就需要我们来定制了,这是IDEA官网介绍:

文件代码模板的设置

Paste_Image.png
  • Files:文件,例如CLASS,HTML等,指的是某一类文件
  • Includes:这就像是工具类,可以在其他三个目录中引入
  • Code
  • Other

默认IDEA的设置是这样的:

  • 设置Include:File Header
Paste_Image.png
  • 在具体的File中引入
Paste_Image.png
  • 我们只需要改变或者新建一个include就可以了,我们将 File Header改变一下(具体语法见下面文件代码模板变量)


  • 效果显示

Paste_Image.png

文件代码模板预设的变量

  • ${PACKAGE_NAME} - the name of the target package where the new class or interface will be created.
  • ${PROJECT_NAME} - the name of the current project.
  • ${FILE_NAME} - the name of the PHP file that will be created.
  • ${NAME} - the name of the new file which you specify in the New File dialog box during the file creation.
  • ${USER} - the login name of the current user.
  • ${DATE} - the current system date.
  • ${TIME} - the current system time.
  • ${YEAR} - the current year.
  • ${MONTH} - the current month.
  • ${DAY} - the current day of the month.
  • ${HOUR} - the current hour.
  • ${MINUTE} - the current minute.
  • ${PRODUCT_NAME} - the name of the IDE in which the file will be created.
  • ${MONTH_NAME_SHORT} - the first 3 letters of the month name. Example: Jan, Feb, etc.
  • ${MONTH_NAME_FULL} - full name of a month. Example: January, February, etc.
Top