4 ms·
Dear Vim beginner, before getting a fancy keyboard, do remap Esc to some other key. It makes no sense to have your most important key where it is nowadays. Th
by cassepipe 3y ago
Dear Vim beginner, before getting a fancy keyboard, do remap Esc to some other key.
It makes no sense to have your most important key where it is nowadays.
The reason the back to normal mode key is ESC is because that key used to be much closer from the home row.
My personal preference is to use Caps Lock because each OS has an easy solution for this simple remap and since it's system wide you can use vim modes elsewhere too (zsh and gdb for me mostly). Also in general it's quite convenient to have escape so close.
Do what you will but please don't suffer uselessly for stupid historical reasons.
- jfdi 3y agoinoremap kj <Esc> :)
- qup 3y agoI use this one, too. I've seen a lot of people recommend jj, but that's part of something I type a lot, so I had to choose another. jk works okay too, because I don't use that acronym.
- Clever321 3y agoI thought I was the only one insane enough to do this.
- bbotond 3y agoThere are dozens of us! Dozens!
- precompute 3y agoThis is so useful I have it baked into my keyboard!
- cassepipe 3y agoIt's a great idea but it's not portable in other simple vim modes that generally lack the possibility of such a configuration, and if they do provide it, now you have another configuration to take care of. Why I like my solution : It takes three seconds to activate in any OS and it's available system-wide
- hcs 3y agoAfter using a keyboard with Esc even further away than usual, I've found myself using Ctrl-[ more often. I should look into remapping capslock.
- cassepipe 3y agoPlease do that, it's a simple option in the settings of any OS. Why use such a convenient tool as vim if you have to make a weird combination for the single most important key in your editor ? I know one gets used to anything but still. (I personally believe it doesn't make you that faster but it does take away the dullness/repetitiveness out of editing)
- Zamiel_Snawley 3y agoCaps lock is such a waste of prime keyboard real estate, even for non-vim users! For those who don’t use vim, just switching caps lock and control is probably better so you can copy and paste with less contortion. For vim users, I highly recommend remapping caps lock to be control when held, and escape when tapped.
- el_benhameen 3y agoI jump between using a Mac and a Windows machine for development. Remapping capslock to ctrl/cmd feels more ergonomic, and has the added benefit of making it so I don’t have to remember which machine I’m on.
- alentred 3y ago> caps lock to be control when held, and escape when tapped Ooh, nice! How do you map it in Vim? Or in MacOS? I always remap caps lock to control because, Vim or not, I still need control-something all the time. But I always wanted to remap esc to something closer to the home row, but never did since caps lock was already taken :) How do you map the held/tapped keys separately?
- whhuh 3y agoThank you!! I just remapped caps lock to esc and I think I'm in heaven. I've always thought esc was painfully far away, but never thought to remap caps lock.
- jLid 3y agoBinding caps lock to control when held and escape if pressed alone is the greatest
- __MatrixMan__ 3y agoThis is good advice. But be cautioned--at some point you'll want "some other key" to be the left half of your spacebar or some other such nonsense. And then you'll be one of us. Forever.
- hollerith 3y agoHuh. I find ESC easier to type than Caps Lock because it is in the corner of the keyboard. I used to have RSI and what solved it (over 15 years ago) was taking more care to hit the precise center of the key. Using my sense of touch to sense the key's exact location before even trying to activate the key helps me do that. When the key is on left edge of the keyboard, it is easier to do the determination of the exact location (of the left edge of the key I want) because I don't have to worry about accidentally activating the key to the left of the key I want. Caps Lock of course is also on the left edge of the board, just like ESC is, but ESC is also on the top edge, which is an additional help: the easiest keys to type in my experience are the ESC key and the left control key because they are in corners of the board. (The other two corner keys, "pause/break" and the right arrow key, are harder because of how far they are from the home row.) I never understood the desire many writers on this site have of moving the hands as little as possible. More precisely, I understand the rationale, but I consider the rationale to be misinformed. If you don't move your hands (i.e., because you have a keyboard with only 36 keys or something), you still have to use your arm muscles to hold your hands over the board, and the human brain is better at movement than at using the muscles to statically counteract gravity like that. That is part of it, but there is more. When hitting a ball with a tennis racket, it is ergonomic to take a back swing, i.e., to move the part of the racket that will hit the ball in the direction opposite the direction you want the ball to go, before starting the swing. Very quick back swings are important in typing, too, for preventing RSI (for reasons I don't fully understand). And I think moving my hands around the board (i.e., in the 2 horizontal dimensions) makes it less likely my brain will put the relevant muscles in "freeze mode", which makes RSI more likely. Or something like that.
- cassepipe 3y agoVim stockholm syndrome ? I don't know about RSI yet but I do know one thing : Vim workflow is to make a quick edit and then go back to normal mode as quickly as you can. This prevent accidental inserts and you are always back at the command center for your next edit. The same way some people understood most of the time is spent reading code rather than writing, vim's insight is that more time is spent doing edits than actually inserting text. So maybe strecthing your pinkie to the far (but admittedly easily locatable) corner of your keyboard is good RSI exercise I don't know but the Caps lock is just as easy for your finger to locate and don't require strechting. It's just better.
- pylua 3y agoI agree with this, but there is another default combination that is escape , right? I realized that esc was difficult in vim when I was forced to change due to the original MacBook Pro Touch Bar.
- jodrellblank 3y agoCtrl-[ It's not bad, but not all that comfortable on my left hand pinky finger.
- pylua 3y agoThat’s it! I have come to use this without thinking and I have not noticed any discomfort.
- cassepipe 3y agoI experienced the same thing in another aspect of my life. My light switches at home can't light the room with just one switch for some reason. Each time I want to enter a room, I have to write LIT in morse with the switch. It was a bit weird at the beginning but now I got used to the pattern and I can do it under two seconds and I have not noticed any discomfort.
- 000ooo000 3y agoJust to add to the other ESC remapping suggestions: Insert mode (i.e. i): space Exit insert mode (i.e. esc): shift+space Some terminals have issues with modifiers on keys like space but if you're a vim user on only 1-2 machines and can use something like Kitty then you should be OK.
- niederman 3y agoHonestly even if you don't use Vim it's worth doing. I'm a big fan of interception-tools' caps2esc on Linux.
- cassepipe 3y agoThe reason why I recommended this simple remapping is because there's no need for any tool. In each OS there's a simple, GUI accessible even, option for that remapping. Combining Ctrl + Esc is even better no doubt but it takes a bit more work The jk solution is great but it won't be available in other vim modes elsewhere