Vim Tips Wiki

Talk:Map caps lock to escape in Windows

1,610pages on
this wiki

Back to page

Revision as of 18:20, September 17, 2009 by Jrpetit (Talk | contribs)

The tip page is intended as a summary of the best methods for using the Windows operating system to remap keys.
This talk page will hold details that are not appropriate for the main tip.


Following are some examples of settings to map the keyboard in different ways.

Map CapsLock as Escape (press CapsLock to generate Escape):

[HKEY_CURRENT_USER\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,01,00,3a,00,00,00,00,00

The above applies to the current user (log off and log on to apply). Alternatively, an administrator can apply the change to all users (reboot to apply) by replacing [HKEY_CURRENT_USER\Keyboard Layout] with [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]

Swap CapsLock and Esc (press Capslock to generate Escape; press Esc to generate CapsLock):

"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,01,00,3a,00,3a,00,01,00,00,00,00,00

Map CapsLock to LeftCtrl (press CapsLock to generate LeftCtrl):

"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00

Swap CapsLock and LeftCtrl:

"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,3a,00,1d,00,1d,00,3a,00,00,00,00,00

Map LeftAlt as CapsLock, LeftCtrl as LeftAlt, and CapsLock as LeftCtrl (useful for some laptops):

"Scancode Map"=hex:00,00,00,00,00,00,00,00,04,00,00,00,3a,00,38,00,38,00,1d,00,1d,00,3a,00,00,00,00,00

Registry scancodes

This section is an explanation of the format used for "Scancode Map", from Scan Code Mapper for Windows and Keyboard scan codes.

More information is at Remap the F12 Key, CapsLock Key or any Key in Windows XP, 2000, Vista and 2003.

"Scancode Map" is a registry binary value with the following format (each value is a 32-bit integer in little-endian order):

<00000000> <00000000> <NumberFollowingIntegers> <Mapping1> <Mapping2> ... <00000000>

A mapping consists of two 16-bit scancodes. The second scancode (high word) from the keyboard is replaced with the first scancode (low word). Some relevant scancodes:

0x01 Esc
0x1D L-Ctrl
0x38 L-Alt
0x3A CapsLock
0x46 ScrollLock

For example, the following line:

"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,01,00,3a,00,00,00,00,00

consists of one mapping (01,00,3a,00) which replaces the scancode 0x003a with 0x0001. That means that pressing CapsLock (0x3a) will generate Escape (0x01).


This section is for other Windows utilities relevant to mapping keys. Brief notes on other useful utilities are in the tip.

  • On Windows XP, and possibly other versions, a resource kit utility named remapkey.exe provides a GUI to create needed registry entries to remap keys.
  • KeyTweak is a free program that automates changing the registry to map keys.
  • Ctrl2cap from Sysinternals is a kernel-mode driver to perform keyboard input filtering to turn CapsLock into LeftCtrl.


Or instead:

Use <CTRL-[> to generate an escape sequence. Mapping the escape key to the CAPS-LOCK is simply counter-productive on windows since the CTRL key is used all the time: see copy and paste. It is FAR more useful to have the caps key be a control key. Vim users can find this tip on the vim tips section at which I wrote many years ago. Not sure why somebody felt the need to blow away that tip here.

There is a reason why original UNIX keyboards have the CONTROL key in that spot.

Which tip got "blown away"? All tips of the kind you mentioned have been merged to 285: Avoid the escape key. Some of these titles have been kept as redirects, some have not. John and I are in slight disagreement as to whether or not to keep old titles around (my opinion is "yes, yes, yes") whereas he likes to cull the less useful titles so yours may have been the victim of a less-than-stellar title. If you want, recreate the page as a redirect to Avoid the escape key by making a page of the correct title with content, #REDIRECT [[Avoid the escape key]]. Or respond here with the old title and I'll do it.
This reminds me of another reason I've had but never mentioned for keeping titles around. In my experience (and I assume other people's as well), an editor may create a page on a wiki, but not really check on the wiki or become very active. But, that's "their" page (no, it doesn't really belong to anyone, but a lot of effort went into crafting it so there is some sense of ownership) and they will check on it from time to time. If they don't check often enough, or don't understand the wiki policies or culture, they may miss the notice that the page is being merged/deleted. So they go to check on it later, see it's deleted, and the only thought is "those jerks deleted MY page for no good reason!" This is probably less important than preventing link rot, but I'm sure it turns off a user or two from time to time. I didn't contribute to wikipedia for a long time after my first article, "Grancrete", got deleted because it looked like a corporate promotion of a product (it wasn't, I did it in good faith after seeing an article on a news site and thinking it was pretty cool). Had I been involved in the community, I may have noticed the discussion going on about the new page and argued against deletion (or maybe not considering the size of wikipedia), but I wasn't so I never had the chance.
Anyway, sorry your tip got deleted. John and I have sort of met in the middle as far as keeping titles go, so I'll probably continue to let him delete some titles I think shouldn't be, he'll continue to keep some titles as redirects to merged content, and I'll continue to restore pages as redirects if someone notices and complains.
--Fritzophrenic 17:19, 31 July 2009 (UTC)

