Subcommands

  • Start vi with vi file1 [file2 [...]]. See Table 10-10.

    Table 10-10. Basic vi editing commands

    Command

    Description

    Esc

    Exit insert mode and put the editor into command mode.

    h or left arrow

    Move left one character.

    j or down arrow

    Move down one line.

    k or up arrow

    Move up one line.

    l or right arrow

    Move right one character.

    H

    Move to the top of the screen.

    L

    Move to the bottom of the screen.

    G

    Move to the end of the file.

    W

    Move forward one word.

    B

    Move backward one word.

    0 (zero)

    Move to the beginning of the current line.

    ^

    Move to the first nonwhitespace character on the current line.

    $

    Move to the end of the current line.

    Ctrl-B

    Move up (back) one screen.

    Ctrl-F

    Move down (forward) one screen.

    i

    Insert at the current cursor position.

    I

    Insert at the beginning of the current line.

    a

    Append after the current cursor position.

    A

    Append to the end of the current line.

    o

    Start a new line after the current line.

    O

    Start a new line before the current line.

    r

    Replace the character at the current cursor position.

    R

    Start replacing (overwriting) at the current cursor position.

    x

    Delete the character at the current cursor position.

    X

    Delete the character immediately before (to the left) of the current cursor position.

    s

    Delete the character at the current cursor position and go into insert mode. (This is the equivalent of the combination xi.)

    S

    Delete the contents of the current line and go into insert mode.

    dX

    Given a movement command X, cut (delete) the appropriate number of characters, words, or lines from the current cursor position. ...

Get LPI Linux Certification in a Nutshell, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.