Created
October 24, 2014 21:28
-
-
Save byron-janrain/52efb9c9f45dd565fb2b to your computer and use it in GitHub Desktop.
SublimeText 3 plugin for SemSem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime, sublime_plugin | |
class SemSemListener(sublime_plugin.EventListener): | |
def on_modified(self, view): | |
if not view.settings().get('semsem_go'): | |
return | |
region = view.sel()[0] | |
current = region.begin() - 1 | |
prev = region.begin() - 2 | |
sem = view.substr(current) | |
semsem = view.substr(prev) | |
if semsem == ';' and sem == ';': | |
view.run_command('sem_sem') | |
class SemSemCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
view = self.view | |
region = self.view.sel()[0] | |
line = view.line(region) | |
if line.contains(region) and view.substr(line.end() - 1) != ';': | |
view.insert(edit, line.end(), ';') | |
if region.end() != line.end(): | |
erase = sublime.Region(region.begin() - 2, region.begin()) | |
view.erase(edit, erase) |
In case it wasn't clear, this is a plugin to allow typing semicolons at the end of any line by typing ;; anywhere on that line. Since there's no legitimate use-case for a double-sem and jumping to the end of the line uses different key combos on different platforms. if the cursor is already at the end of the line, you can type as many semicolons as you want.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
download and copy to ~/Library/Application Support/Sublime Text 3/ Packages/User/semsem.py
Then in the syntax specific configuration add the following setting
"semsem_ho": true
To activate.