close icon
daily.dev platform

Discover more from daily.dev

Personalized news feed, dev communities and search, much better than what’s out there. Maybe ;)

Start reading - Free forever
Start reading - Free forever
Continue reading >

Visual Studio Code: Read this before you get started

Visual Studio Code: Read this before you get started
Author
Nimrod Kramer
Related tags on daily.dev
toc
Table of contents
arrow-down

🎯

Learn about Visual Studio Code, a versatile code editor with features like IntelliSense, Git support, and a vast marketplace of extensions. Get started with installation, configuration, and productive coding tips.

Visual Studio Code (VS Code) is a versatile, free code editor that supports a wide range of programming languages and platforms. It's ideal for developers of all levels, offering features like IntelliSense for smart suggestions, built-in Git support for version control, and a vast marketplace of extensions to boost productivity. Here's a quick overview:

  • Free and cross-platform: Works on Windows, Linux, and macOS.
  • Highly customizable: Themes, keybindings, and settings can be tailored to your preferences.
  • Rich feature set: Includes IntelliSense, debugging tools, and built-in terminal.
  • Extensive extension marketplace: Enhance functionality with plugins for languages, themes, and tools.
  • Regular updates: Continuously improved by Microsoft and the community.

Whether you're writing JavaScript, Python, C++, or any other language, VS Code offers a smooth coding experience. With tools for debugging, version control with Git, and customization options, it's designed to make coding efficient and enjoyable. For beginners, it's a great starting point due to its ease of use, helpful community, and wealth of online resources.

What is Visual Studio Code?

Visual Studio Code, or just VS Code, is a free program made by Microsoft that lets you write and work on code easily. It's great for building websites and applications, and it supports a bunch of programming languages like JavaScript, TypeScript, and Node.js.

Here are some cool things about VS Code:

  • IntelliSense helps you write code faster by predicting what you'll type next.
  • Git support means you can keep track of changes in your code without leaving the editor.
  • You can add extensions to do even more, like work with different programming languages or tools.
  • You can change how it looks and the keyboard shortcuts to make it comfortable for you.
  • It works on Windows, Linux, and macOS.

Created by Microsoft

Microsoft released VS Code in 2015. It's a mix between a simple code editor and a set of tools for developers, like smart suggestions (IntelliSense) and a way to fix mistakes (debugging).

VS Code gets updated every month with new stuff and fixes, and a lot of people help make it better on GitHub.

For All Developers

VS Code is mainly for web development, but thanks to people making extensions, it also works well for:

  • Python
  • Java
  • C/C++
  • C#/.NET
  • PHP
  • Go

It's designed to be quick and easy for anyone who writes code, no matter what language you use.

VS Code vs. Sublime Text

VS Code has some things Sublime Text doesn't, like:

  • A built-in place to write commands (terminal) and tools to find and fix errors (debugging)
  • Better support for tracking changes in your code (Git)
  • More options for adding new features (extensions)

But, Sublime Text can be faster and smoother to use.

VS Code vs. Atom

VS Code is generally faster and uses less memory than Atom. It's also better for smart suggestions (IntelliSense) and fixing errors (debugging). But, Atom lets you change its look just as much as VS Code.

VS Code vs. Vim

VS Code can do a lot of what Vim does, especially with keyboard commands for quick editing. But Vim is super lightweight and works in a text terminal. While VS Code is easier for beginners, Vim has some powerful features for those who learn it well. VS Code can try to act like Vim with certain extensions, but it's not exactly the same.

Installing and Configuring VS Code

Installation Guide

Getting Visual Studio Code set up on your computer is easy, whether you're using Windows, macOS, or Linux.

Here's how to do it:

  • Windows - Head over to the VS Code website and grab the installer. Run it, and you're all set.
  • macOS - Visit the VS Code website, download it for macOS, and then drag it into your Applications folder.
  • Linux - For those on Debian/Ubuntu or Red Hat/Fedora, VS Code has got you covered with .deb and .rpm packages. Just download and install from the setup guide for Linux.

For other ways to install, like using it on the go, check the setup overview.

Basic Configuration

After installing, you'll want to tweak a few things to get started:

  • Themes - Change how VS Code looks under Preferences > Color Theme. There are lots of options, from dark to light themes.
  • Settings - Hit Ctrl/Cmd + , to open settings. Here, you can adjust things like when your code saves automatically, how big your text is, and more.
  • Keybindings - Customize how you use your keyboard in VS Code by going to Preferences > Keyboard Shortcuts. You can even make VS Code's shortcuts work like other editors (Vim, Sublime, etc.) with keymap extensions.

Adding extensions from the Marketplace can also give you new tools and features, like help with code errors, better Git support, or language-specific aids.

Required Extensions

Some extensions really help make your coding life easier:

For more, the Marketplace has extensions for almost anything you might need.

Learning the VS Code Interface

Key Sections

The main parts of the VS Code interface include:

  • Editor - This is where you open and change code files. You can have more than one file open at a time.
  • Side Bar - This shows the files and folders you're working with. You can hide it to see more of your code.
  • Status Bar - Found at the bottom, it tells you things like which Git branch you're on and if there are any mistakes in your code.
  • Panels - These are areas that pop out for specific tasks like searching, viewing errors, or managing extensions.

You can change the size of these sections by dragging their edges. Feel free to arrange them however works best for you.

Customizing the Layout

To make the VS Code interface work better for you:

  • Use Ctrl+B (Windows/Linux) or Cmd+B (macOS) to hide or show the Side Bar.
  • Press F11 to go full screen.
  • Try Zen Mode with Ctrl+K Z to hide everything but your code.
  • Open files side-by-side by splitting the editor window.

Extensions like Settings Sync can help you keep your setup the same across different computers.

Key Keyboard Shortcuts

Here are some handy shortcuts in VS Code:

  • Ctrl+P - Quickly find a file
  • Ctrl+Shift+F - Search and replace across files
  • Ctrl+G - Go to a specific line
  • Ctrl+\ - Split the window to see files next to each other
  • Ctrl+Shift+M - Show or hide the Problems panel
  • Ctrl+Shift+X - Open the Extensions view

VS Code has a lot of keyboard shortcuts to help you work faster. You can also change them to fit your needs.

Productive Coding Features

VS Code has some cool tools like IntelliSense, debugging, and Git support that make coding a lot easier. These tools help you write, test, and manage your code better.

IntelliSense

IntelliSense is like a smart helper that gives you suggestions while you type, making it easier to code quickly and with fewer mistakes. It offers:

  • Suggestions for methods, parameters, and imports
  • Tooltips that explain what parts of your code do
  • Hints about what parameters (or inputs) a method needs
  • Checks your code for errors like missing variables

IntelliSense is great for languages like JavaScript, TypeScript, HTML, CSS, and more. It learns how you code and gives you tips that make sense for what you're doing.

Debugging

VS Code can help you find and fix problems in your code for languages like Node.js, Python, C#, Go, Java, and PHP. With debugging, you can:

  • Stop your code to see what's happening at that moment
  • Go through your code step by step
  • Set breakpoints that only stop the code if certain conditions are met
  • Look at the values of variables and objects
  • See the call stack to understand how your code runs

Debugging makes it easier to see inside your code and solve problems faster.

Version Control with Git

VS Code lets you work with Git right inside the editor for things like saving changes, sharing your code, and fixing conflicts. You can:

  • See changes in the Git sidebar
  • Save and commit changes through the Source Control tab
  • Share and get changes from the repository
  • Fix conflicts between your code and others'
  • Open repositories to look at past changes

With Git tools built into the editor, working on code with others and keeping track of your changes is a lot smoother.

sbb-itb-bfaad5b

Customizing and Extending VS Code

Essential Customizations

VS Code lets you change how it looks and works to fit what you like. Here are some basic ways to make it yours:

  • Themes - Go to File > Preferences > Color Theme to pick different colors for the editor. You can choose from light, dark, or really bold themes. Some popular choices are Solarized Light, GitHub Dark, and Cobalt2.
  • Font - In File > Preferences > Settings > Font, you can change the size, style, and type of font. Fira Code and Source Code Pro are favorites for coding.
  • Layout - You can make parts of VS Code bigger or smaller by dragging their sides. To hide the Activity Bar, click View > Appearance > Show Activity Bar.
  • Explorer - Under File > Preferences > Settings > Explorer, you can decide how your files and folders show up. For example, you might want to hide files that start with a dot (.).

Increasing Efficiency

Learn these keyboard shortcuts to work faster in VS Code:

  • Basic editing - Ctrl+X (cut), Ctrl+C (copy), Ctrl+V (paste), Ctrl+/ (comment or uncomment)
  • Navigation - Ctrl+P (open file), Ctrl+G (go to line), Ctrl+Shift+\ (find matching bracket)
  • Split windows - Ctrl+\ (split editor), Ctrl+1/2/3 (switch between splits), Ctrl+W (close window)
  • Sidebar - Ctrl+B (show/hide sidebar), Ctrl+Shift+E (open explorer)
  • Find/replace - Ctrl+F (find), Ctrl+H (replace), F3/Shift+F3 (next/previous find)
  • Rich languages - Ctrl+spacebar (show suggestions), Ctrl+Shift+I (make the code neat)

