如何在文本片段中使用此路径?
我想要一个字符串 $TM_PROJECT_DIRECTORY-$TM_FILEPATH..... $TM_PROJECT_DIRECTORY
是
/Users/me/Desktop/project/application/app_name
$TM_FILEPATH
是 /Users/me/Desktop/project/application/app_name/application/models/user_model.php
我想要的结果:
application/models/user_model.php
I would like to have a string that is $TM_PROJECT_DIRECTORY-$TM_FILEPATH.....
the $TM_PROJECT_DIRECTORY
is
/Users/me/Desktop/project/application/app_name
and $TM_FILEPATH
is /Users/me/Desktop/project/application/app_name/application/models/user_model.php
The result I want:
application/models/user_model.php
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您无法使用原始片段语法执行此操作,但您可以使用命令动态创建片段。
因此,要执行您想要的操作,您必须创建“New Command”,然后在其中创建一个您想要的代码片段,例如 ruby:
然后在
Input
中设置none
并在 <代码>输出设置插入为片段
。实际上,使用 TextMate 了解的任何编程语言都可以即时创建许多功能强大的片段。
You can't do this in raw snippet syntax, but you can create snippets on the fly using the Commands.
So, to do what you want you must create «New Command», then make a snippet you want in, for example, ruby:
then in
Input
setnone
and inOutput
setInsert as Snippet
.Actually, using any programming language TextMate understand you can create a lot of powerful snippets on the fly.
${TM_FILEPATH/$TM_PROJECT_DIRECTORY\//}
有关详细信息,请参阅 TextMate 帮助中的第 7.7 节“片段/转换”。
${TM_FILEPATH/$TM_PROJECT_DIRECTORY\//}
See Section 7.7 "Snippets/Transformations" in the TextMate Help for details.
我自己也刚刚遇到这个问题。这是我使用的代码片段:
当 Textmate 插入代码片段时,周围的反引号执行 shell 代码。
Just had this issue myself. Here's the snippet I used:
The surrounding backticks execute the shell code when Textmate inserts the snippet.