Table of Contents
1. Quick Navigation
1. Search for files
2. Open settings
3. Switch side Sidebar
4. Navigation tab
5. Navigation tab group
6. Open the terminal
7. Open the command panel
2. Quick selection
1. Select the current line
2. Current selection
3. Current Word
4. Select until the end of the word
5. Select multiple lines of code by dragging the mouse
6. Use arrow keys to select multiple lines of code
3. Quick search
1. Result Navigation
2. Select multiple Results
3. Select all results
4. Code Navigation
1. Jump to the specified line
2. Go to the matching bracket
3. Collapse/expand code blocks
4. Collapse/expand code blocks and sub-code blocks
4. Navigate to Errors and Warnings
5. Move the cursor
1. Insert an extra cursor at a specific position
2. Insert an additional cursor above or below
3. Undo cursor insertion
4. Select Insert the cursor at the end of the code
6. Quick coding
1. Move lines or blocks of code
2. Copy lines or blocks of code
3. Code indentation
4. Switch code comments
5. Switch code block comments
6. Code Format
7. Quickly fix errors
8. Rename
9. Delete whitespace
Home Development Tools VSCode Memorize these VSCode shortcuts to improve your development efficiency!

Memorize these VSCode shortcuts to improve your development efficiency!

Feb 21, 2022 pm 07:43 PM
vscode A shortcut

This article summarizes some VSCode shortcuts recorded in official documents that can improve efficiency. Memorize them to improve development efficiency! !

Memorize these VSCode shortcuts to improve your development efficiency!

Visual Studio Code is one of the most popular and commonly used code editors. It is open source and free to use. It also provides support for multiple languages ​​and frameworks. [Recommended study: "vscode Getting Started Tutorial"]

Note that these Visual Studio Code shortcuts are taken from the VS Code official documentation. If some shortcuts don't work, it may be because the shortcut has changed in the editor or file format, or an extension has been installed that is affecting the shortcut.

1. Quick Navigation

1. Search for files

When you need to search for specific files, and when the project is large, it will take a lot of time. Even if you already know where the file is, using this shortcut key will be very convenient to easily open the file in the project.

  • Windows/Linux: ctrl P
  • macOS: command P

2. Open settings

Visual Studio Code has many features and settings that can be changed as needed. This shortcut makes it easy to open settings when necessary.

  • Windows/Linux: ctrl ,
  • macOS: command ,

3. Switch side Sidebar

Many times, we need more space to place the files we need to process. Therefore, this shortcut key can conveniently show or hide the sidebar.

  • Windows/Linux: ctrl B
  • macOS: command B

When you have many tabs open and need to switch between them, you can use this shortcut key, it will display the tab list and navigate between them, we can select the tab to open.

  • Windows/Linux: ctrl shift tab
  • macOS: control shift tab

Visual Studio Code provides the function of creating a tab group. Tab groups allow us to group tabs, each taking up a portion of the screen. Use this shortcut key to switch between different tab groups. If the tab group selected in the shortcut is greater than the number of groups currently open, this shortcut creates a new group.

  • Windows/Linux : ctrl 1 or 2 or 3
  • macOS: command 1 or 2 or 3

6. Open the terminal

During the development process, the terminal will be used frequently. Visual Studio Code allows us to open a terminal window within the editor. This eliminates the need to switch between the editor and the terminal, allowing us to focus on the editor and code.

  • Windows/Linux: ctrl J
  • macOS: command J

Memorize these VSCode shortcuts to improve your development efficiency!

7. Open the command panel

We can execute many commands in Visual Studio Code. Use this shortcut key to easily open the command palette. The command palette allows searching for available commands and executing them.

  • Windows/Linux: ctrl shift P
  • macOS: command shift P

Memorize these VSCode shortcuts to improve your development efficiency!

2. Quick selection

During the development process, it is often necessary to make selections in the code, including copying, cutting and other operations. Instead of using the mouse, you can save time by using the keyboard. These shortcut keys focus on making selections quickly.

1. Select the current line

