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

by Ramesh Natarajan on October 16, 2009

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

Linux Sysadmin Course Linux provides several powerful administrative tools and utilities which will help you to manage your systems effectively. If you don’t know what these tools are and how to use them, you could be spending lot of time trying to perform even the basic administrative tasks. The focus of this course is to help you understand system administration tools, which will help you to become an effective Linux system administrator.
Get the Linux Sysadmin Course Now!

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

{ 1 comment… read it below or add one }

1 Gage August 25, 2012 at 12:23 am

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

Leave a Comment

Previous post:

Next post: