In the graphical Linux world, vi editor now rarely used. But it is only choice at command prompt if graphical interface not available. The VI editor shipped with almost every Linux distributions.? The most hardest and annoying things with vi editor is to switching between Command Mode and Input Mode.? The Command mode used to search for characters, and delete existing text. But if you need to enter new text or edit existing text, then you have to enter into Input mode.? Focusing If you focus on a few basics, you’ll get the job done.

List of Useful Commands

Entering Input Mode

  • a? ? ? ? Add text after the cursor.
  • i ? ? ? Insert text before the cursor.
  • R ? ? ? Replace text starting at the cursor.
  • o ? ? ? Insert a new line after the current one.

Entering Command Mode

  • esc? ? Switch from Input mode to Command mode.

Exiting or Saving Your File

  • :w ? ? Write file to disk, without exiting editor.
  • ZZ? ? Save the file and exit.
  • :q!? ? Quit without saving.

Other Useful Commands

  • ® ? ? ? ? ? ? ? ? ? ? ? Move cursor one space right.
  • ¬ ? ? ? ? ? ? ? ? ? ? ? ? Move cursor one space left.
  • ­ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Move cursor up one line.
  • ¯ ? ? ? ? ? ? ? ? ? ? ? ? Move cursor down one line.
  • ctrl-F ? ? ? ? Move forward one screen.
  • ctrl-B ? ? ? ? Move backward one screen.
  • $ ? ? ? ? ? ? ? ? ? ? ? ? Move cursor to end of line.
  • ^ ? ? ? ? ? ? ? ? ? ? ? ? Move cursor to beginning of line.
  • :1 ? ? ? ? ? ? ? ? ? ? ? Move to first line of file
  • :$ ? ? ? ? ? ? ? ? ? ? ? Move to last line of file
  • / ? ? ? ? ? ? ? ? ? ? ? ? ? Search for a character string.
  • ? ? ? ? ? ? ? ? ? ? ? ? ? ? Reverse search for a character string.
  • x ? ? ? ? ? ? ? ? ? ? ? ? Delete the character at the cursor position.
  • dd ? ? ? ? ? ? ? ? ? ? Delete the current line.
  • p ? ? ? ? ? ? ? ? ? ? ? ? Paste data that was cut with x or dd commands.
  • u ? ? ? ? ? ? ? ? ? ? ? ? Undo.

Written by Bala Krishna

Bala Krishna is web developer and occasional blogger from Bhopal, MP, India. He like to share idea, issue he face while working with the code.

This article has 2 comments

  1. Yoshie Guard

    Hello, good internet site you have here, but I merely had to let you know about what may potentially be a internet browser compatibility problem. I’m running Windows Vista 64 bit with Ie, and the format is strange. It’s a little bit difficult to see some regions of the blog, and I am running my screen resolution at 1280 x 800. I’m sure you didn’t have in mind for your web page to seem so peculiar, so is there any way you are able to assist me take care of this matter?