(emacs)Init Rebinding

Next: Function Keys Prev: Rebinding Up: Key Bindings

Rebinding Keys in Your Init File

   If you have a set of default definitions that you like to use all
the time, you can put commands in your `.emacs' file by using their
Lisp syntax.  Thus, the first `global-set-key' command in this section
could be put in an `.emacs' file in either of the two following formats:

     (global-set-key "\C-z" 'shell)

   or as:

     (global-set-key [?\C-z] 'shell)

When the key sequence consists of characters, like this one, you can
write it as a string or as a vector.  The first format specifies the key
sequence as a string, `"\C-z"'.  The second format uses a vector to
specify the key sequence.  The square brackets (`[...]') delimit the
contents of the vector.  The vector in this example contains just one
element, which is the integer code corresponding to `C-z'.  The
question mark is the Lisp syntax for a character constant; the
character must follow with no intervening spaces.

   The single-quote before `shell' marks it as a constant symbol rather
than a variable.  If you omit the quote, Emacs tries to evaluate
`shell' immediately as a variable.  This probably causes an error; it
certainly isn't what you want.

   Here is another example that binds a key sequence two characters

     (global-set-key "\C-xl" 'make-symbolic-link)


     (global-set-key [?\C-x ?l] 'make-symbolic-link)

automatically generated by info2www