Skip to content

Instantly share code, notes, and snippets.

@is
Created March 18, 2016 12:53
Show Gist options
  • Select an option

  • Save is/7858c68f76cca54ccc13 to your computer and use it in GitHub Desktop.

Select an option

Save is/7858c68f76cca54ccc13 to your computer and use it in GitHub Desktop.
Sublime tagline plugin.
import sublime, sublime_plugin
import time
class IsNoteCommand(sublime_plugin.TextCommand):
def run(self, edit):
pos = self.view.sel()[0].begin()
noteid = self.noteid()
message = "==NOTE-%d %s" % (noteid, time.strftime("%Y.%m.%d %H:%M:%S\n"))
self.view.insert(edit, pos, message)
def noteid(self):
# ref:
# https://forum.sublimetext.com/t/how-to-get-complete-text-contents-of-active-tab/4758/2
noteid = 0
content = self.view.substr(sublime.Region(0, self.view.size()))
lines = content.replace("\r\n", "\n").replace("\r", "\n").split("\n")
for line in lines:
if (line.startswith("==NOTE-")):
curid = int(line[7:].split()[0])
if (curid > noteid):
noteid = curid
noteid += 1
return noteid;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment