How to go back or forward a word in bash environment?

33,186

There is M-b and M-f for moving backwards and forwards to the current word, respectively. Here M is the Meta or Esc key or a combination, like Ctrl+Meta. The section Commands for Moving in the bash manpage lists these and other shortcuts available for moving on the bash shell.

The manual also describes how to customize your bash settings so you can use your known Ctrl + / to skip words.

Share:
33,186

Related videos on Youtube

user11671
Author by

user11671

Updated on September 18, 2022

Comments

  • user11671
    user11671 over 1 year

    Possible Duplicate:
    How can I move around the bash commandline efficiently?

    In the Windows prompt, one can go back or forward one word by pressing ctrl and <-/->. What's the equivalent in a bash environment?

  • user11671
    user11671 about 14 years
    I tried Esc+b/f,not working .
  • ayaz
    ayaz about 14 years
    Try the Alt key as well. The meta key is also emulated with the alt or windows key on keyboards that have them.
  • Dennis Williamson
    Dennis Williamson about 14 years
    @user11671: Does bind -p|grep forward-word produce "\ef": forward-word (among other things)?
  • Matthias Braun
    Matthias Braun over 9 years
    Alt + Shift is the meta key on my Gnome terminal.
  • dougkramer
    dougkramer over 9 years
    To directly answer the user's question, this works for me in ~/.inputrc in Ubuntu: # Assign Ctrl-right-arrow and Ctrl-left-arrow move to next/previous word "\e[1;5C": forward-word "\e\e[C": forward-word "\e[1;5D": backward-word "\e\e[D": backward-word source: bbs.archlinux.org/viewtopic.php?id=35154
  • jojman
    jojman over 8 years
    Is there a way to navigate words as whitespace-delimited sequences of characters, and not as sequences of alphabetical characters?
  • arka mandal
    arka mandal about 6 years
    @dougkramer how does that directly answer users question? that's about rebinding the command, whereas user is asking what is the default equivalent