I am running the python console in my terminal on OSX and I would like to know if there are any keyboard shortcuts for navigating to the next/previous word or to the beginning or end of the line.

In my text editor for example I can use CMD + RIGHT ARROW to get to the end of a line, but this doesn't work here.


If you are using the Python that comes with OS X, it was not built with Readline support at least in 10.8. You can still use basic Emacs-style keybindings:

  • control-A: go to beginning of line
  • control-E: go to end of line
  • option-B: go word backward
  • option-F: go word forward
  • control-K: delete to end of line
  • control-U: clear line
  • option-D: delete word forward
  • option-delete: delete word backward

If you installed Python with Homebrew, it was probably configured with Readline support, so you can use the same keybindings as in Bash.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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