live_template.md

live template 变量语法

settings -> live templates -> $item -> template text -> edit variables …

template text 写作
xxx $variable_name$ xxx

edit variables expression 语法参考链接: 官方链接
中文链接

实例

1
2
3
4
5
# 获取第一层文件目录(去掉了真正的第一层,因为这里的需求是第一层不要), 变量表达式 Expression
substringBefore(regularExpression(regularExpression(fileRelativePath(), concat(substringBefore(fileRelativePath(), "/"),"/"), ""), concat("/",fileName()), ""),"/")

# 获取第二层文件目录, 实际是第一层后面的都算第二层
regularExpression(regularExpression(regularExpression(fileRelativePath(), concat(substringBefore(fileRelativePath(), "/"),"/"), ""), concat("/",fileName()), ""), concat(substringBefore(regularExpression(regularExpression(fileRelativePath(), concat(substringBefore(fileRelativePath(), "/"),"/"), ""), concat("/",fileName()), ""),"/"), "/"), "")

live_template.md
https://abrance.github.io/2024/09/06/mdstorage/domain/ide/idea/live_template/
Author
xiaoy
Posted on
September 6, 2024
Licensed under