Switch square and normal brackets With xmodmap

    _   _              _    ___  _            _     _                  _
   /_\ | |_ __  ___ __| |_ / _ \| |__ ___ ___| |___| |_ ___   _ _  ___| |_
  / _ \| | '  \/ _ (_-<  _| (_) | '_ (_-</ _ \ / -_)  _/ -_)_| ' \/ -_)  _|
 /_/ \_\_|_|_|_\___/__/\__|\___/|_.__/__/\___/_\___|\__\___(_)_||_\___|\__|
                                                   In Glorious ASCII-VISION
Home

2010-07-14 Wed Switch square and normal brackets With xmodmap

Most programming languages use ")" and "(" way more than "[" and "]" yes "(" is harder to type than "[". Here are the lines to add to your .xmodmap to switch them:

keysym bracketleft = parenleft braceleft
keysym bracketright = parenright braceright
keysym 9 = 9 bracketleft
keysym 0 = 0 bracketright

Or you can do the same thing calling xmodmap from the command line with:

xmodmap -e 'keysym bracketleft = parenleft braceleft' 
xmodmap -e 'keysym bracketright = parenright braceright' 
xmodmap -e 'keysym 9 = 9 bracketleft' 
xmodmap -e 'keysym 0 = 0 bracketright' 

Alternatively, if you use Emacs you can switch them just for Emacs using the following lines in your .emacs file:

(keyboard-translate ?\( ?\[)
(keyboard-translate ?\[ ?\()
(keyboard-translate ?\) ?\])
(keyboard-translate ?\] ?\))

Don't use both of these methods at the same time of course, they'll cancel each other out! I have the Emacs code in an interactive function ready to be called whenever I'm using my Emacs config on a machine without my xmodmap customisations (a Windows machine for example).

 __________________
< made in Org-mode >
 ------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                 |   | ----w |
                 ||     ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Author: Thomas Parslow <tom at almostobsolete dot net>

Date: 2010-07-14 12:39:44 BST

HTML generated by org-mode 6.31trans in emacs 23