3 ms·
If you map jk and kj to <Esc> you can just mash both keys at once and it doesn't matter which one registers first!
by positr0n 7y ago
If you map jk and kj to <Esc> you can just mash both keys at once and it doesn't matter which one registers first!
- darkteflon 7y agoHave to ask: for all you jj / jk mappers, don’t you end up triggering this by accident when you’re just cruising around your code?
- alexjm 7y agoVery rarely. The only place I notice a difference is if the last letter I type is a j, the cursor 'hesitates' for a moment because Vim is watching for a k. The advantage I found of jk over jj is that, in normal mode, jk is a no-op, so if I hit jk as Escape when I was already in normal mode, it doesn't matter. The only problem is that when I'm editing text out of Vim, I end up with the occasional jk at the end of my typing. That almost happened while writing this comment.
- positr0n 7y agoFor cruising around my code the advantage is that jk/kj doesn't do anything in normal mode (cruising mode, haha). So I can just start mashing jk in a terminal window that I don't know what mode I left vim in. The biggest downside to jk/kj mapping is that words that end with k are somewhat common. So a few times a week I will type something like "splunk" and want to exit insert mode immediately so I mash jk/kj after the k. 50% of the time the j is first so I end up with "splun" (kj is <esc>) (k moves up since we're in normal mode now).
- ascagnel_ 7y ago> The biggest downside to jk/kj mapping is that words that end with k are somewhat common. So a few times a week I will type something like "splunk" and want to exit insert mode immediately so I mash jk/kj after the k. 50% of the time the j is first so I end up with "splun" (kj is <esc>) (k moves up since we're in normal mode now). This is why I use `jj` instead of `jk`/`kj` -- as a native English speaker in a job where everyone primarily speaks English, there are few cases where I'd be writing code with a `jj` naturally in a string.
- roland35 7y agoI haven't had that happen yet with jk at least, I could see jj triggering something if you have the timeout setting too long.
- L3viathan 7y agoThere's also vim-arpeggio, with which you can define mappings for simultanously held-down keys: https://github.com/kana/vim-arpeggio https://github.com/kana/vim-arpeggio