Home > Blog > What is Visual Studio Code - A Complete VS Code Tutorial

What is Visual Studio Code - A Complete VS Code Tutorial

What is Visual Studio Code - A Complete VS Code Tutorial

By Upskill Campus
Published Date:   29th August, 2024 Uploaded By:    Ankit Roy
Table of Contents [show]

 

Visual Studio Code (VS Code) is a lightweight, open-source code editor developed by Microsoft for writing computer code.  It is popular among developers for its versatility, speed, and extensive features. It works on Windows, Mac, and Linux and you can use it to write code in many languages like JavaScript, TypeScript, Node.js, and even C++, C#, Java, Python, PHP, Go, and . NET. This visual studio code tutorial will help you start using VS Code. We will also elaborate on multiple concepts, such as benefits, architecture, tools, etc. Whether you're a beginner or an experienced developer, this guide will help you master VS Code to enhance productivity and streamline your coding workflow.


Overview of Visual Studio Code


VS Code is a free, easy-to-use tool for writing computer code. It works on Windows, Mac, Linux, and even Raspberry Pi. You can use it to write code in many languages like JavaScript, TypeScript, Node.js, and even C++, C#, Java, Python, PHP, and Go. It also helps you work with .NET, Unity, Docker, Kubernetes, and cloud services like Amazon, Microsoft, and Google.

 

Visual Studio Code is a great tool for writing code. It helps you write code faster by suggesting variables, methods, and modules. It also allows you to find and fix mistakes in your code and makes it easy to move around and change your code. Moreover, you can even use it to manage your code versions with Git. Many of these features are based on the same technology used in Visual Studio.

 

VS Code is made up of different parts. It uses technology like Electron, Node.js, TypeScript, and Language Server Protocol. In short, it's always being updated with new features. There are also many extensions you can add to use different programming languages. Some extensions have more features than others, but you can always add basic support for your favorite language even if there's no advanced extension.


Visual Studio Code Architecture


When you look at the "About" section of VS Code, you'll see some information about what it's made of. Moreover, this information will tell you more about the parts that make up VS Code, like Electron, Node.js, TypeScript, and Language Server Protocol.

 

Version: 1.66.2 Commit: dfd34e8260c270da74b5c2d86d61aee4b6d56977 Date: 2022-04-11T07:49:20.994Z Electron: 17.2.0 Chromium: 98.0.4758.109 Node.js: 16.13.0 V8: 9.8.177.11-electron.0 OS: Darwin x64 19.6.0

 

Visual Studio Code is made up of several parts. It uses Electron, which helps it work on different computers, and Node.js, which runs JavaScript code. It also uses Chromium, a part of Google Chrome, and V8, a powerful engine for running JavaScript. If you're using a Mac, you'll see that it uses Darwin, the base of macOS. If you're using Windows or Linux, you'll see that it uses those operating systems.

 

Language Server Protocol (LSP) is a way for different programs to talk to each other. It helps tools like editors and IDEs get information from language servers. Language servers are experts who know a lot about a specific programming language. In addition, they can help you with auto-complete, finding definitions, and seeing where things are used in your code.

 

Debug Adapter Protocol (DAP) is a way for different programs to talk to each other. Moreover, it helps tools like editors and IDEs talk to debuggers. Debuggers are like helpers that can help you find and fix mistakes in your code. DAP makes it easier to create a generic debugger that can work with different types of debuggers, so you don't have to create a new debugger for each tool you use.


Visual Studio Code Extensions


Under this VS code tutorial, there are many extensions available for VS Code that can help you use different programming languages. You can find and install these extensions in the Marketplace, or from the Extensions sidebar or Command Palette within VS Code.

 

VS Code has many extensions that can help you use different programming languages. You can find and install these extensions in the Marketplace, or from the Extensions sidebar or Command Palette within VS Code. There are thousands of extensions available, and one of the most popular is for Python Programming, with millions of downloads. It helps you write, debug, and refactor Python code, and also automatically installs other useful extensions for Python.


Visual Studio Code Benefits and Uses


VS Code is a powerful tool for writing code. It has many features that make it easy to write, edit, and understand code. Some of these features include:

 

  • Easy editing: VS Code makes it easy to write code with features like highlighting, matching brackets, and automatic indentation.
  • Developer tools: It has tools that help you write better code, like suggesting words, finding errors, and understanding how code works.
  • Build and scripting tools: You can use VS Code to manage your code projects and work with Git.
  • Learning tools: VS Code can help you learn to code by highlighting necessary words and suggesting ways to complete your code.
  • Collaboration tools: You can work with others on code using Visual Studio code tools
  • Team collaboration tools: You can connect to other tools like Slack and Discord while using VS Code.

 

Here, we have already discussed the visual studio code uses. With the help of this, you can also add new features to VS Code by installing extensions. In addition, you can customize VS Code to fit your preferences by changing the look, keyboard shortcuts, and settings. 


Visual Studio Code Example


Now, we will discuss a few examples of the VS Code. But before moving further, we will learn how to run the code.  

 

  • First, open VS Code and go to File > Open Folder.
  • After that, choose the folder where you saved your extension.
  • Then, click the Debug icon and then Start.
  • A new window of VS Code will open, and this new window knows about your extension.
  • Next, press Ctrl+Shift+P (or use the Command Palette) and type "Hello World".
  • At last, click "Hello World" to run your command.

 

Congratulations! You just created and ran your first VS Code extension command.

 

Example:

 

// 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);

}

Visual Studio Code VS Visual Studio


Choosing between VS Code and Visual Studio depends on your needs. VS Code is simpler and faster, but Visual Studio has more features. Many of the features in VS Code came from Visual Studio, so it's easy to switch between them.

 

Visual Studio can create new projects from templates, while VS Code can't. But you can use command-line tools like Yeoman to do this within VS Code. If you need to analyze how your code is running, Visual Studio is better.

 

Visual Studio used to be slow when opening big projects, but that's fixed now. It also used to take up a lot of space, but you can now choose which parts to install.


Conclusion 


Visual Studio Code is a powerful and versatile code editor that offers a wide range of features for developers. Moreover, it is lightweight yet extensible, with a rich ecosystem of extensions that support numerous programming languages and frameworks. Whether you're a seasoned developer or just starting, VS Code provides a robust and efficient environment for writing, editing, and debugging code. In addition, its combination of speed, customization options, and community support make it a popular choice among developers worldwide.

 


Frequently Asked Questions


Q1. Is Visual Studio Code an IDE?

Ans. Yes, VS Code is an IDE.

Q2. Is Visual Studio Code like Python?

Ans.VS Code uses Python programming language.

 

About the Author

Upskill Campus

UpskillCampus provides career assistance facilities not only with their courses but with their applications from Salary builder to Career assistance, they also help School students with what an individual needs to opt for a better career.

Recommended for you

Leave a comment