How to Use the vi Editor

April 2nd, 2009 by @HKw@! | Filed under Unix.

Starting vi and Saving Files
vi filename
- start editing filename, create it if necessary

Saving the file you’re working on and/or leaving vi:

:wq
-
write the file to disk and quit

:q!
-
quit without saving any changes

:w! newfile
-
write all lines from the entire current file into the file ‘newfile’, overwriting any existing newfile

:n,m w! newfile
-
write the lines from n to m, inclusive, into the file newfile, overwriting any existing newfile

Share

Leave a Reply

BlogCatalog