By default, bash has its own set of short cut to make it easier to type and change command. But it's quite different from what we vi users have get used to. It's a pain to try to remember two different style of short cuts.
Fortunately, bash has the ability to allow us to retain our vi habit. To turn this feature on, simply run set -o vi . Then we can verify this feature is enabled by running set -o and see if it shows vi on.
Having turned it on, we can edit our commands just as in vi. By default, the shell is in insert mode. By pressing escape, it turns to command mode in which we can use vi command to move, search around.
For example, we can find a command in history by :
- press escape
- press /
- input search terms
- press n to search for next match
Bonus: In windows prompt, we can use F7 to get a command history list and F8 to search in command history.
Master the Linux bash command line with these 10 shortcuts
Useful Keyboard Shortcuts for the DOS Command Prompt in Windows
Find and bind key sequences in bash