Chuyển tới nội dung
Home » Hello World Visual Studio Code | Add A Custom Command

Hello World Visual Studio Code | Add A Custom Command

How to print Hello World  using Visual Studio code | C programming


Installing VS Code and extensions

  1. If you haven’t already done so, install VS Code.
  2. Next, install C# Dev Kit from the Visual Studio Marketplace. For additional details on installing extensions, read Extension Marketplace. The C# extension is called C# Dev Kit and it’s published by Microsoft.

Note: C# Dev Kit supports cloud native development. To do cross-platform mobile and desktop development, you can use C# Dev Kit with the .NET MAUI extension. Learn how to get set up with .NET MAUI in VS Code.

Upon installation, C# Dev Kit launches an extension walkthrough. You can follow the steps of this walkthrough to learn more about the features of the C# extension. Reopen the walkthrough at any time by opening the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)) and selecting Welcome: Open Walkthrough. Here, select Get Started with C# Dev Kit.

Note: You are required to sign in to a Visual Studio subscription to use C# Dev Kit. Check out the Signing in to C# Dev Kit documentation to learn more.

Installing the .NET Coding Pack for students

If you’re a student, we recommend installing the .NET Coding Pack for an easier setup experience. The Coding Pack includes VS Code, the .NET SDK, and essential .NET extensions. The Coding Pack can be used as a clean installation, or to update or repair an existing development environment.

Install the .NET Coding Pack – Windows

Install the .NET Coding Pack – macOS

Note: The .NET Coding Pack is only available for Windows and macOS. For other operating systems, you need to manually install the .NET SDK, VS Code, and .NET extensions.

Next Steps

In this walkthrough, we’ve seen a very simple extension. For a more detailed example, see the Word Count Example which shows how to target a specific language (Markdown) and listen to the editor’s document changed events.

If you’d like to read more generally about the extension APIs, try these topics:

  • Extension API Overview – Learn about the full VS Code extensibility model.
  • API Patterns and Principles – VS Code extensibility is based on several guiding patterns and principles.
  • Contribution Points – Details about the various VS Code contribution points.
  • Activation Events – VS Code activation events reference
How to print Hello World  using Visual Studio code | C programming
How to print Hello World using Visual Studio code | C programming

Configure and run the debugger

Let’s now try debugging our Python program. Debugging support is provided by the Python Debugger extension, which is automatically installed with the Python extension. To ensure it has been installed correctly, open the Extensions view (⇧⌘X (Windows, Linux Ctrl+Shift+X)) and search for

@installed python debugger

. You should see the Python Debugger extension listed in the results.

Next, set a breakpoint on line 2 of

by placing the cursor on the

Next, to initialize the debugger, press F5. Since this is your first time debugging this file, a configuration menu will open from the Command Palette allowing you to select the type of debug configuration you would like for the opened file.

Note: VS Code uses JSON files for all of its various configurations;


is the standard name for a file containing debugging configurations.

Select Python File, which is the configuration that runs the current file shown in the editor using the currently selected Python interpreter.

The debugger will start, and then stop at the first line of the file breakpoint. The current line is indicated with a yellow arrow in the left margin. If you examine the Local variables window at this point, you can see that the


variable appears in the Local pane.

A debug toolbar appears along the top with the following commands from left to right: continue (F5), step over (F10), step into (F11), step out (⇧F11 (Windows, Linux Shift+F11)), restart (⇧⌘F5 (Windows, Linux Ctrl+Shift+F5)), and stop (⇧F5 (Windows, Linux Shift+F5)).

The Status Bar also changes color (orange in many themes) to indicate that you’re in debug mode. The Python Debug Console also appears automatically in the lower right panel to show the commands being run, along with the program output.

To continue running the program, select the continue command on the debug toolbar (F5). The debugger runs the program to the end.

Tip Debugging information can also be seen by hovering over code, such as variables. In the case of


, hovering over the variable will display the string

Roll a dice!

in a box above the variable.

You can also work with variables in the Debug Console (If you don’t see it, select Debug Console in the lower right area of VS Code, or select it from the … menu.) Then try entering the following lines, one by one, at the > prompt at the bottom of the console:

msg msg.capitalize() msg.split()

Select the blue Continue button on the toolbar again (or press F5) to run the program to completion. “Roll a dice!” appears in the Python Debug Console if you switch back to it, and VS Code exits debugging mode once the program is complete.

If you restart the debugger, the debugger again stops on the first breakpoint.

To stop running a program before it’s complete, use the red square stop button on the debug toolbar (⇧F5 (Windows, Linux Shift+F5)), or use the Run > Stop debugging menu command.

For full details, see Debugging configurations, which includes notes on how to use a specific Python interpreter for debugging.

Tip: Use Logpoints instead of print statements: Developers often litter source code with

Create a Python source code file

From the File Explorer toolbar, select the New File button on the



Name the file

, and VS Code will automatically open it in the editor:

By using the


file extension, you tell VS Code to interpret this file as a Python program, so that it evaluates the contents with the Python extension and the selected interpreter.

Note: The File Explorer toolbar also allows you to create folders within your workspace to better organize your code. You can use the New folder button to quickly create a folder.

Now that you have a code file in your Workspace, enter the following source code in


msg = "Roll a dice" print(msg)

When you start typing

IntelliSense and auto-completions work for standard Python modules as well as other packages you’ve installed into the environment of the selected Python interpreter. It also provides completions for methods available on object types. For example, because the


variable contains a string, IntelliSense provides string methods when you type



Finally, save the file (⌘S (Windows, Linux Ctrl+S)). At this point, you’re ready to run your first Python file in VS Code.

For full details on editing, formatting, and refactoring, see Editing code. The Python extension also has full support for Linting.

Hello World in Java using Visual Studio Code
Hello World in Java using Visual Studio Code

Next steps

To learn how to build web apps with popular Python web frameworks, see the following tutorials:

There is then much more to explore with Python in Visual Studio Code:

  • Python profile template – Create a new profile with a curated set of extensions, settings, and snippets
  • Editing code – Learn about autocomplete, IntelliSense, formatting, and refactoring for Python.
  • Linting – Enable, configure, and apply a variety of Python linters.
  • Debugging – Learn to debug Python both locally and remotely.
  • Testing – Configure test environments and discover, run, and debug tests.
  • Settings reference – Explore the full range of Python-related settings in VS Code.
  • Deploy Python to Azure App Service
  • Deploy Python to Container Apps

Your First Extension

In this topic, we’ll teach you the fundamental concepts for building extensions. Make sure you have Node.js and Git installed.

First, use Yeoman and VS Code Extension Generator to scaffold a TypeScript or JavaScript project ready for development.

  • If you do not want to install Yeoman for later use, run the following command:

    npx --package yo --package generator-code -- yo code

  • If you instead want to install Yeoman globally to ease running it repeatedly, run the following command:

    npm install --global yo generator-code yo code

For a TypeScript project, fill out the following fields:

# ? What type of extension do you want to create? New Extension (TypeScript) # ? What's the name of your extension? HelloWorld ### Press

to choose default for all options below ### # ? What's the identifier of your extension? helloworld # ? What's the description of your extension? LEAVE BLANK # ? Initialize a git repository? Yes # ? Bundle the source code with webpack? No # ? Which package manager to use? npm # ? Do you want to open the new folder with Visual Studio Code? Open with `code`

Inside the editor, open


and press F5. This will compile and run the extension in a new Extension Development Host window.

Run the Hello World command from the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)) in the new window:

You should see the

Hello World from HelloWorld!

notification showing up. Success!

Start VS Code in a workspace folder

By starting VS Code in a folder, that folder becomes your “workspace”.

Using a command prompt or terminal, create an empty folder called “hello”, navigate into it, and open VS Code (


) in that folder () by entering the following commands:

mkdir hello cd hello code .

Note: If you’re using an Anaconda distribution, be sure to use an Anaconda command prompt.

Alternately, you can create a folder through the operating system UI, then use VS Code’s File > Open Folder to open the project folder.

Cách code c/c++ bài 1: Hello World trên visual studio code.
Cách code c/c++ bài 1: Hello World trên visual studio code.

Install and use packages

Let’s build upon the previous example by using packages.

In Python, packages are how you obtain any number of useful code libraries, typically from PyPI, that provide additional functionality to your program. For this example, you use the


package to generate a random number.

Return to the Explorer view (the top-most icon on the left side, which shows files), open

, and paste in the following source code:

import numpy as np msg = "Roll a dice" print(msg) print(np.random.randint(1,9))

Tip: If you enter the above code by hand, you may find that auto-completions change the names after the


keywords when you press Enter at the end of a line. To avoid this, type a space, then Enter.

Next, run the file in the debugger using the “Python: Current file” configuration as described in the last section.

You should see the message, “ModuleNotFoundError: No module named ‘numpy'”. This message indicates that the required package isn’t available in your interpreter. If you’re using an Anaconda distribution or have previously installed the


package you may not see this message.

To install the


package, stop the debugger and use the Command Palette to run Terminal: Create New Terminal (⌃⇧` (Windows, Linux Ctrl+Shift+`)). This command opens a command prompt for your selected interpreter.

To install the required packages in your virtual environment, enter the following commands as appropriate for your operating system:

  1. Install the packages

    # Don't use with Anaconda distributions because they include matplotlib already. # macOS python3 -m pip install numpy # Windows (may require elevation) py -m pip install numpy # Linux (Debian) apt-get install python3-tk python3 -m pip install numpy

  2. Now, rerun the program, with or without the debugger, to view the output!

Congrats on completing the Python tutorial! During the course of this tutorial, you learned how to create a Python project, create a virtual environment, run and debug your Python code, and install Python packages. Explore additional resources to learn how to get the most out of Python in Visual Studio Code!

Join the community

Find community resources and connect with user groups.

.NET developer community – Meet with like-minded developers

Tutorial – Create your first extension: Hello World

This Hello World example walks you through creating your first extension for Visual Studio. This tutorial shows you how to add a new command to Visual Studio.

In the process, you learn how to:

For this example, you use Visual C# to add a custom menu button named “Say Hello World!” that looks like this:


This article applies to Visual Studio on Windows. For Visual Studio for Mac, see Extensibility walkthrough in Visual Studio for Mac.

Install VSCode and run C# Hello World
Install VSCode and run C# Hello World

C/C++ for Visual Studio Code

C/C++ support for Visual Studio Code is provided by a Microsoft C/C++ extension to enable cross-platform C and C++ development on Windows, Linux, and macOS. When you create a


file, the extension adds features such as syntax highlighting (colorization), smart completions and hovers (IntelliSense), and error checking.

Developing the extension

Let’s make a change to the message:

  1. Change the message from “Hello World from HelloWorld!” to “Hello VS Code” in


  2. Run Developer: Reload Window in the new window.
  3. Run the command Hello World again.

You should see the updated message showing up.

Here are some ideas for things for you to try:

  • Give the Hello World command a new name in the Command Palette.
  • Contribute another command that displays current time in an information message. Contribution points are static declarations you make in the


    Extension Manifest to extend VS Code, such as adding commands, menus, or keybindings to your extension.
  • Replace the


    with another VS Code API call to show a warning message.
Python - print(\
Python – print(\”Hello World\”) in VSCode

Run Python code

Click the Run Python File in Terminal play button in the top-right side of the editor.

The button opens a terminal panel in which your Python interpreter is automatically activated, then runs


(macOS/Linux) or



There are three other ways you can run Python code within VS Code:

  1. Right-click anywhere in the editor window and select Run > Python File in Terminal (which saves the file automatically):

  2. Select one or more lines, then press Shift+Enter or right-click and select Run Selection/Line in Python Terminal. This command is convenient for testing just a part of a file.

  3. From the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)), select the Python: Start REPL command to open a REPL terminal for the currently selected Python interpreter. In the REPL, you can then enter and run lines of code one at a time.

Congrats, you just ran your first Python code in Visual Studio Code!

Enhance completions with AI

GitHub Copilot is an AI-powered code completion tool that helps you write code faster and smarter. You can use the GitHub Copilot extension in VS Code to generate code, or to learn from the code it generates.

GitHub Copilot provides suggestions for numerous languages and a wide variety of frameworks, and it works especially well for Python, JavaScript, TypeScript, Ruby, Go, C# and C++.

You can learn more about how to get started with Copilot in the Copilot documentation.

C++ Hello World in Visual Studio Code
C++ Hello World in Visual Studio Code

Debugging your Extension

Simply set a breakpoint, for example inside the registered command and run the

"Hello world"

command in the Extension Development VS Code instance.

Note: For TypeScript extensions, even though VS Code loads and executes


, you are actually able to debug the original TypeScript code due to the generated source map


and VS Code’s debugger support for source maps.

Tip: The Debug Console will show all the messages you log to the console.

To learn more about the extension development environment.

Open folder

By starting VS Code in a folder, that folder becomes your “workspace”. VS Code stores settings that are specific to that workspace in


, which are separate from user settings that are stored globally.

Using a terminal, create an empty folder called “hello”, navigate into it, and open VS Code (code) in that folder (.) by entering the following commands:

mkdir hello cd hello code .

Alternatively, you can run VS Code through the operating system UI, then use File > Open Folder to open the project folder.

VSCode Tutorial: How to Create your first web page in Visual Studio Code - Hello World
VSCode Tutorial: How to Create your first web page in Visual Studio Code – Hello World

Next steps

Now that you know the basics of working with Visual Studio Extensibility, here’s where you can learn more:

  • Start to develop Visual Studio extensions – Samples, tutorials. and publishing your extension
  • What’s new in the Visual Studio 2017 SDK – New extensibility features in Visual Studio 2017
  • What’s new in the Visual Studio 2019 SDK – New extensibility features in Visual Studio 2019
  • Inside the Visual Studio SDK – Learn the details of Visual Studio Extensibility

Getting Started with Python in VS Code

In this tutorial, you will learn how to use Python 3 in Visual Studio Code to create, run, and debug a Python “Roll a dice” application, work with virtual environments, use packages, and more! By using the Python extension, you turn VS Code into a great, lightweight Python editor.

If you are new to programming, check out the Visual Studio Code for Education – Introduction to Python course. This course offers a comprehensive introduction to Python, featuring structured modules in a ready-to-code browser-based development environment.

To gain a deeper understanding of the Python language, you can explore any of the programming tutorials listed on within the context of VS Code.

For a Data Science focused tutorial with Python, check out our Data Science section.

Add a custom command

  1. If you select the


    manifest file, you can see what options are changeable, such as description, author, and version.

  2. Right-click the project (not the solution). On the context menu, select Add, and then New Item.

  3. Select the Extensibility section, and then choose Command.

  4. In the Name field at the bottom, enter a filename such as Command.cs.

Your new command file is visible in Solution Explorer. Under the Resources node, you can find other files related to your command. For example, if you wish to modify the image, the PNG file is here.

How to Set up Visual Studio Code for C and C++ Programming
How to Set up Visual Studio Code for C and C++ Programming

Set up your C++ Environment

C++ is a compiled language meaning your program’s source code must be translated (compiled) before it can be run on your computer. The C/C++ extension doesn’t include a C++ compiler or debugger, since VS Code as an editor relies on command-line tools for the development workflow. You need to install these tools or use the tools already installed on your computer.

Check if you have a compiler installed

Note: There may already be a C++ compiler and debugger provided by your academic or work development environment. Check with your instructors or colleagues for guidance on installing the recommended C++ toolset (compiler, debugger, project system, linter).

Common compilers that already come preinstalled on some platforms are the GNU Compiler Collection (GCC) on Linux and the Clang tools with Xcode on macOS.

To check if you already have them installed:

  1. Open a new VS Code terminal window using (⌃⇧` (Windows, Linux Ctrl+Shift+`))

  2. Use the following command to check for the GCC compiler



    g++ --version

    Or this command for the Clang compiler



    clang --version

The output should show you the compiler version and details. If neither are found, make sure your compiler executable is in your platform path (


on Windows,


on Linux and macOS) so that the C/C++ extension can find it. Otherwise, use the instructions in the section below to install a compiler.

Install a compiler

If you don’t have a compiler installed, you can follow one of our installation tutorials:




Note: If you would prefer a full Integrated Development Environment (IDE), with built-in compilation, debugging, and project templates (File > New Project), there are many options available, such as the Visual Studio Community edition.

Create a Hello World App

To make sure the compiler is installed and configured correctly, lets create a Hello World C++ program.

Create a C++ file

  1. On Windows, launch a Windows command prompt (Enter Windows command prompt in the Windows search bar). On macOS and Linux, you can enter these commands in the terminal.
  2. Run the following commands. They are creating an empty folder called


    where you can place all your VS Code projects. The next commands create and navigate you to a subfolder called


    . From there, you are opening


    directly in VS Code using the



mkdir projects cd projects mkdir helloworld cd helloworld code .

The “code .” command opens VS Code in the current working folder, which becomes your “workspace”. Accept the Workspace Trust dialog by selecting Yes, I trust the authors since this is a folder you created.

Now create a new file called


with the New File button in the File Explorer or File > New File command.

Add Hello World source code

Paste in the following source code:


int main() { std::cout << "Hello World" << std::endl; }

Now press ⌘S (Windows, Linux Ctrl+S) to save the file. You can also enable AutoSave to automatically save your file changes, by checking Auto Save in the main File menu.

Goodbye VS Code
Goodbye VS Code

Install a Python interpreter

Along with the Python extension, you need to install a Python interpreter. Which interpreter you use is dependent on your specific needs, but some guidance is provided below.


Install Python from Use the Download Python button that appears first on the page to download the latest version.

Note: If you don’t have admin access, an additional option for installing Python on Windows is to use the Microsoft Store. The Microsoft Store provides installs of supported Python versions.

For additional information about using Python on Windows, see Using Python on Windows at


The system install of Python on macOS is not supported. Instead, a package management system like Homebrew is recommended. To install Python using Homebrew on macOS use

brew install python3

at the Terminal prompt.

Note: On macOS, make sure the location of your VS Code installation is included in your PATH environment variable. See these setup instructions for more information.


The built-in Python 3 installation on Linux works well, but to install other Python packages you must install



Other options

  • Data Science: If your primary purpose for using Python is Data Science, then you might consider a download from Anaconda. Anaconda provides not just a Python interpreter, but many useful libraries and tools for data science.

  • Windows Subsystem for Linux: If you are working on Windows and want a Linux environment for working with Python, the Windows Subsystem for Linux (WSL) is an option for you. If you choose this option, you’ll also want to install the WSL extension. For more information about using WSL with VS Code, see VS Code Remote Development or try the Working in WSL tutorial, which will walk you through setting up WSL, installing Python, and creating a Hello World application running in WSL.

Note: To verify that you’ve installed Python successfully on your machine, run one of the following commands (depending on your operating system):

Linux/macOS: open a Terminal Window and type the following command:

python3 --version

Windows: open a command prompt and run the following command:

py -3 --version

If the installation was successful, the output window should show the version of Python that you installed. Alternatively, you can use the

py -0

command in the VS Code integrated terminal to view the versions of python installed on your machine. The default interpreter is identified by an asterisk (*).

Run it

You can now run the source code in the Visual Studio Experimental Instance.

Step 1. Press F5 to run the Start Debugging command. This command builds your project and starts the debugger, launching a new instance of Visual Studio called the Experimental Instance.

Step 2. On the Tools menu of the Experimental Instance, click Say Hello World!.

You should see the output from your new custom command, in this case, the dialog in the center of the screen that gives you the Hello World! message.

Hướng dẫn cài đặt Java và môi trường trong Visual Studio Code
Hướng dẫn cài đặt Java và môi trường trong Visual Studio Code

Next steps

In the next topic, Extension Anatomy, we’ll take a closer look at the source code of the

Hello World

sample and explain key concepts.

You can find the source code of this tutorial at: The Extension Guides topic contains other samples, each illustrating a different VS Code API or Contribution Point, and following the recommendations in our UX Guidelines.

Using JavaScript

In this guide, we mainly describe how to develop VS Code extension with TypeScript because we believe TypeScript offers the best experience for developing VS Code extensions. However, if you prefer JavaScript, you can still follow along using helloworld-minimal-sample.

UX Guidelines

This is also a good time to review our UX Guidelines so you can start designing your extension user interface to follow the VS Code best practices.

Example – Hello World

Your First Extension

This document will take you through creating your first VS Code extension (“Hello World”) and will explain the basic VS Code extensibility concepts.

In this walkthrough, you’ll add a new command to VS Code which will display a simple “Hello World” message. Later in the walkthrough, you’ll interact with the VS Code editor and query for the user’s currently selected text.


The Structure of an Extension

After running, the generated extension should have the following structure:

. ├── .gitignore ├── .vscode // VS Code integration │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── .vscodeignore ├── ├── src // sources │ └── extension.ts // extension.js, in case of JavaScript extension ├── test // tests folder │ ├── extension.test.ts // extension.test.js, in case of JavaScript extension │ └── index.ts // index.js, in case of JavaScript extension ├── node_modules │ ├── vscode // language services │ └── typescript // compiler for typescript (TypeScript only) ├── out // compilation output (TypeScript only) │ ├── src │ | ├── extension.js │ | └── │ └── test │ ├── extension.test.js │ ├── │ ├── index.js │ └── ├── package.json // extension's manifest ├── tsconfig.json // jsconfig.json, in case of JavaScript extension ├── typings // type definition files │ ├── node.d.ts // link to Node.js APIs │ └── vscode-typings.d.ts // link to VS Code APIs └── // extension development quick start

Let’s go through the purpose of all these files and explain what they do:

The extension manifest: package.json

  • Please read the


    extension manifest reference
  • More information on


    contribution points
  • Each VS Code extension must have a


    file that describes it and its capabilities.
  • VS Code reads this file during start-up and reacts to each


    section immediately.
Example TypeScript extension manifest

{ "name": "myFirstExtension", "description": "", "version": "0.0.1", "publisher": "", "engines": { "vscode": "^0.10.1" }, "categories": [ "Other" ], "activationEvents": [ "onCommand:extension.sayHello" ], "main": "./out/src/extension", "contributes": { "commands": [{ "command": "extension.sayHello", "title": "Hello World" }] }, "scripts": { "vscode:prepublish": "node ./node_modules/vscode/bin/compile", "compile": "node ./node_modules/vscode/bin/compile -watch -p ./" }, "devDependencies": { "typescript": "^1.6.2", "vscode": "0.10.x" } }

Note: A JavaScript extension doesn’t require the


field as no compilation is needed.

  • This specific package.json describes an extension that:
  • contributes an entry to the Command Palette (


    ) with the label

    "Hello world"

    that will invoke a command


  • requests to get loaded (activationEvents) when the command


    is invoked.
  • has its main JavaScript code in a file called



Note: VS Code does not load the code of an extension eagerly at start-up. An extension must describe, through the


property under what conditions it should get activated (loaded).


The generated extension’s code is in




in case of a JavaScript extension):

// The module 'vscode' contains the VS Code extensibility API // Import the module and reference it with the alias vscode in your code below import * as vscode from 'vscode'; // this method is called when your extension is activated // your extension is activated the very first time the command is executed export function activate(context: vscode.ExtensionContext) { // Use the console to output diagnostic information (console.log) and errors (console.error) // This line of code will only be executed once when your extension is activated console.log('Congratulations, your extension "my-first-extension" is now active!'); // The command has been defined in the package.json file // Now provide the implementation of the command with registerCommand // The commandId parameter must match the command field in package.json var disposable = vscode.commands.registerCommand('extension.sayHello', () => { // The code you place here will be executed every time your command is executed // Display a message box to the user vscode.window.showInformationMessage('Hello World!'); }); context.subscriptions.push(disposable); }

  • Each extension should export from its main file a function named


    , which VS Code will invoke only once when any of the


    described in the


    file occur.
  • This specific extension imports the


    API and then registers a command, associating a function to be called when the command


    gets invoked. The command’s implementation displays a “Hello world” message in VS Code.

Note: The


section of the


adds an entry to the Command Palette. The code in extension.ts/.js defines the implementation of



Note: For TypeScript extensions, the generated file


will be loaded at runtime and executed by VS Code.

