Try taking a look at this question on SO: Are there any emacs key combinations reserved for custom commands?
Regarding seeing what is available, there's the unbound
library (see the first answer to the above question).
One convention (grabbed from my answer to that question) is:
You can redefine anything, but the convention is to use C-c l (where l is any letter).
As a user, you can redefine any key;
but it is usually best to stick to key
sequences that consist of C-c
followed by a letter (upper or lower
case). These keys are "reserved for
users," so they won't conflict with
any properly designed Emacs extension.
The function keys F5 through F9 are also
reserved for users. If you redefine
some other key, your definition may be
overridden by certain extensions or
major modes which redefine the same
key.
Just remember that key bindings are different in each of the various (major and minor) modes, so what is available in one buffer isn't necessarily available in another. And make your key bindings at the most localized level possible. For example, if the functionality does something to a line of code, don't make a global key binding for it, define it in the appropriate keymaps (c++-mode-map
, ruby-mode-map
, etc.).
As far as your specific tasks, have you noticed:
- M-% aka
query-replace
- C-M-% aka
query-replace-regexp
Also, when you're searching (C-s or C-M-s (and the reverse variants)), you can type M-% (or C-M-%) to directly enter query-replace
(query-replace-regexp
) with the search string as the thing to substitute... Pretty handy.