Repositories for sublimetext and Word

I think Writemonkey is the best prose editor out there, it works well with NaturallySpeaking, and 3.0 looks to be amazing -- seemingly taking some cues from sublimetext. Unfortunately, it only runs on Windows, and it breaks virtualbox's and vmware's clipboard synchronization. Hence, I haven't been able to use it for a while.

But once I got used to its repository function (i.e., quickly scoot selected text to a repository file) I couldn't do without. Hence, I have plugins for the two text editors I tend to use the most, sadly, neither of which are free: sublimetext (for its power and speed) and MS Word (for speech dictation). I just realized I've never really shared these.

from os.path import abspath, basename, dirname, exists, join, splitext
import sublime, sublime_plugin
import time


class MoveToRepoCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        for region in self.view.sel():  
            if not region.empty():  
                selection = self.view.substr(region)  
                date = time.strftime("%Y-%m-%d %H:%M %Z", time.localtime())
                chunk = '\n<!-- moved from main text: %s -->\n\n%s\n\n' % (
                    date, selection)
                fn = abspath(self.view.file_name())
                path = dirname(fn)
                fn_base, fn_ext = splitext(basename(fn))
                fn_repo = join(path, fn_base + '.repo_md')
                print('fn_repo = %s' % fn_repo)
                if exists(fn_repo):
                    with open(fn_repo, 'r') as repo: 
                        repo_content =
                    repo_content = ''
                with open(fn_repo, 'w') as repo: 
                    repo.write(chunk + repo_content)
                self.view.replace(edit, region, '')

Sub repo()
Attribute repo.VB_ProcData.VB_Invoke_Func = "Normal.NewMacros.repo"
' repo Macro

    Dim fn As String
    Dim FSO As Object
    Set FSO = CreateObject("Scripting.FileSystemObject")

    ChangeFileOpenDirectory ActiveDocument.path
    fn = FSO.GetBaseName(ActiveDocument.Name) & ".repo_md"
    Debug.Print fn

    Documents.Open filename:=fn, _
        ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
        PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
        WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
        wdOpenFormatAuto, XMLTransform:="", Encoding:=1252
    Selection.TypeText ("<!-- moved from main text: ")
    Selection.InsertDateTime DateTimeFormat:="yyyyy-MM-dd HH:mm", _
    Selection.TypeText (" -->")
    Selection.PasteAndFormat (wdFormatPlainText)
    Application.Run MacroName:="Normal.NewMacros.FileSave"
End Sub

Comments !