Design of vim Mode Activation Key
If you are designing a modal keybinding, such as vim, where you have command mode and insert mode that need to be switched to, there's the question of how to do this.
There are 3 major ways.
- ① A mode toggle key.
- ② 1 Dedicate key for command mode activation and 1 Dedicate key for insert mode activation.
- ③ 1 Dedicate key for command mode activation, and when in command mode, a key for insert mode activation
Here's pros and cons of each.
A Toggle Key Approach
In this way, 1 key toggles command/insert mode. The flaw with this approach is that user needs to know which state he is currently in. Usually by some visual indicator on screen. This means, user needs to look first. (say, you came back from lunch.)
2 Dedicated Keys to Activate Command/Insert Mode
In this approach, there's 1 dedicated key to activate command mode, and 1 dedicated key to activate insert mode.
The flaw with this approach is that, 2 keys are required (instead of one). This may be a problem because these keys need to be pressed very frequently, multiple times per minute, so they need to be topmost easy keys, but there are only few easy spots on traditional PC keyboard. e.g. Caps Lock is a good spot, Alt are good. But usually Alt already has uses. For example, as normal Alt for the left one and as Alt Graph for the right one.
1 key for command mode activation, then when in command mode, another key activates insertion mode. This is the approach of vi.
The problem with this approach is that it is less intuitive.
In conclusion, the vi way is probably the best, given standard PC keyboard, because:
The 1 toggle key is simple, but the issue of needing to be aware of current state puts a mental burden, or visual burden.
The 2 dedicated keys approach, requires 2 keys. It is solid, but requiring 2 easy key spots seems too much, because 1 precious extra easy key spot can be used for many candidates of most frequently used commands, such as a leader key for hundreds of commands (such as emacs's C-x prefix), or emacs M-x for calling command by name, or emacs mark command to start text selection, or OS wide previous window command 【Alt+Tab】.
If you have a batman keyboard such as Kinesis Keyboard that has lots thumb keys, then the 2 dedicated keys might be ok, but still, that one key spot if used for other frequently used command, probably still offset the advantage of simplicity.
Note that 2 dedicated keys for mode switching does not save you keystrokes in general. It saves 1 keystroke when user just came back from lunch. More specifically, when user is not sure of current state, AND does not want to first check state visually, AND user want to go to insertion mode, so user press Escape then i, 2 key strokes. But this is rare, because when actively editing, the vi way still just require 1 key to switch between modes, same as 2 dedicated key to switch modes.
If you have a question, put $5 at patreon and message me.