0

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!

0

1 Answer 1

4

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).

1
  • Thanks to both of you! This has driven me crazy for a very long time. For tcsh junkies like me, could you perhaps augment your answer to add that if you put the line set editing-mode vi into ~/.inputrc, then you'll have the property I want by default? Commented Apr 4, 2021 at 18:20

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.