Vi

From LinuxNewbie

vim, is simply a good/fast and lightweight editor. It might look complicated at the beginning but after a little while using it, you can't go back. Let's go over the simple commands that you will all need to use when starting with vim.

  • First of all:
To open a file, you type:
"Esc + : + e  + name of the file", then press enter.
For instance, ":e test.txt" will give you:
http://undernetlinuxnewbie.org/wiki/tutorials/images/opening.jpg
or simply something like:
Ex:
 davidc@oxygen:~$ vim cmp.pl
 will give you this:
 http://undernetlinuxnewbie.org/wiki/tutorials/images/opening2.jpg
Goto Second step.


  • Second thing you wanna do is start writing to the file.
To start writing (--INSERTING--) to the file, type:
"i" .. simply. or sometimes, shift+i which should give you and something has this:
http://undernetlinuxnewbie.org/wiki/tutorials/images/inserting.jpg


  • Third point of this simple tutorial for today,
To quit or save what you have done, 
"Esc + : + w" to save your file.
"Esc + : + q" to quit
"Esc + : + q!" to quit without saving changes.

Do you see a pattern?
:e test.txt -> opens a file.
:w          -> writes
:q          -> quits
:wq         -> writes and quits
:q!         -> quit whithout saving.