In the process of business development, we can improve the development efficiency through some keyboard shortcuts provided by the editor. This paper mainly summarizes the shortcut keys of VScode in the MAC environment (default shortcut keys, if there is a change of keys may conflict), and analyzes the appropriate scenarios to explain how to improve the efficiency.
In my opinion, the shortcut keys do not need to be memorized by rote, but should be developed by hand. Practice makes perfect, just like typing. I believe that most people will not pay attention to the keyboard now. Over time, we develop muscle memory, which again increases our productivity.
This paper has done some classification for shortcut keys, with effect pictures to deepen the impression, as well as part of the scene analysis, to explain the use of some shortcut keys, because some missing scenes will make you feel not necessarily good. For example, I often use CMD + X to delete the clipboard. However, when the clipboard already has the previous code and I want to delete it again, using CMD + X will overwrite the content of the clipboard. In this case, I can use CMD + Shift + K to delete the clipboard without overwriting it.
The cursor type
Move the cursor to the tail lines (the beginning end | | | first)
CMD + [write | left | please | -]Copy the code
Using this shortcut key can reduce the number of clicks of the mouse, improve the coding fluency, and after skilled use, the efficiency is faster than the mouse.
Add the cursor above and below the line
CMD + opt + [write | left]Copy the code
As shown above, the efficiency of using this method is significantly higher than that of making changes one by one. The premise is that the changes must have something in common. Otherwise, it is recommended to use the mouse click, as described below.
Adds multiple cursors to the specified location
Opt + Left mouse buttonCopy the code
Add the cursor above and below the above line. This method is better suited for irregular scenarios.
Select the cursor to the lines (the beginning end | | | first tail)
CMD + shift + [write | left | please | -]Copy the code
Text selection can be carried out without the mouse, and row selection has obvious advantages. However, if you want to select the whole line but the cursor is not at the beginning or end, it is more convenient to select one by one in the following paragraphs. *
One by one to choose
Control + shift + [please | -]Copy the code
It is better to select from text, and more efficient to select a full line or a string of content.
Word by word matches (case insensitive) and follows the cursor
cmd + D
Copy the code
This method is more suitable after the current location is selected. If you need to select all of the current files, it is faster to use the following full-text match, but in the example above, it is more suitable when the previous one does not need to be modified.
Word current page full text matches (case insensitive) trailing cursor
cmd + shift + L
Copy the code
This method is case-insensitive and applies to all page modifications.
Words to delete
opt + delete
Copy the code
Compared to normal delete, this method can be faster (after all, there are fewer delete key times), to delete the entire row, you can choose CMD + X or CMD + Shift + K. This method also works on the command line.
Cursor jumps in {}
cmd + shift + \
Copy the code
This method is easy to view the current function content when the method code is too much, you can also choose vscode plug-in to clear parentheses, in terms of view, should be more efficient.
Adds a line and moves the cursor to the beginning of the line
CMD + Shift + EnterCopy the code
Probably a lot of times you go back to the end of the previous line and enter, but this is more efficient when the length of the line is different. Return to front for short.
The text class
Row (up and down) copy
Shift + opt + [write | left]Copy the code
This method has fewer operations than the normal method. General operations, line selection, line copy, Enter, paste.
Row (up and down) movement
Opt + [write | left]Copy the code
As above, the general operations are to cut the current line, move the cursor up or up, enter, and paste. Or use the front carriage return above to reduce the action by one step.
Line to delete
cmd + shift + K
Copy the code
CMD + X clipboard clipboard clipboard clipboard clipboard clipboard clipboard clipboard Of course, you can also use CMD + delete if the cursor is at the end of the line
Comment line
cmd + /
Copy the code
This method should be used by most people. If not, you can get the method, which is written here mainly for comparison with the following block comment.
Block comments
shift + opt + A
Copy the code
In contrast to line annotations, line numeric methods are less applicable when you want to annotate content in the middle of a line. This method is efficient and much faster than manually typing /* */.
Auto wrap [for display only, does not affect the actual code]
opt + Z
Copy the code
This method is used for display only and does not change the original text, which is convenient when reading too much content.
Save all files (edited but not saved files)
cmd + opt + S
Copy the code
Instead of opening each unsaved page separately, you can save all of them directly. But you may have formed a habit of writing after the habit of CMD + S to save, this method may not be very practical.
Return to the previous position of the cursor
control + '-'
Copy the code
This method is useful when viewing libraries. To view the method definition of the place can ** CMD + left key **, but in the same file, the content is too long, want to continue to look at the time, back to a position is very troublesome, this method is very useful at this time.
The view class
Open a new editor (Window)
cmd + shift + N
Copy the code
Select the new window shortcut key for vscode files.
Open a new project
cmd + O
Copy the code
Select open for vscode files.
The new file
cmd + N
Copy the code
Creates a new file at the level of the current file. The first line of input can be used for the file name or can be modified. Can be left to find the right click to create.
Save the current file as
cmd + shift + S
Copy the code
Associated with CMD + N above, the above method will be saved in the same directory as the current file. This method can be modified to move the file once.
Close the current window | open before closing the file
cmd + W | cmd + shift + T
Copy the code
If the file window is not needed, you can directly close it by CMD + W, but sometimes you need to close it by mistake. If there are too many files and directories, especially in node_modules, you can use CMD + Shift + T to restore it.
Open command line
control + ~
Copy the code
The command line corresponding to the current root directory will be opened in vscode, saving the time to find the path. ** CMD + shift + C ** if you want to open it in the native command line, you can directly go to the root directory.
Move the current file to a new group
CMD + control + (please | -)Copy the code
The previous operation is to open the function on the side in the upper right corner of vscode, but there is still one left. It needs to be closed again. This method can be directly moved to the right side, ← can be undone.
Left sidebar show/hide
cmd + b
Copy the code
Sometimes when the screen is not enough, the sidebar takes up a lot of space, which can be closed. The most commonly used method may be to click the file icon in the upper left corner to fold, which is faster and does not require mouse operation.
Find the file and open it
cmd + P
Copy the code
File search shortcut, but the method does not support directory search, if you want to carry out directory search, directly put the hot area to the left directory, and then directly input search.
Select and open the file TAB in the current group to select, open it
control + tab
Copy the code
Similar to The Window application switch, like chrome TAB switch, when you need to switch files, you can no longer use the mouse.
Enter the line number to jump to the number of lines corresponding to the currently open file
control + G
Copy the code
Jump directly to the corresponding line, you can use CMD + P to find the file, and then control + G to find the corresponding code.
Search class
Global search
cmd + shift + F
Copy the code
Search supports regular matching and is even more effective when replaced.
Global replacement
cmd + shift + H
Copy the code
In the example above, it might feel like simply replacing @/hooks with @dian/hooks, which it is, but replacing the tail is not easy if you want to filter the methods in it. At this point, you can filter in the re. This method can also be previewed to see if the regees meet the criteria in real time.
The mouse problem
Mouse click problem
Mouse click: Moves the cursor to the click position
Double-click: select a word
Three mouse clicks: Select the entire row
Four mouse clicks: Select all
Select the file on the left of the mouse
Click the mouse to select: the file window opens on the right, and the title text at the top is in italics. When you click another file again, the current TAB will be replaced
Double-click the mouse to select: a new file window TAB is opened on the right, and the title at the top is normal. When you double-click other files again, a new file TAB window will be created
Option + mouse click | double-click, similar to the above operation, just open files will be placed in the right group directly
The last
If there are any mistakes in this article, please comment on them
GIF recording quality may vary, please forgive me
We also hope you can provide more convenient shortcut keys to speed up our coding!
The original address