4

I'm trying to change my bash vi mode keys to enter and exit insert mode, I would like to set these shortcuts:

  • Ctrl-\ : Enter moviment mode
  • Alt-\ : Enter insert mode

how can I do that? I'm trying editing it to my .inputrc and/or .bashrc without success.

.inputrc:

set echo-control-characters off
#want vi to be the default editor for readline                      
set editing-mode vi                                            
set completion-ignore-case On
echo "mode: $mode"
# vi settings                                         
$if mode=vi
    #"\C-l":clear-screen
    #"\C-p":history-search-backward
    "\C-\":vi-movement-mode
    #set keymap vi-insert
    #"jj":vi-movement-mode
    "\M-\":vi-insertion-mode
$endif

then I'm trying to sourcing it:

maiko.costa@PEDCWB033:~$ source .inputrc 
mode: =vi
mode=vi: command not found

what it's wrong with my $if ? Below my current bash version.

maiko.costa@PEDCWB033:~$ echo $BASH_VERSION
4.1.5(1)-release

Thx.

2

The $if mode=vi conditional looks correct.

Read .inputrc into bash with:

bind -f ~/.inputrc

To read the bash help for bind:

help bind

AFAIU, echo is not a valid inputrc command.

Here are the Bash readline docs: https://www.gnu.org/software/bash/manual/bashref.html#Readline-Init-File

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.