I am using the vim mode in my bash (i.e. I setup readline to use vim mode through ~/.inputrc
).
If I do a history-search-backward
and then history-search-forward
in insert mode with some characters already typed, the bash jumps to command mode when the forward-search arrives at the end.
For example, this happens when I:
- Type
echo "foo"
- Type
e
- Press Up Arrow (prompt shows
echo "foo"
in insert mode) - Press Down Arrow (prompt shows
echo "foo"
in command mode)
It does not happen if I omit the step where I type e
.
Furthermore, bash also jumps to command mode whenever I press the Delete
key, plus it toggles capitalization.
For example, this happens when I:
- Type
echi
- Move left
- Press
Delete
(prompt showsecHi
in command mode)
This happens independent of moving left, only the letter that is toggled changes.
(The first phenomenon occurs exactly the same way in ipython
, which also uses readline
. The second phenomenon is a bit diferent in ipython
: Pressing delete in command mode does what it's supposed to do, pressing delete in insert mode also does what it's supposed to do, unless I am at the end of the line, in which case it also jumps back to command mode, but does not toggle capitalization.)
EDIT To fix the problem with the Delete
key, put "\e[3~": delete-char
in your '~/.inputrc`
I am using the following .inputrc
:
1 set editing-mode vi
2 set keymap vi-command
3 "\e[A":history-search-backward
4 "\e[B":history-search-forward
5 "\e[C":forward-char
6 "\e[D":backward-char
7 ##
8 "j":history-search-forward
9 "k":history-search-backward
10 set keymap vi-insert
11 "\e[A":history-search-backward
12 "\e[B":history-search-forward
13 "\e[C":forward-char
14 "\e[D":backward-char
15 ##
16 set show-mode-in-prompt on
17 ##
18 set vi-cmd-mode-string "\1\e[2 q\2\1\e[1;31m\2(cmd)\1\e[0m\2"
19 set vi-ins-mode-string "\1\e[5 q\2(ins)"
20 ##
21 set keymap vi-insert
22 RETURN "\e\n"
23 set keymap vi-command
24 v: ""
and the following .vimrc
:
filetype plugin on
set shellslash
set grepprg=grep\ -nH\ $*
filetype indent on
let g:tex_flavor='latex'
set ff=unix
nmap <CR> o<Esc>
set number
set showcmd
0 Answers