Boo*_*man 3 visual-studio-code
我是 VScode 新手。我想知道是否有任何方法可以更改line comment特定文件扩展名的快捷键的行为。特别是,我有一个名为file.frm. 现在该文件类型的行注释应该是*ie
cat file.frm
* This is a comment
// This is not a comment
// However ctrl+k ctrl+c puts line comment as // like in C
Run Code Online (Sandbox Code Playgroud)
默认情况下ctrl+k ctrl+c将行注释//类似于C. 我想把这个改成*. 当然,对于其他文件类型,此快捷方式的行为将像往常一样保持不变。我该怎么做?
有官方扩展支持此文件类型的语法突出显示,但显然不支持行注释快捷方式:
Name: FORM Syntax Highlighting
Id: benruijl0774.vscode-form
Description: Syntax highlighting for the symbolic manipulation toolkit FORM.
Version: 0.0.1
Publisher: Ben Ruijl
VS Marketplace Link: https://marketplace.visualstudio.com/items?
itemName=benruijl0774.vscode-form
Run Code Online (Sandbox Code Playgroud)
我做了一个扩展,使这个过程变得更容易:自定义语言属性。
"Show the language configuration file for the current editor"
"command": "custom-language-syntax.showConfigFile",
Run Code Online (Sandbox Code Playgroud)
language-configuration.json包含与活动文本编辑器的语言 ID 相关的文件。它看起来类似于:{
"comments": {
"lineComment": "//", // this is wwrong
"blockComment": [
"/*",
"*/"
]
},
// <etc.>
Run Code Online (Sandbox Code Playgroud)
lineComment值更改为:"lineComment": "*",
Run Code Online (Sandbox Code Playgroud)
这会更改您安装的语言扩展中的实际文件。 重新加载vscode即可看到生效。
此选项的缺点是,如果language-configuration.json扩展作者将来更新该文件,您将丢失所做的更改,并且必须重新编辑该文件。[就语言而言form,这种情况似乎不太可能经常发生。] 无论如何,该Custom Language Properties命令都可以轻松查看和更改该文件。
"Transform the current language configuration file for intellisense"
Run Code Online (Sandbox Code Playgroud)
这将使以下步骤变得更容易,因为您应该在设置中获得智能感知。
settings.json:"custom-language-properties": {
"form.comments.lineComment": "*" // you should get intellisense for most of this
}
Run Code Online (Sandbox Code Playgroud)
这不会更改底层language-configuration.json文件,只是覆盖其lineComment条目。不需要重新加载 vscode 即可看到此设置生效。
在您的情况下,如果您运行步骤 4(b),此扩展程序将无法将语言 ID 本身设置为某些语言(例如form. 在这种情况下,将出现一个输入框,供您输入语言标识符(对于这些文件类型,它显示在 vscode 窗口的右下角)。在您的情况下,输入“表单”Enter进行确认,您应该已准备就绪。
| 归档时间: |
|
| 查看次数: |
2557 次 |
| 最近记录: |