Get today's date from Sublime 2

孤街浪徒 提交于 2019-12-11 11:39:34

问题


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/'  

How would I create something like that in Sublime?


回答1:


Sublime Text 2 has a feature called Snippets, this allows for only static 'expression' + TAB replacements.

It seems someone is working on a plugin called SMART Snippets in which you can use python code in the Snippets.

With SMART Snippets, You can now use Python to dynamically create snippets.

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()))```

This now works in my Sublime Text 2 by typing "today + TAB"



来源:https://stackoverflow.com/questions/12768169/get-todays-date-from-sublime-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!