Bash can be set to operate in vim mode . However, my .vimrc
is no longer used. Specifically, my mapping of jj to Esc no longer works. I have to press Esc to exit to insert mode. How do I tell bash to use my .vimrc
file?
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.
Sourcing it is the same as typing each command in order. You source with the command :source (usually shortened to :so ). The only file sourced by default is the . vimrc ( _vimrc on windows) so that's a place you can keep all the commands you use to set up Vim every time.
You are looking for bash-'s vi mode (which is just that: a vi input mode for bash, and has nothing at all to do with vi or vim).
It does have to do with readline/inputrc as far as I know so you could see whether you can
links:
The last link contains a somewhat more advanced example of a .inputrc
for use with bash:
# Edit options before rerunning previous command, eg: ls a b c -> ls -al a b c
"\e-": "\C-p\C-a\M-f "
# Cycle thru completions.
"\e/": menu-complete
# glob patterns without executing, eg: 'rm *x'
"\ee": glob-expand-word
# Vim style history search
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
# Two escapes clear command line.
"\e\e": "\C-a\C-k"
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