A collection of VSCode shortcuts worth knowing, recommended by the Shortcuts Uncle

Hello.
I'm Mandai, the Wild team member in charge of development.

I wrote an article about Visual Studio Code (VSCode) shortcuts a little while ago, and since then I've been spending my days Googling shortcuts and reading through configuration files. My
daily work revolves around memorizing as many shortcuts as possible to work without taking my hands off the keyboard, and from the shortcuts I've learned since the last article, I've carefully selected only the ones that I've used for a while and that feel comfortable with me!


 

Select from the beginning to the end of the line

I used to frequently use the combination of home key followed by Shift + end, but there is a shortcut that instantly selects the current line

Ctrl + L

 

In most cases, this is convenient because you want to delete the entire line, but since the line break code at the end of the line is also included in the selection range, there are rare cases where the line breaks become strange, but don't panic

 

Add/remove leading indent

The standard way to indent is to use the tab key or shift-tab, but VSCode also has shortcuts assigned for indentation

While it's true that you can indent using the tab key, it's not always possible to indent using the tab key.
To indent using the tab key, the cursor needs to be at the beginning of the line, so if you notice an indentation issue midway through, you'll need to move the cursor.

That's what I mean

# Add Ctrl + ]

 

# Delete Ctrl + [

 

The number to increase (decrease) and the character type (tab or space) are determined by the language mode settings

 

Chord Folding

# Collapse Ctrl + Shift + [

 

# Expand Ctrl + Shift + ]

 

When modifying extremely long pieces of code, it's a good idea to make use of code folding and splitting the editor (Ctrl + \) to minimize the amount of time you waste by going back and forth as much as possible

Incidentally, there's also a command to "collapse everything that can be collapsed in a file," which I may have mentioned before. You can collapse everything with the combination Ctrl + K, Ctrl + 0.
Conversely, the command to "expand everything that can be expanded" is the combination Ctrl + K, Ctrl + J.

 

I want to open a file that I accidentally closed

I discovered this by chance, but it has the same shortcuts as browsers like Chrome

Ctrl + Shift + T

 

This is a shortcut that is especially recommended for impatient people who tend to hit Ctrl + W repeatedly

 

I want to see all the commands

Basically, you open the command palette with Ctrl + Shift + P, but did you know you can open it with just the F1 key?
You might be thinking, "So what?", but I'm feeling pretty smug about it, you know?

 

Bonus: Utilizing Unassigned Shortcuts

When developing on the server side, it's common to switch back and forth between the code editor and the terminal.
However, there are no default shortcut keys assigned to move the cursor between the editor and the terminal!

So, why not just assign this to a position of your choice?

 

First, a shortcut to move from the editor to the terminal

The keyboard shortcut settings are accessed using the combination Ctrl + K, Ctrl + S (opening shortcut settings with a shortcut!).
The command name is "workbench.action.focusPanel", so you can copy and paste it to search for it.

The key bindings are probably blank, so hover your mouse cursor over the row and click the pencil icon that appears on the left

Enter your desired key binding and press Enter to complete registration

 

Next, a shortcut to move from the terminal to the editor:

Now that we can move from the editor to the terminal, let's set up a shortcut to go back from the terminal to the editor.
The command name is "workbench.action.focusActiveEditorGroup", so we'll search for it by copying and pasting it as before.
The key binding for this is also empty, so we'll register a key binding in the same way.

In my case, I wanted to switch back and forth using the same shortcut, so I set it up, but it didn't work properly

So, we will set up something called a when expression for this shortcut only

The `when` expression specifies when this shortcut becomes active, and the system prioritizes the timing specified in the `when` expression.
Here, we set the `when` expression to "terminalFocus," which indicates that the terminal is in focus.

This means that when the terminal has focus, the shortcut to move from the terminal to the editor takes priority, making it easier to switch back and forth

 

summary

I started using shortcuts because I thought the few seconds I saved by using them would be quite important, but my main purpose ended up being to use shortcuts and discover good shortcuts I hadn't seen before

I've written several articles introducing shortcuts, so I was starting to run out of ideas... but this time I've ventured into the forbidden territory of unassigned commands.
If you take a closer look, you'll find an incredible number of commands available, and the default shortcuts are truly just the tip of the iceberg.

I can't find any pages that explain individual commands, so there are many that I don't understand, but I would like to write a blog that digs up and collects useful unassigned commands

 
That's all

If you found this article helpful,please give it a "Like"!
1
Loading...
1 vote, average: 1.00 / 11
8,184
X Facebook Hatena Bookmark pocket

The person who wrote this article

About the author

Yoichi Bandai

My main job is developing web APIs for social games, but thankfully I'm also given the opportunity to work on various other tasks, including marketing.
My image rights within Beyond are treated as CC0.