JohnBeckett (talk | contribs) m (moved Mapping caps lock to esc in XWindows to Map caps lock to escape in XWindows: better search) |
JohnBeckett (talk | contribs) (move in comment from tip 75) |
||
Line 108: | Line 108: | ||
This is for mapping caps lock to control, of course. Then use ctrl-[ to send escape. |
This is for mapping caps lock to control, of course. Then use ctrl-[ to send escape. |
||
+ | |||
+ | ===Comments from tip 75 (for Windows)=== |
||
+ | Here's how to map the caps lock key to a control under X windows, at least under xfree86-3.x and 4.x: |
||
+ | Add a file named ".Xkbmap" in your home directory with this content: |
||
+ | <pre> |
||
+ | -option ctrl:nocaps |
||
+ | </pre> |
||
---- |
---- |
Revision as of 09:55, 26 May 2009
Duplicate tip
This tip is very similar to the following:
These tips need to be merged – see the merge guidelines.
created November 19, 2001 · complexity basic · author Leif Wickland · version 5.7
This tip shows some methods for mapping keys within the operating system to make life easier in Vim. In particular, it can be convenient to use the CapsLock key for Escape.
This tip is for Unix-based systems. For Windows, see Remap CapsLock and Avoid the escape key.
Details
If you want to completely swap the Caps Lock and Escape keys, you have to replace the "Lock" on Caps Lock. Drop this file in your home directory:
! Swap caps lock and escape remove Lock = Caps_Lock keysym Escape = Caps_Lock keysym Caps_Lock = Escape add Lock = Caps_Lock
and call it ".speedswapper". Then open a terminal and type
$ xmodmap .speedswapper
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.
Comments
If you want to use the capslock as escape on the console as opposed to just in X, try:
loadkeys ~/keymap
where ~/keymap contains:
keycode 58 = Escape
Or, if you want to completely swap them:
keycode 1 = Caps_Lock keycode 58 = Escape
See 'man 5 keymaps', and verify with 'dumpkeys' that keycode 1 is Escape and keycode 58 is Caps_Lock beforehand.
I used the following code, and it works for me (none the others did)
xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'
Comments from tip 1083 (now removed)
In Linux, you can change the keyboard-layout using a tool called xmodmap.
Write the following line into a file (e.g. ~/.xmodmap-esc)
clear Lock keycode 0x42 = Escape
and load it by running
xmodmap ~/.xmodmap-esc
or you can just run
xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'
in your X start up file.
I know how to turn caps off in Tiger (or turn it into a Ctrl key):
- Open System Preferences
- Goto Keyboard & Mouse
- At the bottom of the panel there is a "Modifier Keys..." button, click it
- Choose "No Action" or "^ ctrl" for caps-lock
For Panther one can look at uControl (http://gnufoo.org/ucontrol/ucontrol.html).
On any X windows implementation you can use:
xmodmap -e 'keycode 66 = Control_L' xmodmap -e 'clear Lock' xmodmap -e 'add Control = Control_L'
to make your caps lock work as control, like on Sun keyboards. Which is a little easier to use IMHO.
For X11, it's convenient to use this xkb configuration:
Option "XkbOptions" "grp:alt_shift_toggle,ctrl:nocaps,grp_led:scroll"
ctrl:nocaps is the trick.
This is for mapping caps lock to control, of course. Then use ctrl-[ to send escape.
Comments from tip 75 (for Windows)
Here's how to map the caps lock key to a control under X windows, at least under xfree86-3.x and 4.x: Add a file named ".Xkbmap" in your home directory with this content:
-option ctrl:nocaps