Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keymap Sublime Text 2 File Type?

I am working on setting up my own keymaps and was wondering if there is the option to set keys to switch the file type that is being worked on. So for example, if I have a regular plain text file and want it to be a css file, I would have a keymap that would change the document type to css. Possible? If so, please explain to me how you have done this.

Rob

like image 867
pertrai1 Avatar asked May 13 '26 09:05

pertrai1


1 Answers

The keybinding for this would be:

{ 
  "keys": ["YOUR_SEQUENCE"], 
  "command": "set_file_type", 
  "args": {"syntax": "Packages/CSS/CSS.tmLanguage"}
}

How to discover command names:

  • Open the console
  • Type sublime.log_commands(True)
  • Go to an open tab
  • Open the command palette and type Set Syntax: CSS

The name of the command and it's required arguments should be logged to the console. From there you just put it in the right JSON syntax.

like image 141
Liam Cain Avatar answered May 16 '26 00:05

Liam Cain