Skip to content

Instantly share code, notes, and snippets.

@bland-industries
Last active August 29, 2015 14:04
Show Gist options
  • Save bland-industries/64b6e42a4f542322c9ec to your computer and use it in GitHub Desktop.
Save bland-industries/64b6e42a4f542322c9ec to your computer and use it in GitHub Desktop.
Plugin for Sublime Text 2: Opens the model view and presenter of a file if the file name is structure as name.model.extension for example.
import sublime, sublime_plugin, os.path
class ModelViewPresenterCommand(sublime_plugin.TextCommand):
def run(self, edit):
mvpNames = ['model','view','presenter']
newthing = self.view.file_name().split("/")
newNewthing = newthing[len(newthing)-1].split(".")
win = self.view.window()
if (newNewthing[1] in s for s in mvpNames):
if os.path.isfile(newNewthing[0] + ".view." + newNewthing[2]):
try:
viewView = win.open_file(newNewthing[0] + ".view." + newNewthing[2])
except:
print "not opening view"
if os.path.isfile(newNewthing[0] + ".model." + newNewthing[2]):
try:
modelView = win.open_file(newNewthing[0] + ".model." + newNewthing[2])
except:
print "not opening model"
if os.path.isfile(newNewthing[0] + ".presenter." + newNewthing[2]):
try:
presenterView = win.open_file(newNewthing[0] + ".presenter." + newNewthing[2])
except:
print "not opening pres"
win.open_file(".".join(newNewthing))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment