Re: vi cheat sheet

Top Page
Attachments:
Message as email
+ (text/plain)
+ vi_useful_subset.txt (text/plain)
Delete this message
Reply to this message
Author: Mark Jarvis
Date:  
To: plug-discuss
Subject: Re: vi cheat sheet

There are some good cheat sheets on the net and they tell you about ALL
of the vi options and commands--more than you ever wanted to know about
vi. for an analogy, most of us neither need, want, or know ALL of the
Office commands--even for the Office app we use most. You use what could
be called "a useful subset". Attached is handout describing my useful
subset of vi commands. In other words, these are the commands that I use
enough to remember. If you need an additional something, there's always
the complete cheat sheet to fall back on.

Hope it helps.

-mj-

Alan Dayley wrote:
> Jonathan Hohle said:
>
>>does anyone have a vi cheat sheet they find useful? i've been trying to
>>get into vi for a while, but have never taken the time to learn all the
>>commands. and when i do have to use a commandline editor always fall
>>back on nano or pico (why does everyone have such a problem with those
>>editors??)
>>
>>anyway, figured it wouldn't hurt to learn vi (especially when i come
>>across a unix system that has nothing but). so can anyone lend me a
>>cheat sheet, or point me to something that will get me into vi?
>
>
> google search on "vi cheat sheet" brings many hits. Pick the one you like
> most.
>
> Alan
>
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list -
> To subscribe, unsubscribe, or to change you mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>

    A Useful Subset of vi Commands
    
    1. Start
        a) vi filename     (std. editing)
        b) view filename     (read-only)
    2. End (must be in command mode)
        a) Quit without saving
            i) :q    (quit--if no changes have been made)
            ii) :q!    (force a quit without saving--even if changes have been made)
        b) Quit and save
            i) :wq    (write and quit)
            ii) :wq!    (force a write over a read-only file and quit)
            iii) :ZZ
            iv) :x
    3. Modes
        a) Command mode
            i) esc switches from Insert to Command Mode
        b) Text entry or insert mode
            i) Any of the text entry commands switches from Command to
               Insert Mode
    4. Move (when in command mode)
        a) Simple
            i) cursor keys
            ii) h, j, k, l keys (left, down, up, right)
        b) Jump
            i) 0 (beginning of line)
            ii) $ (end of line)
            iii) :1(line one of file)
            iv) :n (line n of file)
            v) :$ (last line of file)
    5. Text Entry (Insert Text) Commands
        a) Insert
            i) i (insert typing here, i.e. insert before cursor)
            ii) I (insert typing at beginning, i.e. insert at beginning
                   of line)
        b) Append
            i) a (append typing here, i.e. insert after cursor)
            ii) A (append typing at end, i.e. insert at end of line)
        c) Replace
            i) r (replace the single character at the cursor)
            ii) R (start replacing at the cursor and keep going to the
                   right)
    6. Cut and Paste Commands
        a) dd (cut current line to the buffer)
        b) ndd (starting at the current line, cut n lines to the buffer,
                eg 5dd)
        c) P (paste from the buffer above the current line)
        d) p (paste from the buffer below the current line)
    7. Find Commands
        a) /string <enter> (find and place the cursor under the first
             appearance of "string" occurring after the current cursor
             position)
        b) / <enter> (find the next occurrence of the search string--
             Note:  will wrap around back to beginning)
        c) n (find the next occurrence of the search string)
    8. Miscellaneous Commands
        a) u (undo last command)
        b) J (join end of current line with next line)
        c) x (delete the character at the cursor)