My default shell is tcsh. In my .cshrc file. I have bindkey -v, so that at the command line, the letters b and w jump backwards and forwards a word, respectively. I'd like to set up bash so that when I switch to that shell, it does the same thing. I've tried putting bindkey -v into .bashrc but bindkey is not recognized. Could somebody please explain how to mimic these tcsh key bindings in bash. Thanks!
1 Answer
In the tcsh shell, bindkey -v sets the command line editing mode to "Vi mode" (as opposed to "Emacs mode").
In the bash shell, the same effect can be had with set -o vi.
Putting the command line editor into "Vi mode" makes it behave a bit as if you were using the Vi editor, where w (in "normal mode", after pressing Esc) moves to the first character of the next word, b moves to the first character of the current or previous word, end e moves to the next end-of-word, etc.
You may also switch the Readline library (which the bash bash is using for the command line editing) into "Vi mode" by adding the setting set editing-mode vi in your ~/.inputrc file. Doing this would additionally affect any other program using the Readline library for command line editing (such as some interactive mode database clients).
-
Thanks to both of you! This has driven me crazy for a very long time. For
tcshjunkies like me, could you perhaps augment your answer to add that if you put the lineset editing-mode viinto~/.inputrc, then you'll have the property I want by default?Leo Simon– Leo Simon2021-04-04 18:20:09 +00:00Commented Apr 4, 2021 at 18:20