Very short introduction to Vi (by L. M. MacEwan on floppix.com)
Using vi:
- To start vi, type
vi <filename>
- 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
- To get back to command mode:
- 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
- To undo a command:
- u - undo the last command
- 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
- 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
- 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!