AMAZON

Saturday, September 1, 2012

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

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.

No comments:

Post a Comment