Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a keybind to quickly run C# in VSCode?

I am attempting to learn C#, and found the standard Ctrl+Alt+N does not work, and the tutorials online regarding building C# projects all seem to only mention using the command line with dotnet run. I have no problem with the command line, but it would greatly help my workflow if I didn't have to switch to mouse or trackpad to click the terminal and then back again.

like image 427
Seraphendipity Avatar asked Oct 19 '25 07:10

Seraphendipity


2 Answers

From the VS Code extensions Marketplace download and install the "terminal-command-keys" (by Pete Kinnecom) extension.

Open "keybindings.json" file (View > Command Palette > search for: " >preferences:Open Keyboard Shortcuts (JSON)"

In "keybindings.json" file put the following code inside the brackets "[]" :

{
    "key": "cmd+3",
    "command":"terminalCommandKeys.run",
    "args":{
        "cmd": "dotnet run"
    }

}

Save your "keybindings.json" file. (I have assigned "cmd + 3" key combination to "dotnet run" command. Use your own favorite key combination!

Notes:

  1. There is no space between cmd and + and 3 in the code.
  2. Pay attention to letter case of "terminalCommandKeys.run".
  3. Just to be sure, restart VS Code.

Source: Medium: Francis Mendez

like image 116
Nader Avatar answered Oct 20 '25 21:10

Nader


Not sure about VSCode, but in normal VS build is Shift+Ctrl+B

like image 40
JBatz Avatar answered Oct 20 '25 21:10

JBatz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!