Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In bash, you can move to the beginning of the line with CTRL+A, and the end with CTRL+E. How can I move forward and backward by word?

share|improve this question

migrated from May 27 '10 at 23:43

This question came from our site for professional and enthusiast programmers.

man bash and then read the docs in the READLINE section. – Kaleb Pederson May 27 '10 at 20:44
Another handy reference for bash keyboard shortcuts: – Amanda Oct 26 '12 at 14:02

With emacs bindings:

Meta-B moves back a word and Meta-F moves forward a word.

Ctrl-B moved back a character and Ctrl-F moves forward a character.

So B vs F is backwards vs forward and Meta vs Ctrl is word vs character.

The exact mapping of Meta may vary between keyboards. Try holding down Alt while pressing the other key; if that doesn't work, press and release Esc and then press the other key.

share|improve this answer

use alt+b for backward and alt+f for forward movement by a word.

share|improve this answer

Put in ~/.inputrc:

# Ctrl+Left/Right to move by whole words.
"\e[1;5C": forward-word
"\e[1;5D": backward-word
# Same with Shift pressed.
"\e[1;6C": forward-word
"\e[1;6D": backward-word
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.