I want to use w
for next word and b
for previous word. If I could do more than that I would be even happier.
I use bash if that matters.
I'm surprised you haven't yet found out about
set -o vi
This enables the vi editing mode in Bash (to make this permanent put the command in your ~/.bashrc
file). Greg's Wiki has a short summary, and here's a Unix & Linux question about its advantages.
This setting is for the Bash shell, regardless of the terminal (who's purpose is to provide a container for typing and seeing text (plus selecting and pasting with the mouse) - apart from tabbed windows and some global window management, it shouldn't interfere with what's running inside it).
To enable this for some more (terminal-based) applications that use the readline library for input, you can put this into ~/.inputrc
# Do what "set -o vi" does in Bash to whatever uses readline.
set editing-mode vi
I'm surprised it is mentioned here, so I'll mention it for completeness' sake. Also for the zsh shell, the way of setting vi keybinding is different from bash.
In zsh vi keybinding are set with:
bindkey -v
For a gentle introduction, you can read here. After which, the official documentation should look less intimidating.
For zsh users that use vim(not vi):
In addition to adding the vi keybinding, you should avoid the vi-related backspace issue(backspace stops working) by putting the following two statements in your ~/.zshrc
:
# use vi key bindings
bindkey -v
# avoid the annoying backspace/delete issue
# where backspace stops deleting characters
bindkey -v '^?' backward-delete-char
The backspace issue has been discussed here in more detail.
For Fish shell users, put the command fish_vi_key_bindings
into your config. Default location is: ~/.config/fish/config.fish
For more details, see answer: https://stackoverflow.com/a/28445450
After googling for many hours, and came across this amazing zhs-shell plugin called https://github.com/jeffreytse/zsh-vi-mode
It got so many cool features like delete between brackets, quotations ..etc. These features not available in the original vim-mode
plugin that comes with oh-my-zsh
(without tweaking and configuring of course).
simply add it to your zsh-shell script plugin manger in your .zshrc
that's all.
I hope this would be useful for anyone wish to have vim-command in his iTerm, or any other terminal application.
tested for both Alacrity
and iTerm2
btw.