You can use this shortcut key to quickly select the entire line of code in the line where the cursor is.

  • Windows/Linux: ctrl L
  • macOS: command L

2. Current selection

Use this shortcut key to only select the text you want to find once, and you can select all this text in the file, so that you can edit these texts at the same time.

  • Windows/Linux : ctrl shift L
  • macOS : command shift L

3. Current Word

This shortcut performs the same action as the shortcut above, but without selecting anything. When the cursor is placed on a word, press this shortcut key to select all positions of this word in the current file.

  • Windows/Linux: ctrl F2
  • macOS: command F2 fn

Memorize these VSCode shortcuts to improve your development efficiency!

4. Select until the end of the word

When you select a portion of the code, you can move and expand the selection of this shortcut. You can use the right or left arrow to go in the direction you want.

  • Windows/Linux : shift alt → or ←
  • macOS : shift option → or ←

5. Select multiple lines of code by dragging the mouse

Drag the cursor over the code to select each line from beginning to end. But you can also use this shortcut to select partial lines of code, but only multiple lines of code you drag.

  • Windows/Linux : shift alt drag the cursor
  • macOS : shift option drag the cursor

6. Use arrow keys to select multiple lines of code

You can also perform the above operations using this shortcut key, but instead of using the mouse, use the arrow keys on the keyboard.

  • Windows/Linux : ctrl shift alt → or ← or ↓ or ↑
  • macOS : command shift option → or ← or ↓ or ↑

Memorize these VSCode shortcuts to improve your development efficiency!

All editors have a search function so that you can search in the current file or multiple files Certain words, such as function or variable names, phrases, or code blocks, etc. Let’s take a look at the shortcut keys related to the search function.

1. Result Navigation

You can use this shortcut key to move between search results in the file.

  • Windows/Linux:F3
  • macOS:F3 fn

2. Select multiple Results

If you want to modify multiple search results, you can use this shortcut key to select multiple contents in the search results in the file. Each time you press this key, one result will be selected, and then you will press Search results are selected in order.

  • Windows/Linux : ctrl D
  • macOS : command D

3. Select all results

If you want to use the search function to modify all search results, this shortcut key can select all search results.

  • Windows/Linux: alt enter
  • macOS: option enter

4. Code Navigation

As a file or project becomes more complex, it becomes increasingly difficult to find certain parts of the code. It can be difficult to manually find errors or go to a certain line of code. The following shortcut keys can save a lot of trouble, allowing us to devote more time to what we really want to do.

1. Jump to the specified line

When you encounter a specified line of code that causes a compilation or runtime error, you can use this shortcut key to jump to this line of code. Just press this Shortcut key, enter the number of lines of code, and press Enter to jump to this line of code. This shortcut is very useful when there is a lot of code in a file.

  • Windows/Linux: ctrl G
  • macOS: control G

Memorize these VSCode shortcuts to improve your development efficiency!

2. Go to the matching bracket

We may need to find the closing bracket of the matching code block. It's difficult when the file is long. Use this shortcut to easily find the closing matching bracket for the current block. In HTML tags, it can be moved to the end of the current tag.

  • Windows/Linux : ctrl shift \
  • macOS : command shift \

3. Collapse/expand code blocks

When files contain a lot of code, we can collapse (hide) a certain code block that we are not currently focusing on so that we can focus on other content. This shortcut key is used to collapse or expand code blocks. Just click anywhere in the code block and press the following keys.

  • Windows/Linux : ctrl shift [or]
  • macOS : command option [or]

4. Collapse/expand code blocks and sub-code blocks

What if a code block contains sub-code blocks? Using the above command will collapse the parent code block, but when the parent code block is expanded, the child code block will remain unchanged. If you need to collapse and expand a code block and its sub-code blocks, you can use this shortcut to do it.

  • Windows/Linux : ctrl K [or]
  • macOS : command K [or]

It is crucial to find the code where errors and warnings occur in your code. This shortcut saves you the trouble of scrolling to find the exact problem. It can go directly to the next error or warning.

  • Windows/Linux:F8
  • macOS:F8 fn

5. Move the cursor

