2023/05/26
Using the VSCode extension "Code Runner"
"Code Runner" is an extension that makes it easy to run programs.
- Execute programs with a single click.
- Partial execution of only selected parts is possible.
- It can be executed in almost any language.
Code Runner - Visual Studio Marketplace
Extension for Visual Studio Code - Run C, C++, Java, JS, PHP, Python, Perl, Ruby, Go, Lua, Groovy, PowerShell, CMD, BASH, F#, C#, VBScript, TypeScript, CoffeeScript, Scala, Swift, Julia, Crystal, OCaml, R, AppleScript, Elixir, VB.NET, Clojure, Haxe, Obj-C, Rust, Racket, Scheme, AutoHotkey, AutoIt, Kotlin, Dart, Pascal, Haskell, Nim,
How to use
There are 3 ways to execute the program:
- Press CTRL + ALT + N.
- Click the play button (▶) in the top right corner.
- Right-click and select "Run Code".
If nothing is selected, the entire code will be executed.
If selected, only the selected code will be executed.
Setting
Here is the recommended settings.
The settings can be accessed through configuration page.
code-runner.executorMap
You can configure the execution commands for each language.
By default, Python does not support execution within a virtual environment.
Therefore, the settings for Python should be as follows:
"code-runner.executorMap":
{
"python" : "$pythonPath -u $fullFileName"
},
code-runner.runInTerminal
You can configure whether to execute programs in the terminal or not.
By default, it is set to false (not using the terminal).
If you need to use features like standard input, set it to true.
"code-runner.runInTerminal": true