vscode Common Shortcuts

Keywords: IDE Visual Studio Code


There are too many shortcuts in vscode to be dazzling, but we only need to remember a few commonly used shortcuts to improve development efficiency, so summarize them and bold them to help improve efficiency.

1. Main Command Box

F1 or Ctrl+Shift+P (commonly known as the omnipotent key): Open the command panel. In the open input box, you can enter any command

Ctrl+P:

Click Backspace to enter Ctrl+P Go mode

Enter > under Ctrl+P to enter Ctrl+Shift+P mode

You can also enter a file name directly under the Ctrl+P window and jump to the file

Entering "?" in Ctrl+P mode will pop up the drop-down menu

SymbolEffect
?List current actions that can be executed
!Display Errors or Warnings, or Ctrl+Shift+M
:Jump to the number of lines, or Ctrl+G directly
@Jump to symbol (search for variables or functions), or Ctrl+Shift+O directly
@Jump symbol s by category, find attributes or functions, or enter':'after Ctrl+Shift+O
#Find a symbol by name, or Ctrl+T

2. Code Editor

2.1 Code format correlation

Shortcut keysEffect
Ctrl+[, Ctrl+]Code line indentation
Ctrl+Shift+[, Ctrl+Shift+]Collapse Open Code Block
Ctrl+C Ctrl+VCopy and paste, or copy and paste a line if no text is selected
Shift+Alt+FFormatter
Alt+Up,Alt+DownMove up and down a line
Shift+Alt+Up,Shift+Alt+DownCopy a row up and down
Ctrl+Shift+EnterInsert a row above the current row (cursor moves to the new row after insertion)

2.2 Cursor correlation

Shortcut keysEffect
Ctrl+Shift+LSelect all matches
Ctrl+DCheck Match
Ctrl+UCursor Return
Alt+Shift+Left Mouse KeyMulti-line editing (column editing)
Shift+EndSelect from cursor to end of line
Shift+HomeSelect from the beginning of the line to the cursor
HomeMove to the beginning of the line:
EndMove to End of Line
F12Move to Definition
Alt+F12View thumbnails at definitions (just take a look without jumping around)
Ctrl+DeleteDelete everything to the right of the cursor (current line)
Shift+Alt+Right and Shift+Alt+LeftExpand/Reduce Selection

2.3 Refactoring Code

Find all references: Shift+F12

Also modify all matches in this file: Ctrl+F2

Jump to the next Error or Warning: You can press F8 to jump one by one when there are multiple errors

3. Show correlation

Zoom in or out (based on the top left corner of the editor): Ctrl +/-

Sidebar Show or Hide: Ctrl+B

Display Explorer (cursor cut to sidebar only works): Ctrl+Shift+E

Show Debug: Ctrl+Shift+D

Show Output: Ctrl+Shift+U

4. Modify default shortcuts

Method 1: Open the default keyboard shortcut settings: File -> Preferences -> Keyboard Shortcuts (when Chinese interface is:'File'->'Preferences'->'Keyboard Shortcuts'), or Alt+F -> P -> K -> Enter
Method 2: Click "keybindings.json" at the bottom of the search bar to enter the editing interface
There is a certain way to write the corresponding rules, as follows:

// Put key bindings in this file to override defaults
[{
    "key": "f8",
    "command": "workbench.action.tasks.runTask",
    "args": "build",
    "when": "editorTextFocus"
}
]

key    A key representing a binding

command    Represents an executed command

args    The parameters of the command, where we are build Compile Task

when    When the shortcut key takes effect, this refers to the edit area

Save, you try to press F8,The task ran smoothly.

A blogger's "keybindings.json" file is referenced below (use with caution):

// Place your key bindings in this file to overwrite the defaults
[
    // ctrl+space occupied by toggle input method shortcuts
    {
        "key": "ctrl+alt+space",
        "command": "editor.action.triggerSuggest",
        "when": "editorTextFocus"
    },
    // ctrl+d deletes a row
    {
        "key": "ctrl+d",
        "command": "editor.action.deleteLines",
        "when": "editorTextFocus"
    },
    // Interchange with shortcut key to delete a line
    {
        "key": "ctrl+shift+k",
        "command": "editor.action.addSelectionToNextFindMatch",
        "when": "editorFocus"
    },
    // ctrl+shift+/multiline comment
    {
        "key":"ctrl+shift+/",
        "command": "editor.action.blockComment",
        "when": "editorTextFocus"
    },
    // Customize the same case conversion shortcuts as sublime
    editor.action.transformToLowercase
    editor.action.transformToUppercase
    {
        "key": "ctrl+k ctrl+u",
        "command": "editor.action.transformToUppercase"
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+k ctrl+l",
        "command": "editor.action.transformToLowercase"
        "when": "editorTextFocus"
    }
]

Don't forget that station b pays attention to what Jiaran eats today, the Evening Devil, Bela kira, Nayline Queen, Carol~

Posted by mikkex on Sat, 27 Nov 2021 09:45:32 -0800