Very short introduction to Vi (by L. M. MacEwan on floppix.com)ΒΆ


Using vi:

  1. To start vi, type vi <filename>
  2. To get into insert mode and start entering text into the document press:
    • i - to start inserting text before the cursor
    • a - to start inserting text after the cursor
    • I - to start inserting text at the beginning of the current line
    • A - to start inserting text at the end of the current line
    • o - to open up a new line and insert text on the new line
  3. To get back to command mode:
    • press [Esc]
  4. To delete:
    • make sure you are in command mode; press [Esc]
    • x - deletes the character at the cursor
    • dd - deletes the current line
    • D - deletes from the current postion in the line to the end of the line
    • dG - deletes to end of file
  5. To undo a command:
    • u - undo the last command
  6. To move a line or block of lines:
    • dd - deletes the line from the current postion
    • p - after moving to the new location; p will put the line(s) after the current line
    • 10dd - deletes 10 lines starting from the current postion
    • p - after moving to the new location; p will put all 10 lines after the current line
  7. To copy a line
    • yy - deletes the line from the current postion
    • p - after moving to the new location; p will put the line(s) after the current line
  8. To exit:
    • :q! - quit without saving
    • :q - quit
    • :wq - save the file and quit
    • :w - save the file without quitting

You are done with this small intro, good luck padawan!