-2

https://www.gnu.org/software/bash/manual/html_node/Readline-vi-Mode.html said we could do set -o vi to use vi mode instead of emacs mode for command line editing.

And the help: ex-edit-index sais

c_CTRL-P        CTRL-P          after using 'wildchar' with multiple matches:
                                go to previous match, otherwise: recall older
                                command-line from history.

However when I press CTRL-P I just got ^P

enter image description here

May I know why ?

E_net4
  • 27,810
  • 13
  • 101
  • 139
Xiangpeng
  • 44
  • 8

1 Answers1

2

Readline's "vi mode" is neither vi nor Vim. It is a partial emulation of vi shoehorned into the command line context.

That <C-p> you are referring to is a Vim command so there is no reason whatsoever to expect it to do anything in that context. Vim's documentation is totally irrelevant in this case.

Search for Vim Mode bindings in $ man readline for the actual bindings at your disposal in that "mode".

romainl
  • 186,200
  • 21
  • 280
  • 313
  • `man readline` gives me `No manual entry for readline` – Xiangpeng Oct 19 '21 at 14:11
  • Then you are not using readline, which means that you are not using bash and that referring to the bash manual or the readline manual is utterly pointless. Or your system is broken for some reason and you have more pressing things to think about than enabling vi mode in readline. – romainl Oct 19 '21 at 14:16
  • I'm not sure why I kept getting negative voting. I am using bash. By typing `man readline`, I got same result on mac and centos `No manual entry for readline`, that's it – Xiangpeng Oct 20 '21 at 14:22
  • this is Top of my `info`, there's just no readline * ptx: (coreutils)ptx invocation. Produce permuted indexes. * pwd: (coreutils)pwd invocation. Print working directory. * readlink: (coreutils)readlink invocation. Print referent of a symlink. * realpath: (coreutils)realpath invocation. Print resolved file names. * rm: (coreutils)rm invocation. Remove files. * rmdir: (coreutils)rmdir invocation. Remove empty directories. * runcon: (coreutils)runcon invocation. Run in specified SELinux CTX. – Xiangpeng Oct 20 '21 at 14:34
  • Where to begin? The vi mode you want is a feature of readline and readline is used in bash to handle command-line I/O. If, for some reason, you don't have readline, then you can't have the desired feature. If you want the feature, fix your system. – romainl Oct 20 '21 at 15:03
  • https://catonmat.net/ftp/bash-vi-editing-mode-cheat-sheet.pdf those shortcuts work for me, hence I have readline. Just I don't have that on my `man` or `info`, this doesn't mean my system is broken and I'm not the only one having this https://askubuntu.com/questions/1024863/where-can-i-find-documentation-for-readline Can't you please don't downvote me twice ? I have hardly enough reputation to ask questions. – Xiangpeng Oct 21 '21 at 14:14
  • If I could I would downvote a second time, if only because your edit completely changed the meaning of the question and thus the relevancy of the answer. That's disingenuous at best. – romainl Oct 21 '21 at 14:40
  • you are too strict sir. but anyway thanks for your time and reply, it was my bad to take `:help ex-edit-index` from https://stackoverflow.com/a/21207170/6151972, when I mistook the question as command line in bash with vim mode instead of the bottom command line bar in vim editor. – Xiangpeng Oct 22 '21 at 04:40