Is there any shell in which you can edit your commands with vim shortcuts? Ideally, you would be in insert mode so that it wouldn't make any difference with other shells, but you could also use escape to go to normal mode and use vim commands. Thanks!
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
bash can be told to enter vi mode via set -o vi
. See the man page for more details.
回答2:
zsh can do that. Put this in your .zshrc to default to vim insert mode:
bindkey -v
回答3:
Readline library itself can do this: instead of using set -o vi
in bash, add set editing-mode vi
to ~/.inputrc
. Bash and some other programs use readline, so you will get vi-like editing in them. Zsh does not, but it has its own implementation of vi-like editing mode (see @weronika's answer).