Skip to content

Instantly share code, notes, and snippets.

@sligodave
Last active December 23, 2015 00:28
Show Gist options
  • Save sligodave/6553396 to your computer and use it in GitHub Desktop.
Save sligodave/6553396 to your computer and use it in GitHub Desktop.
A simple sublime text plugin to change the syntax of every opened or new file to YAML. Drop the file "SyntaxToYAML.py" into your Sublime Text "Packages/User/" directory. Add the keymaps to the files with the same name in your "Packages/User/" directory too. DON'T overwrite the "Default (XXX).sublime-keymap" files that are already there. Add to t…
[
// Change the syntax of the current file to YAML
{ "keys": ["ctrl+alt+y"], "command": "change_syntax", "args": {"syntax": "Packages/YAML/YAML.tmLanguage"}}
]
[
// Change the syntax of the current file to YAML
{ "keys": ["ctrl+super+y"], "command": "change_syntax", "args": {"syntax": "Packages/YAML/YAML.tmLanguage"}}
]
[
// Change the syntax of the current file to YAML
{ "keys": ["ctrl+alt+y"], "command": "change_syntax", "args": {"syntax": "Packages/YAML/YAML.tmLanguage"}}
]
import sublime_plugin
class ChangeSyntaxCommand(sublime_plugin.TextCommand):
def run(self, edit, syntax='Packages/Text/Plain text.tmLanguage'):
self.view.set_syntax_file(syntax)
# class ChangeSyntaxToYAMLEventListener(sublime_plugin.EventListener):
# def on_load(self, view):
# view.run_command('change_syntax', args={'syntax': 'Packages/YAML/YAML.tmLanguage'})
# on_new = on_load
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment