Tips and Tricks for Visual Studio Code - IncrediCoders/Python1 GitHub Wiki

This page includes the following tips/tricks on using Visual Studio Code:

  1. Keyboard Shortcuts
  2. Run Your Program
  3. Navigate Your Code
  4. Change Font Size
  5. Change Themes and Colors
  6. Compare Your Code
  7. Additional Resources

1. Keyboard Shortcuts

Keyboard shortcuts can make you more efficient when you're using Visual Studio Code (VSC). It saves time and helps you do more with just your keyboard.

Here are some useful shortcuts to know for VSC:

NOTE: If you are on MacOS, replace Ctrl with Cmd.

  • Copy and Paste: Ctrl + C and Ctrl + V
  • Saving the file you are currently on: Ctrl + S
  • Saving all open files: Ctrl + K S
  • Delete line: Ctrl + Shift + K
  • Running a file (not in debug mode): Ctrl + F5
  • View command suggestions: ?
  • Move a line up or down: Alt + Up or Alt + Down
  • Code reformatting (like indenting the code properly):
    • Currently selected source code: Ctrl + K Ctrl + F
    • Whole document format: Shift + Alt + F

Accessing more keyboard shortcuts:

  • Displays a list of keyboard shortcuts: Ctrl + Shift + P
  • Download the keyboard shortcut reference sheet for your platform:

2. Run Your Program

In addition to using F5 to run your code, there are other ways to do so.

Note: You might need to hold down or toggle function (Fn) keys.

  • Click the green triangle button in the upper right.

  • Run your program through the top menu.

  • Right-click the file you want to run, and select Run Python File in Terminal.

You can also set up specific debugging settings through the top menu. Debugging is useful for finding errors in how your code runs. In the settings, you can set breakpoints, which is one tool for debugging.

3. Navigate Your Code

Scrolling through your code can be very time-consuming. You might have written a lot of code, or you might not remember exactly where a line of code is. There are a lot of ways to navigate through a single file or many files:

NOTE: If you are on MacOS, replace Ctrl with Cmd.

  • To find keywords or phrases: Ctrl + F

  • Navigate to the beginning or end of your file: Ctrl + Home and Ctrl + End

  • Use the Outline Panel to jump to specific variables or functions in your file.

  • Use the Page Down and Page Up keys (if your keyboard has them) to scroll through your code.

  • Hold Alt while scrolling for fast scrolling. It is 5x the normal speed.

  • Navigate through Error and Warnings in your file: Ctrl + Shift + M

    • You can cycle through errors with F8 or Shift + F8
  • Navigating History (the files you have opened):

    • Navigate the entire history: Ctrl + Tab
    • Navigate back a file: Alt + Left
    • Navigate forward a file: Alt + Right
  • Collapse and Expand the Left Navigation Bar: Ctrl + B

    • Alternatively, you can click on the icon to open or close it.
  • Close and Open the Bottom Panel: Ctrl + J

    • You can also click the X near the top-right corner of the Panel to close it. Use Ctrl + J to open it back up again.

4. Change Font Size

If you have vision problems or want to make it easier to read your code, increasing your font size is very helpful. It can decrease potential eye strain and make reading more comfortable while you program.

  1. Click the gear icon on the bottom-left corner of the VSC window and select Settings.

  2. A settings page will open up, and an option to change the font size should appear. Under Editor: Font Size, change the font size number to a larger number.

5. Change Themes and Colors

There are many reasons why you would want to change the theme or colors of VSC. If you have visual challenges, like colorblindness or color sensitivity, changing the theme to special colors can make it easier to work in VSC. You can also change your theme, based on your personal preference. Some people like to leave VSC as its standard dark theme, while others change it to its light theme. It depends on what you want!

  1. Click the gear icon on the bottom left, and then select the Color Theme option.

  2. A list will appear. Pick the theme that suits your needs. Once you click on the theme, it will automatically be applied.

  • If you would like to have a different theme, you can download many other themes through the VS Marketplace for free.

6. Compare Your Code

There are several reasons why you would want to compare your code in different ways. Sometimes you want to be able to reference two different sections of your code at the same time. Or maybe you want to have multiple files visible so you can compare them.

Compare the Same File:

Side-by-Side Editing: Ctrl + \

This will open up a separate editor of your file.

Compare Different Files:

  1. Open the files you want to view.

  2. Click the tab with the name of your file you want to move. Drag the file into the area you would like. There should be a highlighted gray rectangle to show you where it will be displayed. You can move files left/right or up/down from each other. You can view multiple files this way.

7. Additional Resources

Next Steps

If you're still getting your system set up for the book:

If you're ready to get help on Level 1, head to Level 1: Help. See all the Level 1 articles at Level 1: Turtle Map: All Online Resources.

You can also go back to the main page, IncrediCoders: Python Adventures - All Online Resources.