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 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?-
Admin about 14 yearsduplicate: superuser.com/questions/113103/…
-
-
user11671 about 14 yearsI tried
Esc+b/f
,not working . -
ayaz about 14 yearsTry the
Alt
key as well. The meta key is also emulated with thealt
orwindows
key on keyboards that have them. -
Dennis Williamson about 14 years@user11671: Does
bind -p|grep forward-word
produce"\ef": forward-word
(among other things)? -
Matthias Braun over 9 years
Alt + Shift
is the meta key on my Gnome terminal. -
dougkramer over 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 over 8 yearsIs there a way to navigate words as whitespace-delimited sequences of characters, and not as sequences of alphabetical characters?
-
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