WebStorm中⾃定义⽂档注释模板(也叫设置⽂档头部注释)前提:
⽤WebStrom不管写HTML,还是JavaScript都会涉及到⼀些⽂档说明。尤其是⽂档的头部注解说明。
只要是你写的页⾯,头部注解说明基本⼀致。每次都写⼀遍?这不像是⼀个玩计算机⼈的风格。
下⾯的⽅法。就解决了此问题。
同时提⽰:养成良好的代码习惯,规范化代码,规范的注释便于后续维护。
实现效果 如下:
⽂档说明注释 :
Webstorm 中,⾃定义说明注释模板,模板内容包括(⽂档描述、作者、创建⽇期等信息):
⾃定义注释模板开始:
⼀、在菜单栏 --->⽂档中 ---> 找到 设置。toad
或者直接 快捷键 Ctrl + Alt + S 打开Webstorm设置,找不到的 可以 直接搜索 ‘Live Template’,然后
选择进⼊到右侧菜单,如下:
⼆、点击右上⾓ “+” --> Live Template,添加注释模板,出现以下界⾯,填写相关的信息。参考如下:
<!--
@name:
@description:
@author: byx
@time: $date$
-->
详细信息图如下:
第五步,“Edit variables” ,这⾥说⼀下,时间($date$)的具体格式,这个格式和 java中的还不⼀样,百度也是⼀半对,⼀半错,记录下来。防⽌下回换电脑再应⽤到。
date("yyyy-MM-dd HH:mm:ss")
第六步,“Change” 选择模板应⽤的范围。⼀般不会的就全选就好了。嘿嘿。我只HTML中⽤到此快捷键。就只勾选了HTML相关。
选择模板应⽤范围项 为必选项,不选 会报错。保存不了。
三、在HTML代码中,输⼊ /// + Tab 键即可 ⾃动⽣成 ⾃定的 ⽂档头部 注释模板了
番外:最后,详细介绍的⼀下第五步的 Edit variables 到底有哪些参数可⽤。如下图:(图⽚来源于⽹络,byx收集记录) pleasant
Item Description
人生如戏英文
blockComm entEnd Returns the characters that indicate the end of a block comment in the current language context.返回指⽰当前语⾔上下⽂中块注释结尾的字符。
blockComm entStart Returns the characters that indicate the start of a block comment in the current
language context.返回指⽰当前语⾔上下⽂中块注释开头的字符。
camelCa(St ring)Converts a string into camelCa. For example, camelCa(my-text-file), camelCa(my text file), and camelCa(my_text_file) all return myTextFile.
将字符串转换为驼⾊⼤⼩写。例如, camelCa(my-text-file), camelCa(my text file), and camelCa(my_text_file) 这三种都返回 myTextFile.
capitalize(Stri ng)Capitalizes the first letter of the parameter.将参数的第⼀个字母⼤写。
capitalizeAnd Underscore(s CamelCaN Capitalizes all the letters of a CamelCa name pasd as the parameter, and inrts an underscore between the parts. For example, capitalizeAndUnderscore(FooBar) returns FOO_BAR.
ame)将参数所有字母⼤写,并在各部分之间插⼊下划线。例如,如capitalizeAndUnderscore(FooBar),返回FOO_BAR恨的英文
classNameCo mplete()This expression substitutes for the at the variable position.此表达式在变量位置替换类名完成。
clipboard()Returns the contents of the system clipboard.返回系统剪贴板的内容。
the way i am
commentEn d()Returns the characters that indicate the end of a comment in the current language context. The return value is empty if line comments are defined in the current language.
返回指⽰当前语⾔上下⽂中注释结尾的字符。如果⾏注释是⽤当前语⾔定义的,则返回值为空。
commentSta rt()Returns the characters that indicate the start of a comment in the current language context. If line comments are defined in the current language, their start indicator is preferable.
返回指⽰当前语⾔上下⽂中注释开头的字符。如果⾏注释是⽤当前语⾔定义的,则它们的开始指⽰符更可取。
complete()Invokes code completion at the position of the variable.在变量的位置⾃动识别代码
completeSma rt()Invokes smart type completion at the position of the variable.在变量的位置调⽤智能类型完成。
hailconcat()Returns a concatenation of all the strings pasd to the function as parameters.返回串联的所有参数
dartIterable Variable()Returns the name of a variable that can be iterated.返回可迭代的变量的名称。
accumulation
dartListVari able()Returns a list of elements of an array.返回数组元素的列表。
dartSuggest IndexName( )Returns a suggested name for an index variable from most commonly ud ones: i, j, k, etc. The names that are not ud in the current scope yet are shown first.
返回最常⽤的索引变量的建议名称:i、j、k等。当前作⽤域中尚未使⽤的名称将⾸先显⽰。
airdrop是什么dartSuggest VariableNa me()Returns the suggested name for a variable bad on its variable type and initializer expression, according to your code style ttings that refer to the variable naming rules.
For example, if it is a variable that holds an element within an iteration, WebStorm makes a guess on the most reasonable name, taking into account the name of the container that is iterated.
date(sDate)Returns the current system date in the specified format.
Without a parameter, the current date is returned in the default system format.以指定格式返回当前系统⽇期。
如果没有参数,则以默认系统格式返回当前⽇期。
fpadecapitalize(s Name)Replaces the first letter of the parameter with the corresponding lowerca letter.将参数的第⼀个字母替换为相应的⼩写字母。
enum(sCompl
solo
etionString1,s CompletionSt ring2,...)Returns a list of comma-parated strings suggested for completion when the template is expanded.返回在扩展模板时建议完成的逗号分隔字符串列表。
escapeString( sEscapeStrin g)Escapes the string specified as the parameter.转义指定为参数的字符串。
expectedTyp e()Returns the expected type of the expression into which the template expands. Makes n if the template expands in the right part of an assignment, after return, etc.
当模板扩展中返回表达式的预期类型,如果模板在分配的正确部分、返回后等进⾏扩展,则是有意义的。
fileName()Returns the name of the current file with its extension.
Item Description