问题描述
{ "key": "ctrl+k m",
"command": "workbench.action.editor.changeLanguageMode" },
基于上述触发选择语言模式"下拉菜单的默认键绑定,我假设我应该能够在自定义 keybindinds.json 字符串中传入另一个参数(或优化命令"字符串)强制选择特定语言的语法文件.
Based on the above default keybinding to trigger the 'Select Language Mode' drop down, I'm assuming that I should be able to pass in another parameter (or refine the "command" string) in a custom keybindinds.json string to force the selection of a specific language's syntax file.
在 SublimeText 3 中,我的自定义 .json 键绑定切换到 SQL 语法高亮显示如下:
In SublimeText 3, my custom .json keybinding to switch to SQL syntax highlighting just looked like this:
{"keys": ["alt+s"], "command": "set_file_type",
"args": {"syntax": "Packages/SQL/SQL.sublime-syntax"}}
我可以传入什么附加参数来强制 workbench.action.editor.changeLanguageMode
选择特定的语言标识符?
What additional parameter can I pass in to force workbench.action.editor.changeLanguageMode
to select a specific language identifier?
https://code.visualstudio.com/docs/languages/identifiers
推荐答案
你可以通过扩展来实现:
You can do it with extension:
{
"key": "ctrl+shift+8",
"command": "changeLanguageMode.change",
"args": "sql"
}
https://marketplace.visualstudio.com/items?itemName=usernamehw.change-language-mode
这篇关于如何创建自定义键绑定以将语法突出显示更改为 Visual Studio Code 中的特定语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!