Sublime Forum

Unable to use the key binding set specifically for html files

#1

I recently wrote a key binding that applies specifically to HTML and CSS files. It works as expected when I try to invoke it in any CSS file. But when I try to invoke it in an HTML file it doesn’t work.
This is the code snippet for the key binding that I wrote:

{
		"keys": ["ctrl+alt+b"],
		"command": "move_to",
		"args": {
			"to": "eol",
			"extend": false
		},
		"context": [
			{
				"key": "selector",
				"operator": "equal",
				"operand": "source.html, source.css"
			}
		]
}

To confirm that this problem was only with HTML file type, I wrote other key bindings setting their context to specific file types. When I tried to invoke them in their specified file types, only the HTML files failed.

I spent a lot of time thinking about where I went wrong. Can someone please help me solve this problem?

I have used the chain package to link multiple commands with a single key binding.

0 Likes

#2

That is because the selector for html files is text.html and not source.html. You can always use the Tools -> Developer -> Show Scope Name to inspect scopes in a file.

2 Likes

#3

Thanks for the advice. Now all the key-bindings are working as expected.

0 Likes