1

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?

Paolo Moretti
  • 54,162
  • 23
  • 101
  • 92
magicrebirth
  • 4,104
  • 2
  • 25
  • 22

1 Answers1

5

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"

Niels van Reijmersdal
  • 2,038
  • 1
  • 20
  • 36
  • Added installation instructions for SMART_Snippets on the github issue forum: https://github.com/BoundInCode/SMART-Snippets/issues/1 – Niels van Reijmersdal Oct 07 '12 at 12:07
  • seems like a good idea - however I can't get it to work. No snippets display, and the create snippet throws an error.. – magicrebirth Feb 17 '13 at 03:53
  • Seems AGS and me got it working and the SMART Snippets hasnt changes since 10 months, think you are doing something wrong :) but possible Sublime Text 2 has changed and Smart Snippets does not work anymore. – Niels van Reijmersdal Mar 06 '13 at 16:40