How to move one word right/left in linux/bash? [closed]

Edit - please see the same question on Unix Stack Exchange.

What is the equivalent of Windows' CTRL-Right and CTRL-Left ?


Solution 1:

  • Alt+F moves forward, and
  • Alt+B moves backwards.

But that's not all!

  • Ctrl+A moves to the beginning of the line,
  • Ctrl+E moves to the end of the line,
  • Ctrl+R performs an interactive history search, which is very useful.

For many more keybindings, comb your way through man bash.

Solution 2:

Add these two lines to your ~/.inputrc file:

"\eOC": forward-word
"\eOD": backward-word

and press Ctrl-x Ctrl-r to reread the file to make the changes active in your current session.

You will be able to use Ctrl-Right and Ctrl-Left to move right or left word by word.