当前位置:网站首页>20 shortcut keys for vs code!

20 shortcut keys for vs code!

2022-06-12 20:10:00 wx61f365eb1f9fc


VS Code We must know and we will 20 Shortcut key !_ Right click

author  | Deepak Gupta

translator |  Da Luo , Coordinating editor | Guo Lei

This article article , Hope it can help developers use it more efficiently VS Code Programming .


The following is the translation :


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 .

Multi line to one line

VS Code We must know and we will 20 Shortcut key !_ Shortcut key _02


  • stay MAC On :Ctrl + J


  • stay Ubuntu/Windows On : adopt File​​Preferences​​ > Keyboard shortcuts​​ Open shortcut key settings , And bind editor.action.joinLines​​ Your own shortcut .

formatting code

This shortcut can help us indent the code .VS Code We must know and we will 20 Shortcut key !_ubuntu_03 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



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 .VS Code We must know and we will 20 Shortcut key !_ Shortcut key _04 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 on The icon in the upper right corner switches to code editing mode ;


VS Code We must know and we will 20 Shortcut key !_ubuntu_05



  • add to "files.trimTrailingWhitespace": true​​ To 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 :VS Code We must know and we will 20 Shortcut key !_ubuntu_06

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 .VS Code We must know and we will 20 Shortcut key !_ubuntu_07

Collapse the unfolded code at the cursor :


  • stay Windows/Ubuntu On :​Ctrl + Shift + [


  • stay Mac On :​Command+ Option + [


Expand the cursor to display the folded code :


  • stay Windows/Ubuntu On :​Ctrl + Shift + ]


  • stay Mac On :​Command+ Option + ]

Up / Down Copy line

VS Code We must know and we will 20 Shortcut key !_ Shortcut key _08


  • 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

Split edit box

VS Code We must know and we will 20 Shortcut key !_ Shortcut key _09


  • 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 .

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 :

VS Code We must know and we will 20 Shortcut key !_ Right click _10

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 :

VS Code We must know and we will 20 Shortcut key !_ Shortcut key _11

Select the word VS Code We must know and we will 20 Shortcut key !_ Right click _12


  • stay Windows On :Ctrl+ d


  • stay Mac On : Command + d




  • stay Ubuntu On : Ctrl+ d


If you repeatedly Click on This shortcut key , Multiple keywords that are the same will be selected .

Open and close the sidebar

VS Code We must know and we will 20 Shortcut key !_ Right click _13


  • 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 .

Jump to a specific line

VS Code We must know and we will 20 Shortcut key !_ Right click _14

notes : Line jump in file , You can use ​​Ctrl + G , Then enter the line number to jump , Of course , You can also use Ctrl + P, Then input And the line number to jump .


  • stay Windows On :Ctrl + g


  • stay Mac On :Ctrl + g​​ orCtrl + p


  • stay Ubuntu On :Ctrl + g

Symbol jump in file

VS Code We must know and we will 20 Shortcut key !_ Right click _15

stay Windows On :​​Ctrl + Shift + o stay Mac On :Command + Shift+ o stay Ubuntu On :Ctrl + Shift + o You can also group by colons :@:VS Code We must know and we will 20 Shortcut key !_ubuntu_16

Workspace symbol jump VS Code We must know and we will 20 Shortcut key !_ Right click _17


  • stay Windows On :Ctrl + t


  • stay Mac On :Command + t


  • stay Ubuntu On :Ctrl + t


Delete the last word

VS Code We must know and we will 20 Shortcut key !_ Right click _18


  • 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 .

Selected words

VS Code We must know and we will 20 Shortcut key !_ Shortcut key _19


  • 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 .

Copy line

VS Code We must know and we will 20 Shortcut key !_ Right click _20


  • 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 .

Delete row

VS Code We must know and we will 20 Shortcut key !_ Right click _20


  • stay Windows On :​Ctrl + x


  • stay Mac On :​Command + x


  • stay Ubuntu On :​Ctrl + x



Add multiple cursors

VS Code We must know and we will 20 Shortcut key !_ubuntu_22


  • 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 .

rename

VS Code We must know and we will 20 Shortcut key !_ Right click _23


  • stay Windows On :​F2


  • stay Mac On :​F2


  • stay Ubuntu On :​F2


Select the variable , Press ​F2​, References in the context are renamed .

Block selection

VS Code We must know and we will 20 Shortcut key !_ubuntu_24


  • 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 .

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 .VS Code We must know and we will 20 Shortcut key !_ Right click _25

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 :VS Code We must know and we will 20 Shortcut key !_ Shortcut key _26

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


原网站

版权声明
本文为[wx61f365eb1f9fc]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202281502235165.html