当前位置:网站首页>Vs code must know and know 20 shortcut keys!
Vs code must know and know 20 shortcut keys!
2022-07-29 03:34:00 【Luo Zhaocheng CSDN】
The original English text :20 VS Code Shortcuts for Faster Coding
author :Deepak Gupta
translator : Da Luo
This article , Hope it can help developers use it more efficiently VS Code Programming .
Not every developer has enough time , To get familiar with all the shortcuts , To help us improve coding efficiency . Because there are too many shortcut keys .
therefore , Below I list my favorite shortcuts .
One 、 Multi line to one line

- stay MAC On :
Ctrl + J - stay Ubuntu/Windows On : adopt
File>Preferences>Keyboard shortcutsOpen shortcut key settings , And bindeditor.action.joinLinesYour own shortcut .
Two 、 formatting code
This shortcut can help us indent the code .

notes : You can use it at any time of coding , But I prefer to format it when my code is finished .
- stay Windows On :
Shift + Alt + F - stay Mac On :
Shift + Option + F - stay Ubuntu On :
Ctrl + Shift + I
3、 ... and 、 Remove trailing spaces
This shortcut key can help you remove the extra space in front and back , So you don't have to use strict Lint Checked .

notes : I suggest that when you finish writing the code , Use this shortcut .
in fact , This shortcut key needs to be configured by yourself :
- Open the user settings page (
Preferences>Settings>User TAB) - Click the icon in the upper right corner to switch to code editing mode

- add to
"files.trimTrailingWhitespace": trueTo settings file - Save your settings file
If you are using a new version VS Code, You can set up... On the user settings page , Here's the picture :

Four 、 Code folding
Sometimes , The code file is very large , But you just want to know the general logic of the code . At this time, code folding is very necessary .

- Collapse the unfolded code at the cursor
- stay Windows/Ubuntu On :
Ctrl + Shift + [ - stay Mac On :
Command+ Option + [
- stay Windows/Ubuntu On :
- Expand the cursor to display the folded code
- stay Windows/Ubuntu On :
Ctrl + Shift + ] - stay Mac On :
Command+ Option + ]
- stay Windows/Ubuntu On :
5、 ... and 、 Up / Down Copy line

- stay Windows On :
Shift + Alt + Up/Down - stay Mac On :
Shift + Option + Up/Down - stay Ubuntu On :
Ctrl + Shift + Alt + Up/Down
Of course , You can also set and bind your own shortcut keys :File > Preferences > Keyboard Shortcuts
6、 ... and 、 Split edit box

- stay Windows On :
Shift + Alt + \ or 2,3,4 - stay Mac On :
Command + \ or 2,3,4 - stay Ubuntu On :
Shift + Alt + \ or 2,3,4
The split editor can use the shortcut keys for splitting . Use 123 You can also switch the editor focus .
Of course, you can also bind your own shortcut keys .
7、 ... and 、 Editor grid layout
By default , Vertical column layout used in the editor interface ( When you split the editor , By default, it opens on the side ) You can also easily layout horizontally and vertically according to your preferences :

To support a more flexible layout , You can create an empty editor group . By default , When you close the last edit window , The group will also be closed , But you can use the following configuration to turn off this default behavior :
"workbench.editor.closeEmptyGroups": false
stay View > Edit Layout On the menu , There are also preset layouts :

8、 ... and 、 Select the word

- stay Windows On :
Ctrl+ d - stay Mac On :
Command + d - stay Ubuntu On :
Ctrl+ d
If you click this shortcut multiple times , Multiple keywords that are the same will be selected .
Nine 、 Open and close the sidebar

- stay Windows On :
Ctrl+ b - stay Mac On :
Command + b - stay Ubuntu On :
Ctrl+ b
occasionally , The code width in the file is relatively large , Closing the sidebar allows for greater code visibility .
Ten 、 Jump to a specific line

notes : Line jump in file , You can use
Ctrl + G, Then enter the line number to jump , Of course , You can also useCtrl + P, Then input:And the line number to jump
- stay Windows On :
Ctrl + g - stay Mac On :
Ctrl + gorCtrl + p - stay Ubuntu On :
Ctrl + g
11、 ... and 、 Symbol jump in file

- stay Windows On :
Ctrl + Shift + o
- stay Mac On :
Command + Shift+ o - stay Ubuntu On :
Ctrl + Shift + o
You can also group by colons :@:

Twelve 、 Workspace symbol jump

- stay Windows On :
Ctrl + t - stay Mac On :
Command + t - stay Ubuntu On :
Ctrl + t
13、 ... and 、 Delete the last word

