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.
Related videos on Youtube
Author by
user11671
Updated on September 18, 2022Comments
-
user11671 about 1 yearPossible Duplicate:
How can I move around the bash commandline efficiently?In the Windows prompt, one can go back or forward one word by pressing
ctrland<-/->. What's the equivalent in a bash environment?-
Admin over 13 yearsduplicate: superuser.com/questions/113103/…
-
-
user11671 over 13 yearsI triedEsc+b/f,not working . -
ayaz over 13 yearsTry theAltkey as well. The meta key is also emulated with thealtorwindowskey on keyboards that have them. -
Dennis Williamson over 13 years@user11671: Doesbind -p|grep forward-wordproduce"\ef": forward-word(among other things)? -
Matthias Braun about 9 yearsAlt + Shiftis the meta key on my Gnome terminal. -
dougkramer about 9 yearsTo 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 about 8 yearsIs there a way to navigate words as whitespace-delimited sequences of characters, and not as sequences of alphabetical characters? -
arka mandal over 5 years@dougkramer how does that directly answer users question? that's about rebinding the command, whereas user is asking what is the default equivalent