; PSY 1903
PSY 1903 Programming for Psychologists

VSCode

The most important tool for any programmer is a good code editor. While you could write code in any text-based editor (TextEdit, Notepad, etc.), you’ll be lacking some key features that code editors provide including:

  • Syntax highlighting - Highlights different elements of code (keywords, variables, comments) in different colors to improve readability and understanding.
  • Autocompletion - Provides suggestions for code as you type, helping to speed up coding and reduce typing errors.
  • Formatting - Automatically formats code according to predefined styles or user-configured settings, ensuring consistency and readability across the codebase.
  • Error Checking - Provides real-time feedback on syntax errors, potential bugs, and code quality issues, helping to catch and fix errors early in the development process.
  • Etc... Code editors are packed with useful features.

In this course, we’ll start with the general purpose code editor VSCode (Visual Studio Code). This editor is popular, free, cross-platform and highly customizable via extensions. Later in the semester, we’ll also work with R Studio - a code editor customized for working with R.

Download and install

To get started, download VSCode from https://code.visualstudio.com.

Once downloaded, run the installer and follow the instructions provided.

Themes

Color themes can be installed via Extensions, accessible from the activity bar on the left.

If you want your interface to look like what is shown in the videos, the theme I use is luxcium.pop-n-lock-theme-vscode. Feel free to use whatever theme you like.

Pop N Lock Theme in VSCode

Working with files

The file explorer (accessible from the activity bar on the left) is used to open project directories where you can navigate and work with your project files.

Settings

To access Settings in VSCode, click the cog icon on the bottom left then choose Settings.

VSCode has a lot of settings available, so take advantage of the search bar up top when looking for something.

For this course, you should adjust the following settings:

Set Auto Save to onFocusChange. This will make it so your files are automatically saved whenever you switch contexts (e.g. file tabs, or out of VSCode into another window).

Enable Format on Save, so that VSCode’s auto-formatter is regularly run on your code files keeping them tidy.