O'Reilly logo

The Linux Command Line by William E. Shotts Jr.

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

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

˜
˜
˜
˜
˜
˜
˜
˜
˜
˜
˜
˜
˜
˜
˜
˜
˜
˜
˜
˜
˜
"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.

Entering Insert Mode

In ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required