Skip to content

Instantly share code, notes, and snippets.

@saltnlight5
Created November 1, 2012 13:53
Show Gist options
  • Save saltnlight5/3993742 to your computer and use it in GitHub Desktop.
Save saltnlight5/3993742 to your computer and use it in GitHub Desktop.
ZemianNameAndDate.py
// SublimeText user keymap
// Author: Zemian Deng, Date: 2012-11-01_09:55:03
[
{ "keys": ["ctrl+alt+f6"], "command": "reindent"},
{ "keys": ["ctrl+alt+f5"], "command": "zemian_name_and_date"},
{ "keys": ["ctrl+alt+n"], "command": "new_note_file"}
]
# SublimeText command - Create a new file with time stamp as filename.
# Author: Zemian Deng, Date: 2012-11-01_09:54:10
import sublime, sublime_plugin
import time, os.path
class NewNoteFile(sublime_plugin.WindowCommand):
def run(self):
tstamp = time.strftime('%Y%m%d-%H%M%S', time.localtime())
v = self.window.new_file()
v.settings().set('default_dir', os.path.expanduser('~/notes'))
v.set_syntax_file('Packages/Markdown/Markdown.tmLanguage')
v.set_name(tstamp + '.md')
# SublimeText command - Insert Author and Date string.
# Author: Zemian Deng, Date: 2012-11-01_09:50:49
import sublime, sublime_plugin, time
class ZemianNameAndDate(sublime_plugin.TextCommand):
def run(self, edit):
tstamp = time.strftime('%Y-%m-%d_%H:%M:%S', time.localtime())
sel = self.view.sel();
for s in sel:
self.view.replace(edit, s, "Author: Zemian Deng, Date: " + tstamp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment