> The space way
> Leader key
Using space key as the leader is a very popular way of editing, navigation and commanding. There is never an easy way to get used to new shortcuts, but trust me, you would definitely like it once you use it.
> Sticky key
Think about how you invoke commands in VSCode before. When you want to call the command-palette
,
you need to put your left hand’s two fingers on Ctrl + Shift key or Command +
Shift key and press p. And note that it’s a key chord combination when you actually
press these keys.
This looks so stupid when you compare it with just Space Space in Vim’s normal or visual mode. And by saying Space Space, it’s a sticky key bindings which means you just type space key twice in sequence. And you can just set your hands as the default typing position shown in this picture.
> Prefix key
Well, now you probably get the point of using space key. But there is more of it.
Since sticky keys are just key sequences, you can cluster a lot of similar commands to a prefix like space f(file related commands). For example, space f f go to the explorer, space f ssave file and space f Ssave all. In this case, you won’t mess up with these keys because they have the same prefix space f.
> The hybrid editing mode
> Insert mode
Spacemacs has a hybrid mode that takes the normal and visual modes’ key bindings from Vim while still using the general Emacs key bindings in insert mode. To be honest, it’s super smart way of editing.
The Unix key bindings (C-a->home, C-e->end, C-b->back, C-f->forward, C-n->next line, C-p->last line) work in almost every Mac application. You probably never find out they work out of box in your Mac or Linux, but many of your guys don’t know about it.
So, why the hell people want to use Unix key bindings in their machines?
There are many reasons:
- Your Mac does not has the home, end key like a full keyboard.
- It’s a much faster way for navigation once you get used to it
- Be more consistent about the key bindings. They work in terminal, intellij IDEA, even Wechat. So why not use it everywhere.
> Normal & visual mode
As for the normal and visual mode, They are pretty much the same. But they can do much more now in space way.
Note: The leader key is space
Key | Description |
---|---|
leader space | show commands |
leader b b | quick open (see your opened files) |
leader f f | go the explorer |
leader f s | save file |
leader f S | save all |
leader = | beautify file |
leader w [lhjk] | navigate window |
leader w v | split vertically |
C-g (Optional) | ESC |
> To use it
- Add the following configuration in your VSCode’s
User Setting
(You can find out how to get to theUser Setting
over here).
{ |
- Add the following to your VSCode’s
keybindings.json
.
Note: You can find your keybindings.json here.
[ |