[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: map '-' to '_' and '_' to '-'



Rob Owens <rowens@ptd.net> writes:

>On Fri, Nov 12, 2010 at 03:02:00AM -0500, Kamaraju S Kusumanchi wrote:
>> While working on my Debian box (which btw is a mix of Lenny and Squeeze), I 
>> find that I type the underscore character ('_') more often than the dash 
>> character ('-'). It could be file names, variable names while writing code 
>> etc.,
>> 
>> Typing '_' involves holding the shift key while typing '-' does not involve 
>> any. I am wondering if there is a way at the OS (or shell) level solution to 
>> remap '-', '_' one to another so that typing '_' does not involve holding 
>> shift key but typing '-' does.
>> 
>Use xmodmap and/or a .Xmodmap file in your home directory.  You man need
>to use xev to find the keycodes.

The X11 keysyms for these characters are "minus" and "underscore". If
you run "xmodmap -pke | grep underscore" you should see which keycode has
these keysyms mapped.

For me, this is:
$ xmodmap -pke | grep underscore
keycode  20 = minus underscore minus underscore

I suspect that's a standard keyboard keycode so you'll get the same
results, but run it anyway to be sure.

You can remap this like so:
$ xmodmap -e "keycode  20 = underscore minus underscore minus"

That swaps minus and underscore.

You can put the part between quotes in your ~/.Xmodmap file and GNOME
should auto-load it (although I think I remember reading something
lately that this may change).

Finally, I suggest you not do this. I've make changes to my standard
keyboard in the past and when you switch to someone elses keyboard you
just get annoyed :-) I used to map CapsLock to Ctrl, but if you get too
used to that, YOU JUST END UP SHOUTING when you only meant to press
Ctrl.


Reply to: