CHAPTER 13 · 7 lessons · 88 exercises

vi, and a final challenge

Edit a file from inside the terminal. Then, at the end, use everything you have learned at once.

The last chapter. First vi, and then a final challenge.

vi is the editing program that is on every server without fail. It is your last resort for mending a file in a place where there is nothing else, and that is exactly why you cannot go round it.

What anyone opening it for the first time thinks, though, is "how on earth do I get out". Letters you type are not taken, and Ctrl-C does not end it. This is not broken; it is because vi works on the idea of modes.

  • the idea of modes … am I typing now, or commanding
  • starting to type … i a o
  • moving … h j k l and line numbers
  • mending … x dd yy p u
  • saving and getting out … :w :q :q!

There is not much to learn. That pressing Esc always brings you back to command mode, and that with :q! you can get out without saving whatever you have done. Know those two and you will never be stuck again.

And last comes the challenge. Problems where you put together what thirteen chapters taught you, with no instructions. What to use and how, you decide. Solve them and you need never fear a terminal again.

Lessons in this chapter

Modes and editing

  1. 71Modes, and how to get outOpen vi and get out for certain. Move between the mode that types and the mode that commands.Go to the exercises
  2. 72Starting to typeThe six of i a I A o O. Learn to choose where you begin typing.Go to the exercises
  3. 73Moving where you meanth j k l and 0 $ w b, gg G and line numbers. Carry the cursor in one breath.Go to the exercises
  4. 74Removing, and mendingx dw dd D r cw, and the shape with a number. Undo with u, repeat with ..Go to the exercises
  5. 75Copying, and pastingCopy with yy and paste with p. Put with dd to move lines about.Go to the exercises
  6. 76Searching, and replacingFind by contents with / and jump. Replace them all with :%s.Go to the exercises

A final challenge

  1. 77A test of skillPut thirteen chapters of tools together with no instructions. No new commands appear.Go to the exercises

This is the last chapter of the course.