Check out a free preview of the full Visual Studio Code course

The "Key Bindings" Lesson is part of the full, Visual Studio Code course featured in this preview video. Here's what you'd learn in this lesson:

In addition to the default keyboard shortcuts provided in VS Code, Mike demonstrates how custom key bindings can be added through extension files, called keymaps, that mirror other popular editors can be installed. For advanced customizations, key bindings can be made through the VS Code's keybindings.json file.

Preview
Close

Transcript from the "Key Bindings" Lesson

[00:00:00]
>> Mike North: When we're thinking about key bindings, so don't go nuts with key bindings. It's better to be able to sort of interchange with other developers. If you have a pair program, which you should, it is good to sort of have a standard set up and not to have something when people sit down at your machine it's mind-boggling, right?

[00:00:21]
Same reason you wanna have a standard keyboard instead of some. I had a developer friend, that looked like two bowls that he would type in. I could never get used to that, and so I could never use his machine. You can bring in key maps which are, there's one for vim, one for sublime, one for Adam, one for IntelliJ.

[00:00:44]
And if you're coming to Visual Studio code, having already familiarized yourself with one of those other editors, you can just find one of those. So let's open up this extension marketplace. If you paste that string in here we can see like here are all of the different key maps that you can install.

[00:01:00]
That's a good starting point. So basic customizations, you wanna perform in the nice keyboard shortcuts UI, which looks like this. Sorry that is help, I'll just use my keystrokes here. So a really nice UI here where you can sort through and look through, there's a huge array of different preset keystrokes.

[00:01:26]
You should be able to do most of what you need here. One thing I wanna point out is this when column, that has to do with context, right. So this is saying the editor has focus and it is not in read only mode, only then can we add a comment line, right?

[00:01:43]
>> Mike North: So if your needs are not met by what you see there, if you find there's some action that you wanna bind a key to it, and for some reason that UI doesn't work. keybindings.json gives you kind of arbitrary control. And you would add little things like this, a key, a command, and a when.

[00:02:02]
If you're going to keybindings.json. You are customizing more than I would. Because you're sort of in no man's land at that point.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now