Search code examples
pythonemacspython-mode

Change the "send code to interpreter" (C-c |) command in python-mode


I am used to "C-c C-r" command to send code to the interpreter in R with Emacs speaks statistics. How can I set python-mode to use "C-c C-r" rather than "C-c |" to evaulate code?

Thanks!


Solution

  • It's already bound to C-c C-r in the built-in python.el, but here's a command that binds the key. If you're using python-mode.el, you'll have to change the library name, the command, and maybe the map.

    (eval-after-load "python"
      '(progn
         (define-key python-mode-map (kbd "C-c C-r") 'python-shell-send-region)))