2

This question has already been asked here. The accepted answer says it is not possible. Other answers provide a way to do it on linux but I have not check if it worked. I am most interested in knowing if there is a way to do it for mac (although you can post answers for linux as well).

I am only reposting this question here because the other question on SOF is more than five years old. Ideally, I would like to remap to <ESC> key to CAPS LOCK.

1

If you are using the X11 environment, you may achieve what you want with the following commands:

xmodmap -e 'clear lock'

which means: from now on, Caps_Lock key isn't anymore a keyboard modifier and fall back to a normal key

xmodmap -e 'keysym Caps_Lock = Escape'

which means: get the keycode of Caps_Lock and from now on assign it the keysym of Escape.

Note: this receipe works on any Unix.

4
  • Is the terminal application not the same as X11? I tried putting those commands in my .vimrc but it does not recognize it – solalito Nov 10 '15 at 18:38
  • I don't know if it works the same on mac but on linux, if you want those commands to be executed automatically by xmodmap, you shouldn't put them in .vimrc but in ~/.Xmodmap. Besides, you don't write the whole command anymore, just what's inside the quotes. For example, instead of putting xmodmap -e 'clear lock' in .Xmodmap, you just write clear lock. Then you restart the computer or you just log out and log in back so that xmodmap reads the file and executes each line it contains. – saginaw Nov 10 '15 at 21:54
  • @solalito: the commands I gave here aren't internal vi commands, but X11 environment ones. They won't work within vi or Terminal, because they directly talk to the `X`` server and more precisely to the part which deal with the keyboard managment. – dan Nov 11 '15 at 11:05
  • @solalito: I didn't test it, but from a critical reading of their web server, Karabiner: pqrs.org/osx/karabiner seems to be a correct solution to your problem. If you test it successfully, I suggest you to make here an answer to your question. – dan Nov 11 '15 at 11:22
0

The question you posted is still up to date. I've been using the AutoHotkey solution under windows for some years and I'm quite happy with it. I find it useful to also remap the Capslock to Esc under Firefox+Pentadactyl.

As there is no AutoHotkey for mac, you should look for its alternatives.

0

Steve Losh describes a Mac specific way in his blog on the crafting a modern Space Cadet. He also calls out these instructions in his tutorial on Vim.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .