vi <file>

  • Movement:

    h - Left

    j - Down

    k - Up

    l - Right

    :n - go to line

    :$ - Go to the end of file

  • Making Changes

    i - Insert here

    I - Insert at the beginning of line

    a - Append here

    A - Append from the beginning

    x - delete

    dw - delete word

    dd - delete line

    D - delete from here on

    r - replace char

    cw - replace word

    cc - replace current line

    C / c$ - replace from here on

    ~ - swap upper/lower casing

    yy - copy current line

    p - paste

    u - undo

    <Ctrl>-R - redo

  • Searching

    /<pattern> - Forward search

    ?<pattern> - Reverse search

    n - next item

    N - previous item

  • Repeating Actions

    <n><action><insert> - Repeat Action (insert opt) n times

    ex: Write A 45 times == 45iA<esc>

  • Saving & Breaking Out:

    <esc> - exit current mode

    :w - write

    :q! - Leave & don't save a thing!

    :wq! - Write & Run!