2

Inspired by this question. I would like to remap Caps Lock to escape, but only when I am in vim. I would like to keep Caps Lock untouched while not in vim.

3
  • Does it matter to you if it is remapped system wide when vim is opened? Jun 9, 2010 at 19:32
  • @Seamus: It wouldn't be ideal, but it would be better than a persistent system-wide remap.
    – Matthew
    Jun 10, 2010 at 4:40
  • 1
    Then you can write a shell script wrapper for vim, that uses xmodmap to change your key bindings. The settings would persist system wide until you quit vim. You would have to also store the total number of open vims somewhere persistent so that you dont change the mappings back until after all of the vims are closed. You would also have to find some one who knows what they are doing with bash (not me, unfortunately). Jun 10, 2010 at 20:26

3 Answers 3

3

If modifier keys are pressed they are not passed to applications by the OS before any other key is pressed.

Therefor it is not possible to map a single capslock, shift or ctrl key press in applications without remaping it globaly.

0

This may not be the answer you're looking for, and I don't want to start a religious debate, but this is what emacs is good for. As with emacs, you can remap keys and write your own extensions for it.

I don't think this is possible right off the bat with vim.

1
  • 1
    Are you sure that emacs itself can remap caps lock? I don't think a press of caps lock will normally be relayed to an application, but that it will simply modify what is sent afterwards. Otherwise, I agree: with vim, as with emacs, it's possible to implement extensions that use custom keymappings.
    – intuited
    Jun 8, 2010 at 21:30
0

I tried doing the same thing and could not find a way to do it. It seems that Vim doesn't see CapsLock as a modifier key, so you can't create a mapping for it.

You must log in to answer this question.

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