Tip #166: Mapping caps lock to esc in XWindows
tip karma |
Rating 765/206, Viewed by 11185
|
Read and edit this tip on the
Vim tip wiki.
The wiki may have a more recent version of this tip.
created: |
|
November 19, 2001 11:19 |
|
complexity: |
|
basic |
author: |
|
Leif Wickland |
|
as of Vim: |
|
5.7 |
(This originally appeared on the vim mailing list as post by Adam Monsen http://groups.yahoo.com/group/vim/message/19856)
If you want to completely swap caps lock and escape, you have to replace the
"Lock" on caps lock. Drop this file in your home dir:<br>
-----------start------------<br>
! Swap caps lock and escape<br>
remove Lock = Caps_Lock<br>
keysym Escape = Caps_Lock<br>
keysym Caps_Lock = Escape<br>
add Lock = Caps_Lock<br>
------------end-------------<br>
and call it ".speedswapper". Then open a terminal and type<br>
$ xmodmap .speedswapper<br>
and you'll be twice as efficient in vim. Who needs caps lock anyway? The swapping lasts for the duration of the X session, so you can put it in a .xinitrc or similar startup file. As far as other people using my laptop, I'd rather they didn't! Using a Dvorak layout might protect me even more... :)
<< Deleting a buffer without closing the window |
Using vim as a man-page viewer under Unix >>
Additional Notes
leifw @at@ bigfoot dot.dot com,
November 19, 2001 11:21
|
Oh, and I really didn't mean for those <br>'s to show up in the file. It should look like
-----------start------------
! Swap caps lock and escape
remove Lock = Caps_Lock
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock
------------end-------------
|
[email protected],
July 2, 2002 21:06
|
Great tip!!! And I might try the other tip on the Dvorak mappings :-)
|
[email protected],
October 3, 2002 23:38
|
If you want to use the capslock as escape on the console as opposed to just in X, try:
loadkeys ~/keymap
where ~/keymap contains:
---------->8----------
keycode 58 = Escape
----------8<----------
Or, if you want to completely swap them:
---------->8----------
keycode 1 = Caps_Lock
keycode 58 = Escape
----------8<----------
see 'man 5 keymaps', and verify with 'dumpkeys' that keycode 1 is Escape and keycode 58 is Caps_Lock beforehand :)
|
[email protected],
October 12, 2002 11:05
|
hehe, nice, very nice... but i'm living in a torture right now, because i DO wanna change <esc> to another key closer, *** but i'm so used to <esc> that i can't !!!! ***
damn. :P
|
[email protected],
January 22, 2003 3:23
|
How to do this in windows: Create the following file, calling it capstoesc.reg:
-------start
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\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
--------end
Then double-click on it and reboot.
The syntax is explained in https://www.vim8.org/tip_view.php?tip_id=285
|
gtg947a@<nospam>mail.gatech.edu,
September 13, 2003 18:05
|
I had this script working nicely before, but now it gives me this error:
xmodmap: .speedswapper:1: bad keysym in remove modifier list 'Caps_Lock', no corresponding keycodes
xmodmap: .speedswapper:3: bad keysym target keysym 'Caps_Lock', no corresponding keycodes
xmodmap: 2 errors encountered, aborting.
Anybody know what's up?
|
gtg947a@<nospam>mail.gatech.edu,
September 13, 2003 18:13
|
Nevermind, I forgot to delete a line from my XF86Config file. Disregard.
|
adityam at inbox dot lv,
September 17, 2003 12:29
|
I connect to a X-server through ssh, and though the script runs correctly I can not get the desired effect. Can not change the keysettings in the windows machine that I use since I am not a administrator :(
Anyway to overcome this?
|
mail at bjoernalbers dot de,
May 13, 2004 3:23
|
This is really a life changing tip since I hardly ever user my caps_lock!
Thanks
|
leifw @at@ bigfoot dot.dot com,
October 5, 2004 1:49
|
Nearly three years after posting this tip originally, I'll say that the worst part of using it is that if you ever have to set up a new PC, you'll drive yourself mad until you find and implement this tip.
|
nyte2k@<nospam>yahoo DOT com,
March 13, 2005 18:16
|
Anyone have an idea as to how to make this work in os x? I recently acquired a g5 and it doesn't run linux too well yet, so I'm stuck in OS X for the time being. The <Capslock> DAMN! <Capslock><escape> sequence is getting really annoying.. (please send ideas to my email address)
|
oleslists (at) gmail andadot com,
July 5, 2005 4:15
|
Not sure if this is going to be read anytime soon - but worth a shot:
Any way of making this work under XP? The registry entry doesnt work for me.
|
[email protected],
February 25, 2006 18:34
|
another way to exit insert-mode or command mode is: <CTRL-C>
anouther key for <Esc> is: <CTRL-3>
|
[email protected],
October 21, 2006 17:20
|
Any ideas on switch caps and escape on a mac os x (v. 1.4)?
|
|