Reputation: 103
In vim, it is easy to define keybindings of the form
imap \pd \partial
which allows one to define shortcuts for commonly used commands. Is there a way to do the same in one's .emacs file? I am only aware of how to do this for editor commands.
Upvotes: 0
Views: 269
Reputation: 285047
It's explained in this section of the manual.
In the simplest form, a key sequence is globally associated with a function:
(global-set-key (kbd "C-z") 'shell)
binds Control-Z
to the shell function.
If that doesn't fully answer your question, please elaborate. You may want to say what that vim binding does, and explain what you mean by "editor command."
EDIT: To insert text, you use the insert
function. You can wrap this in a lambda:
(global-set-key (kbd "C-z") (lambda ()
(interactive)
(insert "text to insert")))
You may also want to look at Abbrevs.
Upvotes: 2