从Sublime 2获取今天的日期 [英] Get today's date from Sublime 2
问题描述
我是Sublime Text的新手,我以前使用过Textmate,并且那里有一个方便的 today命令,该命令在编辑器中使用外壳返回了今天的日期。
I'm a Sublime Text newbie, I was using Textmate before and there I had a handy 'today' command that was returning today's date in the editor (using the shell).
eg 'today' + TAB ==> '12/10/2012/'
我该如何在Sublime中创建类似的东西?
How would I create something like that in Sublime?
推荐答案
Sublime Text 2具有一个称为代码段的功能,该功能仅允许静态表达式 + TAB替换。
Sublime Text 2 has a feature called Snippets, this allows for only static 'expression' + TAB replacements.
似乎有人正在开发名为 SMART代码段的插件您可以在代码段中使用python代码。
It seems someone is working on a plugin called SMART Snippets in which you can use python code in the Snippets.
带有 SMART代码段,您现在可以使用Python动态创建
代码段。
With SMART Snippets, You can now use Python to dynamically create snippets.
SMART代码段中的python代码类似于:
The python code in your SMART snippet would be something like:
###regex: no
###params: no
###trigger: today
```from time import gmtime, strftime
insert(strftime("%d/%m/%Y", gmtime()))```
现在,在我的Sublime Text 2中,通过键入 today + TAB
This now works in my Sublime Text 2 by typing "today + TAB"
这篇关于从Sublime 2获取今天的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!