blog.atwork.at

news and know-how about microsoft, technology, cloud and more.

Use Visual Studio Code and the Code Runner extension

Visual Studio Code (currently, Version 1.22 is available) is a very cool developer tool providing a modern and fast code editor with a bunch of extensions. With extensions as Code-Runner, it's easy to run a code file or active text directly from the VS Code text editor. Check out this quick description how to configure and use Code Runner.

If you are new to VS Code, at a glance: To install the latest version of VS Code, get the download for Windows, Linux or macOS. To run a command, launch the Command Palette with F1 or Ctrl + Shift + P, run Quick Open by pressing Ctrl + P, etc. See all keyboard shortcuts at Windows, macOS and Linux.

As described in the Code-Runner marketplace description, the configuration must know, where to find the runtime executor. To set the executor path for the most common programming languages on your computer, check File / Preferences / Settings and open the Workspace Settings tab as shown here (see more at User and Workspace Settings). Paste the path to each programming language in here (see below) and press Ctrl + S to save the new settings.

image

Of course, the programming languages must be installed on your computer. When working with command line tools, it's also a good idea to add them to the environment PATH to make them available in every directory. Adapt the executor map as needed for your environment. Here's the sample from Code-Runner (usually you do not need to modify):

{
     "code-runner.executorMap": {
         "javascript": "node",
         "php": "C:\\php\\php.exe",
         "python": "python",
         "perl": "perl",
         "ruby": "C:\\Ruby23-x64\\bin\\ruby.exe",
         "go": "go run",
         "html": "\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\"",
         "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
         "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
     }
}

Press Ctrl + Alt + N (or click the Play Button on the top right corner or press F1 and then select/type Run Code) to run a code file with the configured program. As shown below, press Ctrl + Alt + M to stop the code run mode.

image

So, Visual Studio Code and extensions as Code-Runner are great tools for development on all OS platforms. If you are coming from Visual Studio and you are used to run ASP.NET apps with the integrated IIS, there are more extensions available as I wrote some time ago here.

There are so many resources out how to use VS Code, just to name a few:

Happy developing with Visual Studio Code (and extensions)!

Comments (2) -

  • Toni Pohl

    6/3/2018 11:37:33 AM |

    See also this step-by-step article by Mike Robbins about "How to install Visual Studio Code and configure it as a replacement for the PowerShell ISE":
    mikefrobbins.com/.../

Pingbacks and trackbacks (1)+

Loading