1. Tech

Your suggestion is on its way!

An email with a link to:

http://linux.about.com/library/cmd/blcmdl_vi.htm

was emailed to:

Thanks for sharing About.com with others!

Linux / Unix Command: vi, vim, gvim
Command Library

SYNOPSIS

% vi [options] [file ..]

DESCRIPTION

  • The "vi" text editor is not recommended for newbies.
  • To exit vi (no changes saved) use these five characters: <ESC>:q!<Enter>.
  • vim: Modern Linux distributions use vim (="vi improved") in place of vi, and vim is somewhat better than the original vi.
  • gvim: The GUI version of vi is also available: type gvim in an X terminal.
  • The most important thing to understand about vi is that is a "modal" editor, i.e., it has a few modes of operation among which user must switch. (The same keystrokes have different effects in different modes.) The quick reference is below, with the 4 essential commands in red.

    The commands to switch modes:

The key

Enters the mode Remarks
<ESC> command mode (get back to the command mode from any editing mode)
i "insert" editing mode (start inserting before the current position of the cursor)

DO NOT PRESS ANY OTHER KEYES IN THE COMMAND MODE. THERE ARE MORE COMMANDS AND MODES IN THE COMMAND MODE!

Copying, cutting and pasting (in the command mode):
v start highlighting text. Then, move the cursor to highlight text
y copy highlighted text
x cut highlighted text
p paste text that has been cut/copied

Saving and quitting (from the command mode):
:w write (=save)
:w filename write the contents to the file "filename"
:x save and exit
:q quit (it won't let you if changes not saved)
:q! quit discarding changes (you will not be prompted if changes not saved)

EXAMPLE

% vi parse_record.pl

Starts vi with the default settings and opens file parse_record.pl.

Important: Use the man command (% man) to see how a command is used on your particular computer.

>> Linux Command Library Index

>> Also see Shell Command Library

You can opt-out at any time. Please refer to our privacy policy for contact information.

Discuss in my forum

©2014 About.com. All rights reserved.