In many cases, it may be necessary to have multiple cursors, each located at a different location in the file. These shortcuts make it easier to move around with multiple cursors.

1. Insert an extra cursor at a specific position

This keyboard shortcut can insert an extra cursor anywhere in the file.

  • Windows/Linux : alt mouse click position
  • macOS: option mouse click position

2. Insert an additional cursor above or below

The second way to insert a cursor is to insert it above or below the current cursor position.

  • Windows/Linux : ctrl alt ↓ or ↑
  • macOS : command option ↓ or ↑

3. Undo cursor insertion

What if the cursor is inserted by mistake, or the cursor is no longer needed at that location? This shortcut undoes the last inserted cursor. This shortcut key is useful when inserting multiple cursors, as it keeps the other cursors in place and deletes the last inserted cursor.

  • Windows/Linux : ctrl U
  • macOS : command U

4. Select Insert the cursor at the end of the code

Use this shortcut key to insert the cursor at the end of each line of selected code.

  • Windows/Linux : shift alt I
  • macOS : shift option I

6. Quick coding

1. Move lines or blocks of code

Many times you need to move one or more lines of code from one location to another. Instead of copying or cutting and pasting the code to another location, this shortcut provides a faster solution by simply placing the cursor over the line of code. If you want to move multiple lines of code, just select the code you want to move and then use this shortcut key.

  • Windows/Linux : alt ↓ or ↑
  • macOS: option ↓ or ↑

2. Copy lines or blocks of code

What if you need to copy one or more lines of code and paste them below or above? Instead of actually copying and pasting the code, this shortcut copies the line below or above it depending on the direction you select with the arrows. If you want to copy multiple lines of code, just select the code to be copied and then use this shortcut key.

  • Windows/Linux : shift alt ↓ or ↑
  • macOS : shift option ↓ or ↑

3. Code indentation

When copying code from one location to another, or when changing code, many times the code will have incorrect indentation. This shortcut allows you to indent the code as needed, or select multiple lines of code to move them together.

  • Windows/Linux : ctrl [or]
  • macOS : command [or]

4. Switch code comments

Use this shortcut key to comment or uncomment the line of code where the cursor is. If you want to comment or uncomment multiple lines of code, you only need to select the multiple lines of code first.

  • Windows/Linux: ctrl /
  • macOS: command /

Memorize these VSCode shortcuts to improve your development efficiency!

5. Switch code block comments

Different from the above shortcut keys, the following shortcut keys will comment the selected multiple lines of code into a single comment.

  • Windows/Linux : shift alt A
  • macOS : shift option A

Memorize these VSCode shortcuts to improve your development efficiency!

6. Code Format

For readability reasons, it is important to maintain the format specified by the code. Visual Studio Code provides two shortcut commands for code formatting.

The following shortcut keys can format the code in the entire file:

  • Windows/Linux: ctrl shift F
  • macOS : option shift F

The following shortcut keys can format the selected code:

  • Windows/Linux : ctrl K, then ctr l F
  • macOS : command K, then command F

7. Quickly fix errors

In many cases, if a common or simple error, Visual Studio Code can fix it directly - such as a missing semicolon. If Quick Fix is ​​available, this shortcut can quickly fix errors or warnings.

  • Windows/Linux : ctrl .
  • macOS : command .

8. Rename

It is easy to make mistakes if you manually rename variables, functions or classes that are used multiple times. This shortcut provides a safe way to rename any symbol.

  • Windows/Linux: F2
  • macOS: F2 fn

9. Delete whitespace

You can use the following shortcut keys to delete extra blank lines:

  • Windows/Linux : ctrl K X
  • macOS : command K
10. Change the programming language

By default, Visual Studio Code detects the programming language of the file being processed. Usually, it's done by checking the file's extension. However, if the file's extension is not supported, the language may not be detected correctly. Therefore, when you need to change the programming language of a file, you can use this shortcut key.

Windows/Linux
    : ctrl K, then press M
  • macOS
  • : command K, then press M
  • 7. Better Coding
1. Go to the definition