- stay Windows On :
Ctrl + backspace - stay Mac On :
Option + delete - stay Ubuntu On :
Ctrl + backspace
This function is very useful when you enter an error , You don't need to hold delete Delete one by one .
fourteen 、 Selected words

- stay Windows On :
Ctrl + Shift + Right click / Left key head - stay Mac On :
Option + Shift + Right click / Left key head - stay Ubuntu On :
Ctrl + Shift + Right click / Left key head
This shortcut key helps you quickly select and edit .
15、 ... and 、 Copy line

- stay Windows On :
Ctrl + Shift + d - stay Mac On :
Command + Shift +d - stay Ubuntu On :
Ctrl + Shift + d
Copying rows is a very powerful function .
sixteen 、 Delete row

- stay Windows On :
Ctrl + x - stay Mac On :
Command + x - stay Ubuntu On :
Ctrl + x
seventeen 、 Add multiple cursors

- stay Windows On :
Ctrl + Alt + Up/Down - stay Mac On :
Command + Alt + Up / Down - stay Ubuntu On :
Ctrl + Alt + Up / Down
The copy cursor is VS Code One of the features in , Can save a lot of time .
eighteen 、 rename

- stay Windows On :
F2 - stay Mac On :
F2 - stay Ubuntu On :
F2
Select the variable , Press F2, References in the context are renamed
nineteen 、 Block selection

- stay Windows On :
Shift + Alt - stay Mac On :
Shift + Option - stay Ubuntu On :
Shift + Alt
You can press and hold the shortcut key above , Then drag the mouse , Select a text block , The cursor is added to each selected row .
twenty 、 Command Panel
- stay Windows On :
Ctrl + p - stay Mac On :
Command + p - stay Ubuntu On :
Ctrl + p
Access available commands based on your current context .
Here are some common commands :
1. Open file
When you want to open a file , Use the following command , Then enter the file name , It can help you jump to files quickly .

2. Check out the shortcuts
All commands can be seen in the command panel , And there are shortcut key binding relationships ( If there are shortcut keys ), If you forget the shortcut , You can use it to query :

Conclusion
There are many shortcut keys to meet your needs , ad locum , I listed all VS Code Fast key PDF file :
Linux: https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf
Window: https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf
macOS: https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf
边栏推荐
- Makefile details
- Suffix automata (SAM) board from Jly
- Set functions in kotlin
- Target detection, industrial defects, image segmentation -- deep learning data set induction
- Machine learning based on deepchem
- Design of smoke temperature, humidity and formaldehyde monitoring based on single chip microcomputer
- HDU多校第二场 1011 DOS Card
- 正则表达绕过waf
- 1.5 nn. Module neural network (III)
- (nowcoder22529C)dinner(容斥原理+排列组合)
猜你喜欢

Rdkit II: use rdkit screening to screen 2D pharmacophores of chemical small molecules

Sleuth+Zipkin 来进行分布式服务链路的追踪

During the year, the first "three consecutive falls" of No. 95 gasoline returned to the "8 Yuan era"“

mysql的timestamp存在的时区问题怎么解决

数字孪生实际应用案例-智慧能源篇
![MOS tube - rapid recovery application notes (II) [parameters and applications]](/img/54/eb040a51304192def8cfb360c7c213.png)
MOS tube - rapid recovery application notes (II) [parameters and applications]

ShardingSphere之水平分表实战(三)

Asynchronous callback future mode of concurrent mode

Rongyun IM & RTC capabilities on new sites

A case of gradually analyzing the splitting of classes -- colorful ball collisions
随机推荐
During the year, the first "three consecutive falls" of No. 95 gasoline returned to the "8 Yuan era"“
1.4 nn. Module neural network (II)
深入C语言(3)—— C的输入输出流
04 | background login: login method based on account and password (Part 1)
Understanding of p-type problems, NP problems, NPC problems, and NP hard problems in natural computing
深入C语言(2)——结构的定义与使用
Exness: dove resolution helped gold rebound, and the focus turned to U.S. GDP
Use of leak scanning (vulnerability scanning) tool burpsuite or burp Suite (with installation and installation package download of burpsuite+1.7.26)
(codeforce547)C-Mike and Foam(质因子+容斥原理)
Sleuth+Zipkin 来进行分布式服务链路的追踪
Matlab learning - accumulation of small knowledge points
How to realize multi line annotation in MATLAB
Suffix automata (SAM) board from Jly
(nowcoder22529c) diner (inclusion exclusion principle + permutation and combination)
Simple understanding of CDN, SDN and QoS
军品研制过程-转阶段
Division of data link layer, protocols used in data link layer and detailed introduction
安装抓包证书
今晚7:30 | 连界、将门、百度、碧桂园创投四位大佬眼中的AI世界,是继续高深还是回归商业本质?...
Idea configuration web container and war packaging