set -o vi: "Allow shell command line editing using the built-in vi editor. Enabling vi mode shall disable any other command line editing mode provided as an implementation extension."
No other mode, specifically emacs mode, is included in the POSIX standard.
Take from this what you will.
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...
Back in the heyday of POSIX standardization, the Emacs camp and the POSIX camp were both very opinionated and not entirely aligned. One example is the standard disk block size used in command line utilities such as du and df. RMS made GNU use 1kb instead of the POSIX standard 512 byte size, but this could be overriden by setting the environment variable POSIX_ME_HARDER.
The downside is that while vim mode works nicely on bash, other commands like gdb etc that also use read line aren’t as easy to get into vim mode, if they support it at all…
set editing-mode vi
set keymap vi-command
That does the trick for me in python shell, psql, etc.First thing I do on any fresh unix box is setting above, and echo "set -o vi" >> ~/.bash_profile.
bind -vHere is my config from a happy gdb vim mode user :
set editing-mode vi
# If set to ‘on’, Readline performs filename matching and completion in a case-insensitive fashion. The default value is ‘off’.
set completion-ignore-case on
# If set to ‘on’, Readline displays possible completions using different colors to indicate their file type. The color definitions are taken from the
set colored-stats on
# Perform partial (common) completion on the first Tab press, only start # cycling full results on the second Tab press (from bash version 5)
set menu-complete-display-prefix on
### MAPPINGS ###
# Allow to refresh the screen
"\C-l":clear-screen
# If there are multiple matches for completion, Tab should cycle through them
TAB:menu-complete