Many times, we need to understand the definition of the code we are using. For example, when calling a function and want to know how the function is defined, you can use this shortcut key.

Windows/Linux
    :F12
  • macOS
  • :F12 fn
  • 2. View definition
This shortcut key can open the definition where the definition is checked. This makes it easier to view definitions without having to switch to another file or line of code.

Windows/Linux
    : alt F12
  • macOS
  • : option F12 fn

3. Switch suggestionsMemorize these VSCode shortcuts to improve your development efficiency!

When writing code, VS Code or some extensions will display code suggestions. This shortcut lets you quickly toggle code suggestions to view or hide them.

Windows/Linux
    : ctrl I
  • macOS
  • : command I
  • VS Code is currently One of the best code editors. It provides many out-of-the-box features and rich third-party extensions. Using shortcut keys in VS Code can make development easier, allowing us to focus on writing high-quality code in less time. This article introduces some practical Visual Studio Code shortcut keys, hoping to help you improve development efficiency!
Finally, here are the shortcut keys for VS Code in Windows, Linux, and macOS systems:

Memorize these VSCode shortcuts to improve your development efficiency!

Memorize these VSCode shortcuts to improve your development efficiency!

For more knowledge about VSCode, please visit: 1Memorize these VSCode shortcuts to improve your development efficiency!vscode tutorial

! !

The above is the detailed content of Memorize these VSCode shortcuts to improve your development efficiency!. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to define header files for vscode How to define header files for vscode Apr 15, 2025 pm 09:09 PM

How to define header files using Visual Studio Code? Create a header file and declare symbols in the header file using the .h or .hpp suffix name (such as classes, functions, variables) Compile the program using the #include directive to include the header file in the source file. The header file will be included and the declared symbols are available.

What computer configuration is required for vscode What computer configuration is required for vscode Apr 15, 2025 pm 09:48 PM

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

vscode terminal usage tutorial vscode terminal usage tutorial Apr 15, 2025 pm 10:09 PM

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

Where to write code in vscode Where to write code in vscode Apr 15, 2025 pm 09:54 PM

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

How to solve the problem of vscode Chinese annotations becoming question marks How to solve the problem of vscode Chinese annotations becoming question marks Apr 15, 2025 pm 11:36 PM

How to solve the problem that Chinese comments in Visual Studio Code become question marks: Check the file encoding and make sure it is "UTF-8 without BOM". Change the font to a font that supports Chinese characters, such as "Song Style" or "Microsoft Yahei". Reinstall the font. Enable Unicode support. Upgrade VSCode, restart the computer, and recreate the source file.

Common commands for vscode terminal Common commands for vscode terminal Apr 15, 2025 pm 10:06 PM

Common commands for VS Code terminals include: Clear the terminal screen (clear), list the current directory file (ls), change the current working directory (cd), print the current working directory path (pwd), create a new directory (mkdir), delete empty directory (rmdir), create a new file (touch) delete a file or directory (rm), copy a file or directory (cp), move or rename a file or directory (mv) display file content (cat) view file content and scroll (less) view file content only scroll down (more) display the first few lines of the file (head)

vscode terminal command cannot be used vscode terminal command cannot be used Apr 15, 2025 pm 10:03 PM

Causes and solutions for the VS Code terminal commands not available: The necessary tools are not installed (Windows: WSL; macOS: Xcode command line tools) Path configuration is wrong (add executable files to PATH environment variables) Permission issues (run VS Code as administrator) Firewall or proxy restrictions (check settings, unrestrictions) Terminal settings are incorrect (enable use of external terminals) VS Code installation is corrupt (reinstall or update) Terminal configuration is incompatible (try different terminal types or commands) Specific environment variables are missing (set necessary environment variables)

vscode Previous Next Shortcut Key vscode Previous Next Shortcut Key Apr 15, 2025 pm 10:51 PM

VS Code One-step/Next step shortcut key usage: One-step (backward): Windows/Linux: Ctrl ←; macOS: Cmd ←Next step (forward): Windows/Linux: Ctrl →; macOS: Cmd →

See all articles