📔
intro-to-python
  • An Introduction to Programming in Python (for Business Students)
  • exercises
    • Data Flow Diagramming Exercise
    • Developer Collaboration Exercise
    • README
    • "Web App" Exercise
      • checkpoints
        • Checkpoint 5: Bootstrap Layout
        • Checkpoint 4: Submitting Data from Web Forms
        • Checkpoint 3: Rendering HTML Pages
        • Checkpoint 1: Routing
        • Checkpoint 2: Modular Organization
      • "Web App" Exercise - Further Exploration
    • hello-world
      • "Hello World (Local)" Exercise
      • "Hello World (Local w/ Version Control)" Exercise
      • "Hello World (Colab)" Exercise
    • "Interface Capabilities" Exercise
    • "Continuous Integration 1, 2, 3" Exercise
    • "Web Service" Exercise
      • "Web Service" Exercise - Further Exploration
    • "Testing 1, 2, 3" Exercise
    • "Command-line Computing" Exercise
      • "Command-line Computing" Exercise
      • Professor Rossetti's Mac Terminal Configuration
      • Command-line Computing Exercise
    • "Codebase Cleanup" Assignment
    • "List Comprehensions" Exercise
    • "Groceries" Exercise
      • Python Datatypes (a.k.a. "Groceries") Exercise
      • Python Datatypes (a.k.a. "Groceries") Exercise
    • "Rock, Paper, Scissors" Exercise
      • "Rock, Paper, Scissors" Exercise
    • README
    • "Monthly Sales Predictions" Exercise
    • Setting up your Local Development Environment
    • "Chart Gallery" Exercise
    • "Run the App" Exercise
    • "Web Requests" Exercise
    • "API Client" Exercise
    • "Custom Functions" Exercise
    • Process Diagramming Exercise
  • notes
    • python
      • packages
        • The bigquery Package
        • The PySimpleGUI Package
        • The dotenv Package
        • The matplotlib Package
        • The requests Package
        • The altair Package
        • The gspread Package
        • The PyMySQL Package
        • The psycopg2 Package
        • The selenium Package
        • The seaborn Package
        • The pytest Package
        • The SpeechRecognition Package
        • The flask Package
        • The pandas Package
        • The spotipy Package
        • The pipenv Package
        • The nltk Package
        • The sqlalchemy Package
        • The pymongo Package
        • The plotly Package
        • The BeautifulSoup Package
        • The sendgrid Package
        • The fpdf Package
        • The autopep8 Package
        • The tweepy Package
        • The twilio Package
        • The tkinter Package
      • Python Datatypes Overview
        • Numbers
        • Classes
        • Dates and Times
        • Strings
        • None
        • Dictionaries
        • Booleans
        • Lists
        • Class Inheritance
      • Control Flow
      • Python Modules
        • The webbrowser Module
        • The time Module
        • The csv Module
        • The sqlite3 Module
        • The itertools Module
        • The json Module
        • The math Module
        • The os Module
        • The statistics Module
        • The random Module
        • The pprint Module
        • The datetime Module
        • The collections Module
      • Printing and Logging
      • Comments
      • Syntax and Style
      • Functions
      • Variables
      • Errors
      • Docstrings
      • File Management
      • User Inputs
      • Debugging
    • clis
      • The git Utility
      • Heroku, and the heroku Utility
      • Anaconda
      • The chromedriver Utility
      • The brew Utility (Mac OS)
      • The pdftotext Utility
      • The python Utility
      • The pip Utility
    • Software
      • Software Licensing
      • Software Documentation
      • Software Ethics
      • Software Testing Overview
      • Application Programming Interfaces (APIs)
      • Software Version Control
      • Software Refactoring Overview
    • devtools
      • The VS Code Text Editor
      • Code Climate
      • Travis CI
      • GitHub Desktop Software
      • Git Bash
      • Google Colab
    • Information Systems
      • Computer Networks
      • Processes
      • Datastores
      • Information Security and Privacy
      • People
    • Technology Project Management
      • Project Management Tools and Techniques
      • The Systems Development Lifecycle (SDLC)
    • hardware
      • Servers
    • Environment Variables
  • projects
    • "Executive Dashboard" Project
      • testing
      • "Exec Dash" Further Exploration Challenges
    • The Self-Directed (a.k.a "Freestyle") Project
      • "Freestyle" Project - Demonstration
      • "Freestyle" Project - Implementation (TECH 2335 Version)
      • "Freestyle" Project - Implementation
      • "Freestyle" Project Proposal
      • plan
    • "Robo Advisor" Project
      • Robo Advisor Project - Automated Testing Challenges
      • "Robo Advisor" Further Exploration Challenges
    • "Shopping Cart" Project
      • "Shopping Cart" Project - Automated Testing Challenges
      • "Shopping Cart" Further Exploration Challenges
      • "Shopping Cart" Project Checkpoints
  • License
  • Exam Prep
  • units
    • Unit 4B: User Interfaces and Experiences (Bonus Material)
    • Unit 5b: Databases and Datastores
    • Module 1 Review
    • Unit 7b: Processing Data from the Internet (Bonus Material)
    • Unit 9: Software Products and Services
    • Unit 8: Software Maintenance and Quality Control
    • Unit 7: Processing Data from the Internet
    • Unit 6: Data Visualization
    • Unit 5: Processing CSV Data
    • Unit 4: User Interfaces and Experiences
    • Unit 3: Python Datatypes
    • Unit 12: Project Presentations
    • Unit 2: Python Language Overview
    • Unit 11: Project Implementation Sprint
    • Unit 1: The Python Development Environment
    • Unit 10: Software Planning, Analysis, and Design
    • Unit 0: Onboarding
    • Unit 5B: Advanced Data Analytics
  • Contributor's Guide
