Sublime Forum

ST2: Snippet for dates/time

#1

I have looked around the unofficial documentation (http://docs.sublimetext.info/en/latest/extensibility/snippets.html) and the forums for a solution to this, have found nothing.

As an Advanced Placement Computer Science student (Java), I often type dates (dd.Mon.yyyy) for JavaDoc purposes (course requirement).
I have made (or adjusted) every other snippet I could possibly need right now, except this one.
Ideally, the snippet would work similarly to the class snippet. This snippet uses a TM variable:

${1:${TM_FILENAME/(.*?)(\..+)/$1/}}to fill the class name.

In the unofficial documentation,

.sublime-optionsfiles are referred to, but I could not find any or know where to place one (and if I could or did, I would probably not know how to set a variable to the current date/time).

Any suggestions for a (or directions to an already existing) solution will be greatly appreciated.

  • Alex Ordonez

EDIT: Changed title to specify ST2.

0 Likes

#2

Hi,

I use @FichteFoll’s InsertDate:
github.com/FichteFoll/sublimetext-insertdate

with the following command in my User/Default.sublime-commands:

{ "caption": "InsertDate: ISO Date", "command": "insert_date", "args": {"format": "%Y-%m-%d"} },

If you need to do something more complex you will need to write a simple plugin in Python. (Not too much trouble to do; I’m not a programmer and I managed it.)

Hope this helps,
Alex

0 Likes