Sublime Text:除了没有CTRL + E的HTML之外的其他文件中的Emmet选项卡处理程序?

sun*_*rop 9 scope sublimetext2 emmet

我想在其他文件类型/语法模式中使用Emmet而不是HTML.特别是来自Smarty的.tpl文件和不同CMS的其他模板文件.有什么办法可以在这些文件中使用制表符处理程序吗?我不喜欢用其他文件命中CTRL + E,因为唯一的区别是文件扩展名和一些模板部分.

Ser*_*nok 4

Emmet 限制了某些已知文件类型的 Tab 处理程序,因为\xe2\x80\x99s 没有与 ST 本机片段集成的合理方法。例如,如果您尝试扩展(例如foo缩写),Emmet 不知道您是否要将其转换为<foo>标签或扩展与此触发器关联的本机 ST 片段。因此,使用一些技巧来确定您\xe2\x80\x99 想要做什么。虽然这可能适用于 HTML,但在其他语言中,它可能会因错误触发而让您烦恼。

\n\n

如果您 100% 确定您的模板文件中不需要\xe2\x80\x99s 原生 ST 片段,则可以执行以下操作:打开 user\xe2\x80\x99s 键盘映射文件(Key Bindings \xe2\x80\x94 User在 ST 中查找菜单项)并添加那里有以下代码:

\n\n
[{\n    "keys": ["tab"], \n    "command": "expand_abbreviation_by_tab", \n    "context": [\n        {\n            "operand": "SYNTAX SCOPE", \n            "operator": "equal", \n            "match_all": true, \n            "key": "selector"\n        }, \n        {\n            "match_all": true, \n            "key": "selection_empty"\n        }, \n        {\n            "operator": "equal", \n            "operand": false, \n            "match_all": true, \n            "key": "has_next_field"\n        }, \n        {\n            "operator": "equal", \n            "operand": false, \n            "match_all": true, \n            "key": "auto_complete_visible"\n        }, \n        {\n            "operator": "equal", \n            "operand": false, \n            "match_all": true, \n            "key": "setting.disable_tab_abbreviations_on_auto_complete"\n        }, \n        {\n            "match_all": true, \n            "key": "is_abbreviation"\n        }\n    ]\n}]\n
Run Code Online (Sandbox Code Playgroud)\n\n

其中SYNTAX SCOPE是语法的范围名称,您可以通过按 Ctrl+Shift+P (Mac) 或 Ctrl+Alt+Shift+P (PC) 在状态栏中查看它

\n