Powered by GitBook
On this page
  • Installation
  • Basic Configuration
  • Shell Commands
  • Python Syntax Auto-completion
  • Column Selection
  • Further Optional Configurations
  • Additional Extensions
  • User Settings
  • Keybord Shortcuts
  • Python Snippets

Was this helpful?

  1. notes
  2. devtools

The VS Code Text Editor

PreviousdevtoolsNextCode Climate

Last updated 4 years ago

Was this helpful?

We'll be writing Python scripts using software called a . Similar to word processing software like Microsoft Word, text editors allow us to write and save documents of text. But unlike word processors, which save extra metadata (e.g. styles and formatting) along with the underling text, text editors allow us to save files comprised of just text. This helps the computer more easily interpret them.

There are many good text editor options out there, including , , , and , and it seems each developer has their own preference.

Regardless of which text editor you choose, you are highly encouraged to configure it with certain plugins, packages and extensions to enhance your experience and save you time. There are two sets of functionality in particular which will prove especially valuable this semester. These are "Python syntax auto-completion" and "column-style selection", respectively (see basic configuration section below).

Installation

.

Basic Configuration

After you have downloaded VS Code, you'll want to take some time to familiarize yourself with its and menus.

The Command Pallete (accessible by typing "shift + command + P") is perhaps the biggest time-saving tool, and is worth exploring.

Shell Commands

On a Windows, you may not need to take any action. But on a Mac, follow to enable VS Code shell commands.

After enabling shell commands, you should be able to use the code command to open files and folders from the command-line:

# open all files and folders in the current working directory:
code .

# open all files and folders in the specified directory, e.g. "path/to/my-project":
code path/to/my-project

Python Syntax Auto-completion

Once configured, the text editor is capable of automatically completing snippets of Python code for you. This helps improve accuracy, and saves time.

When you open a Python file in VS Code, it should prompt you to install the official Python extension (ms-python.python). You are recommended to install this extension to enable Python syntax auto-completion.

Column Selection

