Sublime Text 2 - key binding to change syntax

There is an easy way to do that.
On the right bottom, there is a button, click on that button you will get all the available syntax. enter image description here


Use the following key combination to pull up the command palette:

Ctrl+Shift+P

then type:

sshtml (for example, to set the syntax to HTML)


This is how i roll, if that's what you meant exaclty:

// Syntax Change
{"keys": ["alt+shift+h"], "command": "set_file_type",
"args": {"syntax": "Packages/HTML/HTML.tmLanguage"}
},


{"keys": ["alt+shift+m"], "command": "set_file_type",
"args": {"syntax": "Packages/Markdown/Markdown.tmLanguage"}
},


{"keys": ["alt+shift+p"], "command": "set_file_type",
"args": {"syntax": "Packages/PHP/PHP.tmLanguage"}
},


{"keys": ["alt+shift+j"], "command": "set_file_type",
"args": {"syntax": "Packages/Javascript/JSON.tmLanguage"}
},

You can use the Command Pallet (ctrl + shift + p) to change the Syntax, but sometimes using "ss" or "sshtml" brings up other commands that are un-related to the "Set Syntax" options.

You can also add a new Key Binding User Preference that brings up the Command Pallet with the text "Set Syntax: " already in it. Then you just have to type the language you want to set it to.

To setup this key-binding shortcut:

  1. Open the Command Pallet (ctrl + shift + p)
  2. Find and select the "Preferences: Key Bindings" option
  3. Update your User ".sublime-keymap" file to have the "keys" json-object listed in the array:
[
    "// additonal/exsiting key comands go here...",
    { "keys": ["ctrl+alt+l"], "command": "show_overlay", "args": {"overlay": "command_palette", "text": "Set Syntax: "} }
]

Now you can use ctrl+alt+l to bring up the command prompt. Then just type HTML, CSS, or whatever language you're looking to switch too.

Feel free to change the "keys" combination from ctrl+alt+l to anything else you want the shortcut to be too.