Question: I like Vi style of editing and I’m very comfortable with Vi commands. How do i use Vi style line editing in Unix command line?
Answer: Execute set -o vi at your Unix shell to enable Vi style editing.
Enable Vi Style Editing in BASH
$ set -o vi
By default the command line is in emacs mode.
After you perform set -o vi , press ESC to go to command mode. From here you can execute Vi command to perform any command line operation including the following:
- Go to the previous word in the command using b, and the next word using w.
- Use k to view previously executed command and j to view the next.
- Use 0 (Zero) to jump to start of the command. Use $ to go to the end of the command.
- Use /, n, N, fX to perform standard Vim search in command line.
- /search-chars which searches through the history and display the matching command that can be executed.
- Refer to Vi Editor Navigation Fundamental article to understand what Vi command can be used in the command line.
To make this change permanent set this option in bashrc.
$ cat ~/.bashrc set -o vi
Disable Vi Style Editing in BASH
Execute the following to revert back to emacs mode.
$ set -o emacs
Comments on this entry are closed.
This just let me free forever, thank you so much!