OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

Editing Modes

Let's start up vi again, this time passing to it the name of a nonexistent file. This is how we can create a new file with vi:


[me@linuxbox ~]$ rm -f foo.txt

[me@linuxbox ~]$ vi foo.txt

[me@linuxbox ~]$ rm -f foo.txt

[me@linuxbox ~]$ vi foo.txt


If all goes well, we should get a screen like this:




~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

"foo.txt" [New File]


~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

"foo.txt" [New File]


The leading tilde characters (”~”) indicate that no text exists on that line. This shows that we have an empty file. Do not type anything yet!

The second most important thing to learn about vi (after learning how to exit) is that vi is a modal editor. When vi starts up, it begins in command mode. In this mode, almost every key is a command, so if we were to start typing, vi would basically go crazy and make a big mess.


 

Top OS Cloud Computing at OnWorks: