How do you get started with VS code, what are the most commonly used, useful features and how do you use them? That is what this tutorial covers.

What is it?

VS code is a code editor (not just a plain text editor and not a full fledged IDE). It is very fast to start (and to use) but also has some of the features that are traditionally only in full fledged IDEs (such as code navigation, refactoring, building, and debugging).

Installing

To install, just download the installer for your platform and run it.

How to change settings (and what settings to change)

To change settings, go to File->Preferences->Settings. You can search for particular settings.

Settings I like to change:

  • toggle off the minimap (search for “minimap” and you’ll see the setting to toggle it off)
  • set start page to none (search for “start page” and you’ll see the setting)
    • this makes it so that when you launch vscode, you don’t see the annoying start page

How to change keyboard shortcuts

Go to File->Preferences->Keyboard Shortcuts. Search for a command, select it from the list, right click and change the key binding.

To do most things in vscode, you will execute commands. Press control + shift + p to open the “show all commands” search box. Start typing the name of a command, select a command with the arrow keys and press enter to execute it.

I like to change the “show all commands” keyboard shortcut to control + shift + a because I’m used to this from other programs.

How to install extensions

All language services (syntax highlighting, code navigation, refactoring, building, debugging, etc) are provided by extensions for that language. To install an extension:

  • click the Extensions button on the left side bar
  • by default, you’ll be shown the most popular extensions
  • search for an extension
  • click it
  • click install in the newly opened extension page

I install the C++, Python, and todo tree extensions.

How to open a file

I like to just drag the file onto the vscode window. You can also do code path/to/file.ext in your command prompt.

Useful features (and how to use them)

  • Put your cursor over a word, all the same words are highlighted on the page (as well as marked in the scrollbar)
    • you can select a region of text and the same thing happens
    • really good for
      • quickly getting an idea of where certain words or phrases are used in your file
      • seeing if two strings are the same (both will be highlighted on the page if they are)
  • control + f to find
    • supports regex (click the regex button on the find widget to enable it)
    • search results are highlighted on the page and on the scrollbar
    • f3/shift+f3 to go to the next/previous result
    • to restrict searching to just what you have selected
      • make your selection
      • press control + f
      • click the Find in selection button in the find widget
  • control + h to find/replace
    • i often
      • select some text (maybe a block or so)
      • control + h
      • click find in selection button
      • click replace all
    • this is very useful!
  • go to definition/declaration of symbol under cursor (f12)
  • go to symbol in file (alt + \)
    • note: I customized this shortcut to alt + \, it is by default (control + shift + o)
  • go back/forward (alt + left/alt + right)

  • f2 to rename symbol under cursor
    • or right click + rename symbol
  • move line up/down (alt + up/alt + down)
  • copy line down (i do control + d, default is something else, look it up :P)
  • cut line (shift-delete)
  • copy line cursor is currently on (control + c)
  • extend cursor up/down (multi cursor editing) (control + alt + up / control + alt + down)
    • hold alt and click anywhere to place another cursor there
  • expand/shrink selection (shift + alt + right / shift + alt + left)

  • trigger suggestions (control + space)
  • parameter hint (control + shift + space)

  • run format document command to format your doc (or right click -> format document)
  • f5 to debug
    • f10 to step over, f11 step into, shift + f11 to step out
    • can alternatively just use the buttons in the debug widget
  • python specific
    • right click -> run current file in terminal
    • select interpreter command (also in bottom left corner of screen)
      • let’s you choose another python interpreter installed on your system