A Look at the VI Editor - Saving and Closing a file (Page 2 of 4 )
Use :w for saving the content and :q for quitting. Here are some examples.
:w | Saves current file but doesn't exit |
:w file | Saves current content as file but doesn't exit |
:n,mw file | Saves lines n through m to file |
:n,mw >>file | Saves lines n through m to the end of file |
:q | Quits VI and may prompt if you need to save |
:q! | Quits VI without saving |
ZZ or :wq | Saves and exits VI |
VI has two modes; one is the command mode and the other is the edit mode. To change to the edit mode you have to use i (insert) or a (append). Use the ESC character to change back to command mode.
Inserting texts: Use i, I, a, A, o or O for insertion as described in the following table.
i | Insert before cursor |
I | Insert before line |
a | Append after cursor |
A | Append after line |
o | Open a new line after current line |
O | Open a new line before current line |
Next: Cursor motion/movements >>
More BrainDump Articles
More By Mamun Zaman