I'm new to emacs, and I'm trying to set it up as my editor for both python and R. Elpy and Ess are both great, and I'm relying on them a lot. However, I'm used to the Ess key-bindings, and would like the same key-bindings for the similar Elpy commands. For instance, elpy has elpy-shell-send-statement-and-step bound to C-c C-y C-e, and ess has ess-eval-region-or-line-and-step bound to C-<RET> (both of these essentially do the same thing).

What is the best way to modify a few of my Elpy key-bindings to match the matching Ess key-bindings in my init.el?

Thanks in advance!

  • Bind the keys you want in the mode map of the given mode. Those keymaps are probably called ess-mode-map (for ess-mode) and elpy-mode-map` (for elpy-mode).
    – Drew
    Commented Dec 16, 2017 at 16:58

1 Answer 1


You can use local-set-key in the major mode's hook. If you do that you don't even need to know the specific keymap for that mode.

You can paste the following lisp code into your init file to have the binding Ctrl-RET for elpy-shell-send-statement-and-step.

Disclaimer: I didn't try it. Please test it.

(defun my-elpy-mode-hook-fun ()
 "Function to be installed in `elpy-mode-hook'."
 (local-set-key (kbd "C-<RET>") #'elpy-shell-send-statement-and-step))

(add-hook 'elpy-mode-hook #'my-elpy-mode-hook-fun)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.