How to map Caps Lock to Esc for Vim in macOS?
Asked Answered
C

3

7

I use vim to develop on my mac and I updated to Mountain Lion yesterday. I was using http://pqrs.org/macosx/keyremap4macbook/ this to remap the escape key's function to caps lock to switch between edit and insert modes. I can't really functionally develop in vim without this and it doesn't seem to work in Moutain Lion. I really need a solution soon!

Thanks a lot guys.

Chug answered 27/7, 2012 at 3:11 Comment(4)
This as an occasion to develop your flexibility. It's a very useful skill, don't pass this occasion! Anyway, did you follow the install process? If yes, what are the symptoms? Did you send a bug report to the author?Backstairs
Not an answer to your question, but I'd recommend remapping caps lock to Ctrl and use Ctrl-[. It's easier to hit than Escape and you don't rely on software hacks that might break with the next OS update.Grievance
Just ctrl-c is good, too. I submitted an edit for the title of this question, by the way – it could have been more specific.Ocieock
I sent the author an email and he responded asking for patience until the source of mountain lion is released... I didn't even know that apple released their operating system source code. Is that true? Also, I know this is from 2001, but It looked good to me: vim.wikia.com/wiki/VimTip166. I tried it, but xmodmap is not a command my terminal recognizes. I have zsh, and so it asks to autocorrect to _xmodmap, which I tried and it responds with: _arguments:comparguments:312: can only be called from completion functionChug
V
7

Found this: https://github.com/tekezo/PCKeyboardHack/issues/8#issuecomment-7359829

It worked perfectly for me.

I had grown so accustomed to using caps-lock as esc, that it was killing my productivity until I found this.

Valida answered 31/7, 2012 at 17:17 Comment(0)
R
1

You can achieve the same using the accessibility features of macOS. A usage example:

  1. Map Caps Lock to Esc;
  2. Map double Shift to Caps Lock.

To achieve (1) go to Settings > Keyboard > Special keys. In the appeared dialog set the desired mappings.

To achieve (2) go to Settings > Accessibility > Keyboard > Hardware > Activate lock keys.

So now if you have taps on you'll even have a logo on your screen notifying you about that.

NB. These are system-wide settings, not only for vim, but I believe it doesn't make a lot of sense to have a special mapping only for one editor, it will only make things more confusing.

NB. The Settings names could differ slightly for you, since I had to translate them from Dutch. Use some fuzzy logic to get to the right place.

Recreate answered 27/6, 2022 at 12:49 Comment(0)
C
0

You can reassign caps lock key as escape system wide. To achieve that in current macOS version:

Go to System Settings > Keyboard > Keyboard Shortcuts > Modifier Keys tab.

Then set Caps Lock (⇪) key to Escape

Crinose answered 26/8 at 12:2 Comment(1)
Thanks for the update! It's a good thing to have here for posterity. Since 12 years ago, though, things have changed a bit (for me, haha). I have caps lock remapped to control now and I've been using jj for escape in neovim.Chug

© 2022 - 2024 — McMap. All rights reserved.