How to change BASH "editing-mode vi" shortcuts?

4

1

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.

MaikoID

Posted 2014-09-17T12:35:01.013

Reputation: 224

Answers

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

Wes Turner

Posted 2014-09-17T12:35:01.013

Reputation: 204