Miscellaneous files

  • .vscode/launch.json

    defines launching VS Code in the Extension Development mode. It also points with


    to a task defined in


    that runs the TypeScript compiler.

  • .vscode/settings.json

    by default excludes the


    folder. You can modify which file types you want to hide.

  • .gitignore

    – Tells Git version control which patterns to ignore.

  • .vscodeignore

    – Tells the packaging tool which files to ignore when publishing the extension.


    – README file describing your extension for VS Code users.


    – A Quick Start guide for you.

  • test/extension.test.ts

    – you can put your extension unit tests in here and run your tests against the VS Code API (see Testing Your Extension)

Run helloworld.cpp

  1. Make sure you have


    open so it is the active file in your editor.

  2. Press the play button in the top right corner of the editor.

  3. Choose C/C++: g++.exe build and debug active file from the list of detected compilers on your system.

You are only prompted to choose a compiler the first time you run


. This compiler becomes “default” compiler set in your



  1. After the build succeeds, you should see “Hello World” appear in the integrated Terminal.

Congratulations! You’ve just run your first C++ program in VS Code! The next step is to learn more about the Microsoft C/C++ extension’s language features such as IntelliSense, code navigation, build configuration, and debugging using one of the Tutorials in the next section.

Best VSCode Extensions I'm in Love with
Best VSCode Extensions I’m in Love with

Example: Install MinGW-x64 on Windows

To understand the process, let’s install Mingw-w64 via MSYS2. Mingw-w64 is a popular, free toolset on Windows. It provides up-to-date native builds of GCC, Mingw-w64, and other helpful C++ tools and libraries.

  1. Download using this direct link to the MinGW installer.

  2. Run the installer and follow the steps of the installation wizard. Note, MSYS2 requires 64 bit Windows 8.1 or newer.

  3. In the wizard, choose your desired Installation Folder. Record this directory for later. In most cases, the recommended directory is acceptable. The same applies when you get to setting the start menu shortcuts step. When complete, ensure the Run MSYS2 now box is checked and select Finish. A MSYS2 terminal window will then automatically open.

  4. In this terminal, install the MinGW-w64 toolchain by running the following command:

    pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain

  5. Accept the default number of packages in the


    group by pressing Enter.

  6. Enter

    when prompted whether to proceed with the installation.

  7. Add the path to your MinGW-w64


    folder to the Windows


    environment variable by using the following steps:

    1. In the Windows search bar, type Settings to open your Windows Settings.
    2. Search for Edit environment variables for your account.
    3. In your User variables, select the


      variable and then select Edit.
    4. Select New and add the MinGW-w64 destination folder you recorded during the installation process to the list. If you selected the default installation steps, the path is:


    5. Select OK to save the updated PATH. For the new


      to be available, reopen your console windows.
  8. Check that your MinGW-w64 tools are correctly installed and available, open a new Command Prompt and type:

gcc --version g++ --version gdb --version

You should see output that states which versions of GCC, g++ and GDB you have installed. If this is not the case, make sure your PATH entry matches the Mingw-w64 binary location where the compiler tools are located or reference the troubleshooting section.


If you run into any issues or have suggestions for the Microsoft C/C++ extension, please file issues and suggestions on GitHub. If you haven’t already provided feedback, you can take this quick survey.

Getting Started with C# in VS Code

This getting started guide introduces you to C# and .NET for Visual Studio Code through the following tasks:

  1. Installing and setting up your VS Code environment for C#.
  2. Writing and running a simple “Hello World” application using C#.
  3. Introduce you to other learning resources for C# in VS Code.

Keep in mind, that this guide won’t teach you C#. Instead, it teaches you how to get set up for C# development in VS Code. If you’re looking for resources to learn C#, check out our C# curriculum.

Create Your First Java Project using Visual Studio Code 2021 and Java JDK 17
Create Your First Java Project using Visual Studio Code 2021 and Java JDK 17

Installing your Extension Locally

So far, the extension you have written only runs in a special instance of VS Code, the Extension Development instance. To get your extension running in all instances of VS Code, you need to copy it to a new folder under your local extensions folder:

  • Windows:

  • Mac/Linux:


Generate a New Extension

The simplest way to add your own functionality to VS Code is through adding a command. A command is registers a callback function which can be invoked from the Command Palette or with a key binding.

We have written a Yeoman generator to help get you started. Install Yeoman and the Yeoman VS Code Extension generator and scaffold a new extension:

npm install -g yo generator-code yo code

For the hello world extension, you can either create a TypeScript extension or a JavaScript one. For this example, we pick a TypeScript extension.

Hello World in different programming languages #programming #memes
Hello World in different programming languages #programming #memes

Running your Extension

Now that the roles of the files included in the extension are clarified, here is how your extension gets activated:

  • The extension development instance discovers the extension and reads its


  • Later when you press


  • The registered commands are displayed in the Command Palette.
  • In this list there is now an entry

    "Hello world"

    that is defined in the


  • When selecting the

    "Hello world"

  • The command


    is invoked:
  • An activation event


    is created.
  • All extensions listing this activation event in their


    are activated.

    • The file at


      gets loaded in the JavaScript VM.
    • VS Code looks for an exported function


      and calls it.
    • The command


      is registered and its implementation is now defined.
  • The file at
  • The command


    implementation function is invoked.
  • The command implementation displays the “Hello World” message.

Create a virtual environment

A best practice among Python developers is to use a project-specific

virtual environment

. Once you activate that environment, any packages you then install are isolated from other environments, including the global interpreter environment, reducing many complications that can arise from conflicting package versions. You can create non-global environments in VS Code using Venv or Anaconda with Python: Create Environment.

Open the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)), start typing the Python: Create Environment command to search, and then select the command.

The command presents a list of environment types, Venv or Conda. For this example, select Venv.

The command then presents a list of interpreters that can be used for your project. Select the interpreter you installed at the beginning of the tutorial.

After selecting the interpreter, a notification will show the progress of the environment creation and the environment folder (


) will appear in your workspace.

Ensure your new environment is selected by using the Python: Select Interpreter command from the Command Palette.

Note: For additional information about virtual environments, or if you run into an error in the environment creation process, see Environments.

Learn Visual Studio Code - Course for Beginners
Learn Visual Studio Code – Course for Beginners

Debugging the extension

VS Code’s built-in debugging functionality makes it easy to debug extensions. Set a breakpoint by clicking the gutter next to a line, and VS Code will hit the breakpoint. You can hover over variables in the editor or use the Run and Debug view in the left to check a variable’s value. The Debug Console allows you to evaluate expressions.

You can learn more about debugging Node.js apps in VS Code in the Node.js Debugging Topic.

Remote Development

VS Code and the C++ extension support Remote Development allowing you to work over SSH on a remote machine or VM, inside a Docker container, or in the Windows Subsystem for Linux (WSL).

To install support for Remote Development:

  1. Install the VS Code Remote Development Extension Pack.
  2. If the remote source files are hosted in WSL, use the WSL extension.
  3. If you are connecting to a remote machine with SSH, use the Remote – SSH extension.
  4. If the remote source files are hosted in a container (for example, Docker), use the Dev Containers extension.
How to Run C# in VSCode (Compile, Debug, and Create a Project)
How to Run C# in VSCode (Compile, Debug, and Create a Project)

A Simple Change





, in a JavaScript extension), try replacing the


command implementation to show the number of characters selected in the editor:

var editor = vscode.window.activeTextEditor; if (!editor) { return; // No open text editor } var selection = editor.selection; var text = editor.document.getText(selection); // Display a message box to the user vscode.window.showInformationMessage('Selected characters: ' + text.length);

Tip: Once you make changes to the extension source code, you need to restart the Extension Development instance of VS Code. You can do that by using




) in the second instance or by clicking the Restart button at the top of your primary VS Code instance.

Video outline

  • Download and install VS Code.
  • Open a folder

    • File > Open Folder (Ctrl+K Ctrl+O)
  • File Explorer

    • View > Explorer (⇧⌘E (Windows, Linux Ctrl+Shift+E))
  • Search view

    • View > Search (⇧⌘F (Windows, Linux Ctrl+Shift+F))
  • Source Control

    • View > Source Control (SCM) (⌃⇧G (Windows, Linux Ctrl+Shift+G))
  • Run and Debug

    • View > Run (⇧⌘D (Windows, Linux Ctrl+Shift+D))
  • Extensions view

    • View > Extensions (⇧⌘X (Windows, Linux Ctrl+Shift+X))
  • Open the Command Palette.

    • View > Command Palette… (⇧⌘P (Windows, Linux Ctrl+Shift+P))
  • Output panel

    • View > Output (⇧⌘U (Windows Ctrl+Shift+U, Linux Ctrl+K Ctrl+H))
  • Debug Console

    • View > Debug Console (⇧⌘Y (Windows, Linux Ctrl+Shift+Y))
  • Problems panel

    • View > Problems (⇧⌘M (Windows, Linux Ctrl+Shift+M))
  • Integrated Terminal

    • View > Terminal (⌃` (Windows, Linux Ctrl+`))
  • Create a new file

    • File > New File (⌘N (Windows, Linux Ctrl+N))
  • Save a file

    • File > Save (⌘S (Windows, Linux Ctrl+S))
  • Auto Save

    • File > Auto Save
  • Run

    • Run > Start Debugging (F5)
  • Programming language extensions

    • Python – IntelliSense, linting, debugging, code formatting, refactoring, and more.
    • Live Preview – Hosts a local server to preview your webpages.
  • Zoom

    • Zoom out (⌘- (Windows, Linux Ctrl+-))
    • Zoom in (⌘= (Windows, Linux Ctrl+=))
  • Customize your editor with color themes.

    • File > Preferences > Theme > Color Theme (⌘K ⌘T (Windows, Linux Ctrl+K Ctrl+T))