Check out the complete list of shortcuts.

Must-Have Extensions

Here are some extensions you might find really useful:

For more, take a look at the VS Code Marketplace to find extensions.

Best Practices for Productive Coding

Startup Checklist

When you start using VS Code, here are a few quick things you can do to make it run better:

  • Turn off any extensions you're not using by going to the Extensions tab. This can make VS Code faster and use less of your computer's memory.
  • Clear out the extension cache with the Developer: Reload Window command. This can help speed things up too.
  • Use the Settings Sync extension to keep your custom settings the same on any computer you use.
  • Close any files or folders you're not working on to keep your workspace neat and tidy.

Linting and Code Formatting

Use these tools to help your code look good and stay error-free:

  • ESLint is great for catching mistakes in your JavaScript or TypeScript code.
  • Prettier automatically makes your code match style guides.
  • Beautify cleans up your code's look, like fixing spaces and lines.

Make sure to turn on 'format on save' in the VS Code settings so your files get cleaned up every time you save.

Debugging Tips

Here are some ways to make fixing code issues easier:

  • Try using logpoints instead of breakpoints. This way, you can see what's happening without stopping your code.
  • Set up breakpoints that only stop your code when certain things happen.
  • Look at variables in the Debug Console while your code runs to check on data.
  • Use step back and next/previous buttons to move through your code in a controlled way.

Seeing values as you debug can help you find and fix problems quicker.

Conclusion

Visual Studio Code is a helpful tool for people who write code, like for websites or apps. It’s free and works on different types of computers. It has cool features that help you write code without mistakes, manage changes, and understand your code better. You can also make it look and work the way you like by changing its settings and adding new tools from the Marketplace.

Here’s what you should remember from this guide:

  • You can use VS Code on any computer, and it’s made to work fast.
  • It has smart features to help you write code, find errors, and handle version control with Git.
  • You can change how it looks and how you interact with it to make it comfortable for you.
  • You can add more features with extensions to fit what you’re working on.
  • Tools for cleaning up and organizing your code are built-in.
  • It has a built-in terminal and supports Jupyter for more complex projects.

We suggest trying out some extensions we talked about to make your work easier. And if you ever get stuck, there’s plenty of help available online.

VS Code is popular because it’s easy to use, quick, and you can make it your own. Download it and see how it can help with your coding work!

What should you do before you begin debugging in Visual Studio Code?

Before you start fixing bugs in VS Code, it's smart to have a simple project ready, like a basic Node.js app that says "Hello World". This way, you have something simple to test and practice with as you learn how to use the debugging tools. You can add stopping points (breakpoints) and play around with the tools to see how your code runs, check the values of things, and get a feel for how everything works.

How do I use Visual Studio Code for the first time?

When you're new to VS Code:

  • Download and install it from the official website for your computer (Windows, macOS, or Linux)
  • Open it up and start a new file to see what the editor feels like
  • Take a look at the different parts of the interface like the Sidebar and Status Bar
  • If you're working on specific types of projects, like Python or JavaScript, find and install the right extensions
  • Check out features like Zen Mode for less distraction, or how to open files next to each other
  • Customize it to suit you better by changing shortcuts, themes, and settings

The VS Code website has guides and tips on setting everything up just right.

How do I make code readable in Visual Studio?

VS Code has tools to help make your code neater:

  • Remove Unused Directives: This cleans up your code by getting rid of lines that aren't being used
  • Sort Directives: This organizes your code by putting similar lines in order
  • Format Document: This adjusts your code's layout to make it easier to read according to standard rules

Extensions like Prettier can auto-format your code based on style rules. Turning on "Format on Save" can automatically tidy up your code every time you save a file.

Writing code in a clean, organized way and using clear names for things also makes your code easier to read.

Is VS Code good for beginners?

Definitely, VS Code is a great choice for anyone just starting out, especially for web development with HTML, CSS, and JavaScript. It's easy to use, has lots of helpful features like a built-in terminal and debugging tools, and there's a ton of extensions to add more functionality as you need it. It's also got a lot of resources and guides to help beginners get going and keep learning as they get more advanced.

Related posts

Why not level up your reading with

Stay up-to-date with the latest developer news every time you open a new tab.

Read more