Skip to content

Instantly share code, notes, and snippets.

@FokkeZB
Last active December 21, 2015 00:09
Show Gist options
  • Save FokkeZB/6218345 to your computer and use it in GitHub Desktop.
Save FokkeZB/6218345 to your computer and use it in GitHub Desktop.
# Put me in: ~/Library/Application Support/Sublime Text 2/Packages/User/
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/
[{
"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]
]
}
}]
}]
}]
@mdpauley
Copy link

When the .js file was opened I had to add a timeout for the .tss file since the xml file and it opened at the same time and caused an issue

if isfile(fileName.replace('/controllers/','/styles/')+'.tss'):
    sublime.set_timeout(
        lambda: 
            window.open_file(fileName.replace('/controllers/','/styles/')+'.tss')
        , 100)

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