I have edited the tip so the introductory section makes it clear that VimTip285 is probably a better choice for avoiding the escape key (the suggestion about using Ctrl-[ for Esc is the first item at 285). In the 1250 tips imported from in July 2007, there were many tips and comments with advice (often conflicting) re Esc + Ctrl + CapsLock. It was scattered over more than ten pages, and was very hard to find and difficult to read. I think it's much better to have the advice condensed and cleaned, resulting in VimTip285 to avoid the escape key, which starts with links to this tip for maps to change key layout for Windows, and a link to VimTip166 for similar info for Unix.

Originally it was planned that would maintain the old tips indefinitely (but changes were disabled to prevent spam). However, the system crashed with a database corruption (a year ago?) and Bram decided that it was too hard to resurrect the tips. Therefore, there are no tips on now.

Since it was never possible to edit text at, a large majority of the imported tips were in a shocking state. Some tips were simply wrong, others obsolete (not applicable to Vim 7), many misguided, and most had contradictory advice (often a tip would have some script, and the comments would have several attempts by various people to correct bugs, or to improve the script). A fantastically large amount of work has been done here to correct many of these problems, and there may be some unfortunate consequences such as original tip authors not being able to find their work.

Please note that we regard comments as temporary, and all discussions such as this one will be deleted in due course (after a week or two). That does not apply to user talk pages, but it does apply to tips and their talk pages because we want to present simple-to-follow text and don't have the contributors to justify talk pages. I'm just warning you that this discussion is also likely to be cleaned away. JohnBeckett 00:40, 1 August 2009 (UTC)

Windows up until XP, and Vista (I think) do not have a nice UI for changing the mappings of the keyboard. Over the years that I have been using vim, every time I installed or re-installed Windows, one of my first stops has always been to install vim and then map the CAPS key to the control key and make the old control key the CAPS key.
On Linux/BSD/... these things are a small afterthoughts no doubt. The original realization that you could actually do this on Windows, however, was life changing for me as far as vim on Windows is concerned. Anyways, long story short: I would periodically go back to the vim site and dig up my old tip. It's the kind of thing you do and forget about for the next three years.
I made the original title so that it would be easy to search for: Windows, Registry and CAPS (the current wiki document is: Swap_caps-lock_and_control_keys_using_MS_Windows_Registry). Note that it had nothing to do with mapping the escape key.
Perhaps my tip should have also included the way to avoid using the escape key, but in the end I noticed somebody else had already written one on
So the registry information is useful to I think. I still occasionally (every few years or so) have needed to dig it up. Where should I place it? For now, with your permission, I will just revert the redirect. Maybe it belongs in a general section on Windows keyboard configuration tips?
-- Jacques

Jacques: Your original was tip 353 with title "Swap caps-lock and control keys using MS Windows Registry". It is in the wiki history here. Please do not edit that old version; see below. As you say, the title still exists, but is a redirect to tip 75 (this tip).

There was an enormous amount of confusing waffle spread throughout all the tips on mapping keys (with text mixing up different techniques and different operating systems). I have merged all the info (including some new tips!), with many fixes, into just three tips:

You knew how to find your tip, but I'm not sure it would have been easy for someone else. Think about a reader who uses Vim on Windows, but isn't entirely happy with the keyboard layout. Why would they search for "Windows Registry" for a solution, and why do that search here on the Vim Tips wiki? If I knew that there was a technique for mapping keys using the registry, but I had forgotten it, I would use Google and would not expect to find it on a wiki about Vim. Also, I think the only people looking for a tip about replacing the CapsLock key with Ctrl would be the few who remember the old keyboards, and those people would generally have sorted out a solution by now.

All the information from your original tip 353 is on this talk page, and this page is referenced in "See also" in the tip. Specifically, the registry changes from the original tip 353 are above at "Map CapsLock to LeftCtrl (press CapsLock to generate LeftCtrl)" and "Swap CapsLock and LeftCtrl" (the registry entry is slightly different in the second case, but it does exactly the same thing). The only information missing from the original tip 353 is this link which has been replaced with better information.

What might be done is to write a short note somewhere that makes the case for why someone would want to replace CapsLock with Ctrl, and link to this talk page which has the registry settings above (and when all our discussion has been deleted, it will be a lot easier to see).

The above is what I think. However, I have another driving force, namely if someone is prepared to contribute to the wiki (as you have done) I am happy to lose an argument with them. So, please review what I have said and let me know what you want to do. I would like to hear other opinions (Fritzophrenic: are you here?), but I'm happy to restore the original tip 353 if you want (and it would then be available for editing). We generally avoid mentioning a solution in the title, and prefer to be short and to-the-point, so if you want to keep 353, are you sure about the title (what about "Swap caps lock and control keys")? Don't worry about humouring me (I just want to know you have seen my thoughts), so please just say want you want now. JohnBeckett 02:33, 3 August 2009 (UTC)

Here's what I think should happen:

  • In the section of the tip dealing with the registry scancodes, add the links contained above that explain what is going on. I haven't checked them out, we may need some of the explanation as well if the links are too unclear.
  • Mention in the same section that one can also map other keys using the same method, such as the CTRL-CAPS swap being discussed.
  • Modify the original tip title's redirect to point to this section.

--Fritzophrenic 15:04, 3 August 2009 (UTC)

I recommend that the main title for helping windows users with registry codes to remap their keyboard not be about remapping the escape key; it could further have links to the tip on the control-[ sequence. The entire section about remapping the escape key to the control key belongs in a footnote, not as the major piece that is linked to -- it is in my opinion an inferior suggestion.
The most useful remapping of keys for vim is, in my opinion, swapping the caps and control keys around. This tip should be titled as "The control key on windows, tips and configurations to make it easier to use" or some suitable variant.
-- Jacques
Your suggested title is too long. Have a look at some of the titles here (ignore the details; just browse the list of blue titles). The only potentially useful search text in the long title is "control key".
Re the question of which technique should be given prominence: I don't particularly care, but I'm pretty sure that the current arrangement is an accurate reflection of views expressed by many contributors at (some said that using CapsLock for Ctrl was great, but many more wanted an easier way to press Esc).
Unless there is a really good reason, I would like all information regarding mapping the keyboard in one place. That means in this tip (or the Unix equivalent), or possibly on this talk page.
I am warming to the following proposal: Make redirects with titles "Control key" and "Ctrl key"; clicking either would redirect to this tip. Change the tip introduction to have an extra sentence about the Control key. Move the registry explanation from this page to the tip, in its own "Explanation" section. Move the CapsLock/Ctrl setting from this page to the tip, in its own "Use the Caps Lock key as Ctrl" section. Any comments? JohnBeckett 07:21, 23 August 2009 (UTC)
How about: Window Keyboard Customizations as a title?
I really like the "Control key" and "Ctrl key" redirection idea. Is there a way to qualify that with a Windows keyword?
I'm still not convinced about the escape key being the most popular choice. Scrolling up and down ctrl-u ctrl-d etc.. is so much more fluid with the control key right next to the pinky. But, I'll be happy with the ctrl-key/caps suggestion being moved back to the main tip page.
And I still think that ctrl-[ should be mentionned as a way to make escape fluid to do, particularly with the key mapping I prefer with the control key swap.
Any new thoughts here?
What did you think of the title idea I proposed?
If you like, I can make the changes we discussed here (title change and moving the registry information to the front page of the tip).

Around Wikia's network

Random Wiki