Skip to content

Visual Studio Code

etortorici edited this page Dec 3, 2024 · 1 revision

Visual Studio Code (or VSCode, VSC, or Code) is an integrated development environment (IDE) that is well suited for software projects of all kinds that can be used on Windows, Mac, and Linux operating systems. VSCode uses extensions to enable functionality so that it can be both lightweight and powerful. It can be used to write C, C++, Fortran, Rust, Python, Jupyter Notebooks, LaTeX, HTML, CSS, JavaScript, Ruby, Julia, and much much more.

Note: For C, C++, and Fortran, Microsoft has another IDE, simply called Visual Studio, that is a bit more powerful for these particular languages (this is a Windows only application).

Installation

The installers for Windows, Linux, and Mac can all be found here.

Windows

To get the best VSC experience make sure you leave the "Don't create a Start Menu Folder" checkbox UNCHECKED. On the next page, under "Select Additional Tasks", make sure you have the following CHECKED

  • Add "Open with Code" action to Windows Explorer file context menu

    • This makes it so you can right click any file in Windows Explorer, click "Show more options", and then "Open with Code" (it will have the VSC icon next to it).
  • Add "Open with Code" action to Windows Explorer directory context menu

    • This makes it so you can right click a directory in Windows Explorer, click "Show more options", and then "Open with Code" (it will have the VSC icon next to it). This will open an instance of VSC with access to this directory (very convenient!).
  • Register Code as an editor for supported file types

    • This makes it so, for example, double clicking .py scripts, will open it in VSC.
  • Add to PATH (requires shell restart)

    • This allows you to launch VSC from a Command Prompt or Power Shell with code.

Quick Guide

Workspace

A workspace is a collection of one or more directories that comprise a project. If you right click a directory from the Windows Explorer and "Open with Code" (under "Show more Options") or with code [path to directory] from a command prompt, this directory (and all directories down from it) will open as a workspace. VSC has the capability of saving specific settings for each workspace with "File -> Save Workspace As...". This will save a file with file-extension .code-workspace, and these can be opened by double clicking them from Windows Explorer. You can learn more about how to customize a workspace here.

Activity Bar

A VSC window has an "Activity Bar" on the left. This has icons that open a space on the left for certain activities:

  • The first icon will always be the "Explorer" icon (looks like a stack of pages). This is a space for you to manage the files in your project. If you open VSC from the taskbar or start menu for the first time, the Explorer will prompt you to open a project directory. If you use the "Open with Code" option from another program, it will automatically configure the Explorer tab to have access to that directory.

  • The "Search" icon (looks like a magnifying glass) can be used to search through all the files in the project.

  • The "Source Control" icon (looks like a Git visualization) allows you to use Git on your project. This is a perfectly acceptable way to use Git, but it is much easier to use the GitHub desktop application (more on that later).

  • The "Run and Debug" icon (looks like a bug and a triangle) has some debugging functionality.

  • The "Extensions" icon (looks like 4 squares with one disconnected from the others) allows you to install and uninstall extensions.

  • Other icons will appear depending on how your workspace is configured for a particular project.

Some Recommended Extensions

  • GitHub Copilot: Requires a Pro account (You have this through CU and how to access it is discussed in the GitHub section below).

    • This will add a chatbot icon in the Activity Bar, that can be very helpful, but it will also provide AI autocompletion which not only is often wrong and annoying, but also is like leaving a microwave and your bathroom sink both running while youre not using them. You absolutely should turn this feature off. In the Extensions tab, clear your search, and click the gear icon on the right of the "GitHub Copilot Chat" row and then select "Settings." Deselect the following:

      • "Github > Copilot > Chat > Experimental > Code Generation: Use Instruction Files"

      • "Github > Copilot > Chat > Experimental > Generate Tests: Code Lens"

      • "Github > Copilot > Chat > Experimental > Inline Chat Completion Trigger: Enabled"

      • "Github > Copilot > Chat > Experimental > Inline Chat Hint: Enabled"

      • "Github > Copilot > Chat > Experimental > Setup Tests: Enabled"

      • "Github > Copilot > Chat > Experimental > Start Debugging: Enabled"

      • "Github > Copilot > Chat > Experimental > Temporal Context: Enabled"

  • Python

  • Jupyter

  • LaTeX Workshop: This will allow you to compile LaTeX into PDFs within your workspace (very helpful for developing reports, papers, journal articles, and other deliverables)

  • Rainbow CSV: CSV files are a common data file, and this extension makes them easier to view within VSC

  • Spell Right: This is a spell checker and is great for any LaTeX or Markdown you have in your workspace. You can disable it for specific file types in its settings if you want.

LaTeX in VSC

You will need a separate LaTeX compiler to use VSC as a LaTeX editor. On Mac and Linux, TeX Live is a good option, and on Windows you should use MiKTeX. Furthermore, on Windows, you will need to install Strawberry Perl.

There are plenty of LaTeX templates out there. A former PhD student has provided a template for PhD theses on his GitHub that can be found here. This can be used to make all sorts of documents that aren't a PhD thesis.

There is a wiki for the LaTeX Workshop extension.

You will likely be prompted to install TeX packages the first time you run some LaTeX. Install everything that is suggested.

LaTeX Fonts

The LaTeX default font is "CMU Serif", you can download this font here, so that you can utilize it in image editors, so that fonts in your figures are consistent with LaTeX's font

Clone this wiki locally