在 Mac 上的 VS Code 中调试快捷方式

cer*_*rou 3 mac visual-studio-code

我在 Linux 机器上使用 VS Code,我发现它是一个很棒的工具。但是,在 Mac(MacBook Pro)上,我在调试模式下遇到了一些问题。MacBook 将 F 键用于其自身目的(更改亮度、音量等)。然后为了使用,例如F5(继续)或F10(跳过),我必须按fn+F5或fn+F10,这是相当麻烦的。有没有一种方法可以使快捷键起作用,以便只将一个键分配给调试功能(最好是 F 键)?

han*_*xue 5

You have two options here, changing the settings for the Function keys to standard function keys, or re-bind the keyboard shortcut for Debug functionalities in VS Code.

Use F1, F2, etc as standard function keys

In MacOS,

  1. Go to System Preferences
  2. Click on Keyboard
  3. Go to the Keyboard tab
  4. Tick the option that says Use all F1, F2, etc. keys as standard function keys

Mac 上的功能键

Re-map the Debug key

VS Code keybindings.json 文件中,添加以下行。将键盘快捷键更改为您喜欢的任何内容

{
    "key": "ctrl+cmd+s",
    "command": "workbench.action.debug.stop",
    "when": "inDebugMode"
  },
  {
    "key": "ctrl+cmd+s",
    "command": "workbench.action.debug.stepOver",
    "when": "inDebugMode"
  },
Run Code Online (Sandbox Code Playgroud)