DEV Community

Cover image for Say No to Mouse: Vs code shortcuts for easing coding
keshav Sandhu
keshav Sandhu

Posted on

Say No to Mouse: Vs code shortcuts for easing coding

Using keyboard shortcuts in VS Code can greatly improve your productivity by reducing the need for a mouse and speeding up navigation, editing, and other common tasks. Here’s a list of some essential VS Code shortcuts and tricks to help you code more efficiently:

1. Basic Navigation

  • Open Command Palette: Ctrl + Shift + P (or Cmd + Shift + P on Mac)

    Quickly access commands or search for actions.

  • Open File/Folder: Ctrl + P (or Cmd + P on Mac)

    Quickly open a file by typing its name.

  • Toggle Sidebar (Explorer, Search, etc.): Ctrl + B (or Cmd + B on Mac)

    Hide or show the sidebar to save screen space.

  • Navigate Between Open Tabs:

    • Next Tab: Ctrl + Tab
    • Previous Tab: Ctrl + Shift + Tab
  • Go to Definition: F12


    Jumps to the definition of a function, variable, or class.

  • Peek Definition: Alt + F12 (or Option + F12 on Mac)


    Opens a small window with the definition without navigating away.

  • Go to Line: Ctrl + G (or Cmd + G on Mac)


    Jump to a specific line in the current file.

  • Open/Close Integrated Terminal: Ctrl + ~ (or Cmd + ~ on Mac)


    Quickly toggle the integrated terminal.

2. Editing Shortcuts

  • Copy Line Up/Down: Alt + Shift + Up/Down (or Option + Shift + Up/Down on Mac)

    Copy the current line up or down.

  • Move Line Up/Down: Alt + Up/Down (or Option + Up/Down on Mac)

    Move the current line or block of code up or down.

  • Delete Line: Ctrl + Shift + K (or Cmd + Shift + K on Mac)

    Instantly delete the current line.

  • Duplicate Line: Shift + Alt + Down (or Shift + Option + Down on Mac)

    Duplicate the selected line or block of code.

  • Select All Occurrences of Word: Ctrl + D (or Cmd + D on Mac)

    Select the next occurrence of the word under the cursor for multi-cursor editing.

  • Select All Occurrences in File: Ctrl + Shift + L (or Cmd + Shift + L on Mac)

    Select all instances of the selected word or variable in the file.

  • Expand/Contract Selection: Shift + Alt + Right/Left (or Cmd + Shift + Right/Left on Mac)

    Expand or shrink the selection based on syntax context (useful for selecting entire functions, blocks, or HTML tags).

  • Multi-Cursor Editing:

    • Add Cursor Below: Ctrl + Alt + Down (or Cmd + Option + Down on Mac)
    • Add Cursor Above: Ctrl + Alt + Up (or Cmd + Option + Up on Mac) This allows you to add multiple cursors for editing in multiple places at once.
  • Jump to Matching Bracket: Ctrl + Shift + </code> (or Cmd + Shift + </code> on Mac)


    Moves the cursor to the matching bracket (useful for nested code).

3. Refactoring and Code Formatting

  • Rename Symbol: F2

    Renames the selected symbol throughout the codebase.

  • Format Document: Shift + Alt + F (or Cmd + Option + F on Mac)

    Automatically formats the entire document based on the language’s conventions (can be configured in settings).

  • Auto-Import Suggestions: Ctrl + . (or Cmd + . on Mac)

    Show quick fix options like importing a missing module.

  • Toggle Comment Line: Ctrl + / (or Cmd + / on Mac)

    Quickly comment/uncomment a line.

  • Comment/Uncomment Block: Shift + Alt + A (or Cmd + Option + A on Mac)

    Comment or uncomment an entire block of code.

4. Search and Replace

  • Find: Ctrl + F (or Cmd + F on Mac)

    Opens the search box to find text in the current document.

  • Find and Replace: Ctrl + H (or Cmd + H on Mac)

    Opens the search and replace panel.

  • Find All Occurrences in Workspace: Ctrl + Shift + F (or Cmd + Shift + F on Mac)

    Searches for text across the entire workspace.

  • Replace in Files: Ctrl + Shift + H (or Cmd + Shift + H on Mac)

    Replaces occurrences across files in the workspace.

5. File and Workspace Management

  • Quickly Toggle Between Open Editors: Ctrl + 1, 2, 3...

    Switch between multiple editor groups using the number keys.

  • New File: Ctrl + N (or Cmd + N on Mac)

    Creates a new file.

  • Close Current Editor: Ctrl + W (or Cmd + W on Mac)

    Closes the current tab/editor.

  • Split Editor: Ctrl + \ (or Cmd + \ on Mac)

    Splits the editor into multiple views.

  • Reopen Closed Tab: Ctrl + Shift + T (or Cmd + Shift + T on Mac)

    Reopens the last closed tab.

  • Cycle Between Editors: Ctrl + PageUp/PageDown

    Switches between open tabs.

6. Git and Source Control

  • Open Git View: Ctrl + Shift + G (or Cmd + Shift + G on Mac)

    Opens the Git source control view.

  • Stage All Changes: Ctrl + Shift + A

    Stages all the changed files for commit.

  • Commit Staged Changes: Ctrl + Enter (or Cmd + Enter on Mac)

    Commits staged changes with a message.

  • View Git Diff: Ctrl + D

    Opens a diff view to compare file changes.

7. Terminal Shortcuts

  • New Terminal Instance: Ctrl + Shift + (or Cmd + Shift + on Mac)

    Opens a new terminal window.

  • Switch Terminal Tabs: Ctrl + PageUp/PageDown

    Move between multiple terminal tabs.

  • Focus on Terminal: Ctrl + (or Cmd + on Mac)

8. Extensions & Debugging

  • Open Extensions View: Ctrl + Shift + X (or Cmd + Shift + X on Mac)

    Opens the Extensions sidebar where you can install or manage extensions.

  • Start Debugging: F5

    Starts the debugger based on the selected configuration.

  • Step Over: F10

    Steps over to the next line during debugging.

  • Step Into: F11

    Steps into the function during debugging.


Tips & Tricks for Efficiency

  • Zen Mode: Ctrl + K Z (or Cmd + K Z on Mac)

    Enter Zen Mode to remove all distractions (hide all sidebars, status bars, and tabs).

  • Change All Occurrences: Select a word and press Ctrl + Shift + L (or Cmd + Shift + L on Mac) to select all occurrences in the file, making bulk edits faster.

  • Go to File Symbol: Press Ctrl + Shift + O (or Cmd + Shift + O on Mac) to jump to functions, classes, or symbols within a file.

By mastering these shortcuts and tricks, you'll be able to navigate, edit, and refactor code more quickly, reducing the reliance on the mouse and enhancing your overall productivity.

Top comments (0)