I use vi mode in bash all of the time. It would be really useful to see visually if I am in command mode or insert mode.
For example when I want to search the history, typing /my_search
in either mode looks the same until I press Enter, and by then it's too late. I find myself pressing Esc much more than necessary just to make sure I'm in the right mode....
If you're not sure which mode vi is presently in, simply press Esc to make sure it's in command mode and continue from there.
The bash shell (again, via GNU Readline) is able to provide this functionality for us. In order to enable it, you run the command $ set -o vi.
Vi edit modesTo enter Insert mode, press i . In Insert mode, you can enter text, use the Enter key to go to a new line, use the arrow keys to navigate text, and use vi as a free-form text editor. To return to Command mode, press the Esc key once. [ Looking for a different text editor?
You can configure this in the .inputrc
file that readline uses.
set show-mode-in-prompt
For me, this draws a +
as the first character in insert mode, a :
in normal mode, and no character in search mode.
(You can also enable vi mode in here using set editing-mode vi
, which will enable it for all programs using readline, such as the python and ruby interpreters, instead of just bash).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With