If configured, your text editor can also enable vertical text selection. This comes in handy if you have to change multiple lines of text at the same time, including commenting-out many lines at once.

By default, you should be able to achieve column selection functionality in VS Code by pressing "shift + alt" (Windows) or "shift + option" (Mac), then clicking and dragging up or down.

Further Optional Configurations

These are some of the professor's personal VS Code configurations, for your reference. Feel free but not obligated to use them.

Additional Extensions

A sample of the professor's installed extensions (results from running code --list-extensions):

HookyQR.beautify
mechatroner.rainbow-csv
mikestead.dotenv
ms-python.python
sleistner.vscode-fileutils
streetsidesoftware.code-spell-checker
whizkydee.material-palenight-theme
xamm.filepath
yzhang.markdown-all-in-one
code --install-extension HookyQR.beautify
code --install-extension mechatroner.rainbow-csv
code --install-extension mikestead.dotenv
code --install-extension ms-python.python
code --install-extension sleistner.vscode-fileutils
code --install-extension streetsidesoftware.code-spell-checker
code --install-extension whizkydee.material-palenight-theme
code --install-extension xamm.filepath
code --install-extension yzhang.markdown-all-in-one

User Settings

A sample of relevant settings from the professor's settings.json file:

{
  "workbench.activityBar.visible": false,
  "workbench.colorTheme": "Palenight Theme",
  "breadcrumbs.enabled": true,
  "editor.fontSize": 14,
  "editor.wrappingIndent": "none",
  "editor.formatOnPaste": true,
  "editor.formatOnType": true,
  "editor.tabSize": 4,
  "explorer.confirmDragAndDrop": false,
  "explorer.confirmDelete": false,
  "files.trimTrailingWhitespace": true,
  "files.insertFinalNewline": true,
  "files.trimFinalNewlines": true,
  "emmet.showSuggestionsAsSnippets": true,
  "diffEditor.ignoreTrimWhitespace": false,
  "window.zoomLevel": 0,
}

Keybord Shortcuts

Keyboard shortcut overrides:

// Place your key bindings in this file to override the defaults
[
    {
        "key": "cmd+\\",
        "command": "workbench.action.toggleSidebarVisibility"
    },
    {
        "key": "cmd+b",
        "command": "-workbench.action.toggleSidebarVisibility"
    }
]

Python Snippets

Use the command palette and start typing "snippets" to find the "Preferences > Configure User Snippets" setting which should yield a snippets JSON file. Feel free to update yours to include these helpful Python snippets:

{
    // Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
    // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
    // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
    // used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
    // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
    // Placeholders with the same ids are connected.
    // Example:
    // "Print to console": {
    //     "scope": "javascript,typescript",
    //     "prefix": "log",
    //     "body": [
    //         "console.log('$1');",
    //         "$2"
    //     ],
    //     "description": "Log output to console"
    // }

    "Python Function Definition": {
        "prefix": ["def"],
        "body": [
            "def my_func():",
            "    pass"
        ],
        "description": "A function definition in Python."
    },

    "Python Class Constructor": {
        "prefix": ["init", "__init", "defi"],
        "body": [
            "def __init__(self):",
            "    pass"
        ],
        "description": "A class initializer method for Python."
    },

    "Python Main Conditional": {
        "scope": "python",
        "prefix": ["main", "__main"],
        "body": [
            "if __name__ == '__main__':",
            "    pass"
        ],
        "description": "The main conditional for Python."
    }
}
a screenshot of the text editor's autocomplete functionality
a screenshot of the text editor's column selection

You might try searching these manually or via code --install-extension EXTENSION_NAME, where "EXTENSION_NAME" is the extension's identifier (see list above). For example:

See also:

importing them programmatically
https://code.visualstudio.com/docs/editor/userdefinedsnippets
"text editor"
VS Code
Atom
Sublime
Notepad++
Download VS Code
settings
these steps