Setting up VSCode and Hello World in Javascript
Setting up VSCode and Hello World in Javascript

Create a Hello World app

First, ensure you are within the new folder (workspace) that you created. From here, you can create the project in two ways.

Use the Command Palette

  1. Bring up the Command Palette using ⇧⌘P (Windows, Linux Ctrl+Shift+P) and then type “.NET”.
  2. Find and select the .NET: New Project command.
  3. After selecting the command, you’ll need to choose the project template. Choose Console app.
  4. To run your app, select Run > Start Debugging in the upper menu, or use the F5 keyboard shortcut. To learn more about debugging your C# project, read the debugging documentation.

Use the terminal

  1. Open a terminal/command prompt and navigate to the folder in which you’d like to create the app. Enter the following command in the command shell:

    dotnet new console

  2. When the project folder is first opened in VS Code:

    A “Required assets to build and debug are missing. Add them?” notification appears at the bottom right of the window.

    Select Yes.

  3. Run the app by entering the following command in the command shell:

    dotnet run

Modify the source code

At this point, the command and Button text are autogenerated and not that interesting. You can modify the VSCT file and CS file if you want to make changes.

  • The VSCT file is where you can rename your commands, and define where they go in the Visual Studio command system. As you explore the VSCT file, notice comments that explain what each section of the VSCT code controls.

  • The CS file is where you can define actions, such as the click handler.

  1. In Solution Explorer, find the VSCT file for your extension VSPackage. In this case, it’s called HelloWorldPackage.vsct.

  2. Change the


    parameter to

    Say Hello World!




  3. Go back to Solution Explorer and find the Command.cs file. In the


    method, change the string





    Hello World!


    ... private void Execute(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); string message = "Hello World!"; string title = "Command"; // Show a message box to prove we were here VsShellUtilities.ShowMessageBox( this.ServiceProvider, message, title, OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); } ...

Make sure to save your changes to each file.

First  Program | Hello World  | Java Tutorial
First Program | Hello World | Java Tutorial

Running your Extension

  • Launch VS Code, choose



    Open Folder

    and pick the folder that you generated.
  • Press


    or click on the


    icon and click


  • A new instance of VS Code will start in a special mode (

    Extension Development Host

    ) and this new instance is now aware of your extension.
  • Press


    and run the command named

    Hello World

  • Congratulations! You’ve just created and executed your first VS Code command!

Keywords searched by users: hello world visual studio code

Playing With Vscode: C# Hello World Project – Musings Of A Strange Loop
Playing With Vscode: C# Hello World Project – Musings Of A Strange Loop
How To Get Started With Python In Visual Studio Code | Digitalocean
How To Get Started With Python In Visual Studio Code | Digitalocean
Hello World In Java Using Visual Studio Code - Youtube
Hello World In Java Using Visual Studio Code – Youtube
Create A .Net Console Application Using Visual Studio Code - .Net |  Microsoft Learn
Create A .Net Console Application Using Visual Studio Code – .Net | Microsoft Learn
C++ Hello World Program| Visual Studio Code | Hello World Program | C++  Tutorial #Codeontrend #C++ - Youtube
C++ Hello World Program| Visual Studio Code | Hello World Program | C++ Tutorial #Codeontrend #C++ – Youtube
Creating A Hello World Application With C# And .Net Core In Vs Code -  Authorcode
Creating A Hello World Application With C# And .Net Core In Vs Code – Authorcode
Python - Print(
Python – Print(“Hello World”) In Vscode – Youtube
Create A .Net Console Application Using Visual Studio Code - .Net |  Microsoft Learn
Create A .Net Console Application Using Visual Studio Code – .Net | Microsoft Learn
Building Hello World Html Page Using Vs Code And Live Server Extension -  Youtube
Building Hello World Html Page Using Vs Code And Live Server Extension – Youtube
C++ Hello World Program| Visual Studio Code | Hello World Program | C++  Tutorial #Codeontrend #C++ - Youtube
C++ Hello World Program| Visual Studio Code | Hello World Program | C++ Tutorial #Codeontrend #C++ – Youtube
Playing With Vscode: C# Hello World Project – Musings Of A Strange Loop
Playing With Vscode: C# Hello World Project – Musings Of A Strange Loop
C++ Hello World Tutorial In Microsoft Visual Studio. (No Programming  Experience Needed!) - Youtube
C++ Hello World Tutorial In Microsoft Visual Studio. (No Programming Experience Needed!) – Youtube
Python Hello World Program (Step By Step Using Pycharm + Visual Studio Code)  - Python Guides
Python Hello World Program (Step By Step Using Pycharm + Visual Studio Code) – Python Guides
Visual Studio Code C# Beginner Tutorial: Hello World - Youtube
Visual Studio Code C# Beginner Tutorial: Hello World – Youtube
Setting Up Vscode For Python: A Complete Guide | Datacamp
Setting Up Vscode For Python: A Complete Guide | Datacamp

See more here:

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *