tcsh shortcut to move the cursor back to previous space
If you mean keyboard shortcut at the prompt of interactive bash
shells, you could bind the shell-backward-word
and shell-forward-word
to some sequence of characters sent upon some key or combination of key presses.
Like if pressing Ctrl-Left sends the sequence \e[1;5D
on your terminal like it does in xterm
, you could do:
bind '"\e[1;5D": shell-backward-word'
bind '"\e[1;5D": shell-backward-word'
Note that it does not jump from blank to blank but considers shell quoting. So for instance in a line like
echo "foo 'bar baz' blah/bleh bloh
^ ^ ^ ^
It would jump to the locations marked above.
Edit: for tcsh
, you have three options:
Use the equivalent to the
bash
definition above, either in~/.cshrc
or in/etc/csh.cshrc.local
to give all users the benefit.bindkey '\e[1;5D' backward-word bindkey '\e[1;5C' forward-word
Use the
vi
mode (withbindkey -v
) and use theB
andW
keys in normal mode just like invi
.In
emacs
mode (the default, reenabled withbindkey -e
) like forbash
, bind the corresponding widgets (vi-word-back
andvi-word-fwd
):bindkey '\e[1;5C' vi-word-fwd bindkey '\e[1;5D' vi-word-back
Note that those are like vi
's B
and W
, so they're for jumping between blank separated words, not shell tokens (like quoted strings) like in the bash
solution above.