≡ Menu

Do You Like to Perform Vi Style Editing in BASH Command Line ?

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
Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • Gage August 25, 2012, 12:23 am

    This just let me free forever, thank you so much!