Is there a way to format my c++ code using one key ";" in Visual Studio Code

huangapple go评论75阅读模式
英文:

Is there a way to format my c++ code using one key ";" in Visual Studio Code

问题

我想在我的代码行以 ; 结束时格式化我的代码,就像在Visual Studio中一样。
我尝试为 ; 创建一个快捷键绑定以保存文件,但我无法再次在我的代码中写入 ;
有没有一种方法可以做到这一点?

这是我用于 ; 键的 JSON 设置。

{
    "key": ";",
    "command": "editor.action.file.save"
}
英文:

I want to format my code when I end my line of code with ;, like in Visual studio.
I tried to make a hotkey binding for the ; to save the file but I couldn't writ the ; in my code again?
Is there a way to do that?

This is my json settings for the ; key.

    {
        "key": ";",
        "command": "editor.action.file.save"
    }

答案1

得分: 2

Sure, here is the translated content:

使用type命令

{
  "key": ";",
  "command": "runCommands",
  "args": {
    "commands": [
      { "command": "type",
        "args": { "text": ";" }
      },
      "editor.action.file.save"
    ]
  },
  "when": "editorTextFocus"
}
英文:

use the type command

{
  "key": ";",
  "command": "runCommands",
  "args": {
    "commands": [
      { "command": "type",
        "args": { "text": ";" }
      },
      "editor.action.file.save"
    ]
  },
  "when": "editorTextFocus"
}

huangapple
  • 本文由 发表于 2023年6月8日 23:05:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76433238.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定