Vi-Linux Text Editor

17 Sep

The hardest thing to understand about vi is the concept of modes. When using vi, you’re always in either Command or Input mode. Unfortunately there’s no clue as to which mode is currently active. In Command mode, you can move the cursor, search for characters, and delete existing text. But to enter or edit new text, you have to switch to Input mode.

When you start vi, you’re in Command mode. To enter Input mode, type the letter a (lowercase only) to signal that you want to add text after the cursor position. Pressesc to switch back to Command mode at any time.

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.

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.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: