如何创建自定义键绑定以将语法突出显示更改为 Visual Studio Code 中的特定语言? [英] How can I create a custom keybinding to change syntax highlighting to a specific language in Visual Studio Code?

查看:31
本文介绍了如何创建自定义键绑定以将语法突出显示更改为 Visual Studio Code 中的特定语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

{ "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

/github.com/Microsoft/vscode/blob/2e2b47a4944ad1dfc7bbc58756c91aa3188cfa04/src/vs/workbench/browser/parts/editor/editorStatus.ts

推荐答案

你可以通过扩展来实现:

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 中的特定语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