Skip to content

Instantly share code, notes, and snippets.

@mdpauley
Forked from FokkeZB/Main.sublime-menu
Created August 13, 2013 19:32
Show Gist options
  • Save mdpauley/6224810 to your computer and use it in GitHub Desktop.
Save mdpauley/6224810 to your computer and use it in GitHub Desktop.
import sublime, sublime_plugin
from os.path import splitext
from os.path import isfile
class MoveWindowCommand(sublime_plugin.EventListener):
def on_load(self, view):
window = sublime.active_window()
myView = window.active_view()
fileName, fileExtension = splitext(view.file_name())
if fileExtension == '.xml':
window.set_view_index(myView, 1, 0)
elif fileExtension == '.tss':
window.set_view_index(myView, 2, 0)
elif fileExtension == '.js':
window.set_view_index(myView, 0, 0)
if isfile(fileName.replace('/controllers/','/views/')+'.xml'):
window.open_file(fileName.replace('/controllers/','/views/')+'.xml')
if isfile(fileName.replace('/controllers/','/styles/')+'.tss'):
sublime.set_timeout(
lambda:
window.open_file(fileName.replace('/controllers/','/styles/')+'.tss')
, 100)
else :
window.set_view_index(myView, 0, 0)
// Put me in: ~/Library/Application Support/Sublime Text 2/Packages/User/Main.sublime-menu
[{
"id": "view",
"children": [{
"id": "layout",
"children": [{
"command": "set_layout",
"caption": "Custom: 3 Pane",
"mnemonic": "C",
"args": {
"cols": [0.0, 0.5, 1.0],
"rows": [0.0, 0.5, 1.0],
"cells": [
[0, 0, 1, 2],
[1, 0, 2, 1],
[1, 1, 2, 2]
]
}
}]
}]
}]
@troscoe
Copy link

troscoe commented Aug 15, 2013

Any reason why this doesn't work when there is no previous file open?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment