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 …
iao - moving …
hjkland line numbers - mending …
xddyypu - 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
- 71Modes, and how to get outOpen
viand get out for certain. Move between the mode that types and the mode that commands.Go to the exercises - 72Starting to typeThe six of
iaIAoO. Learn to choose where you begin typing.Go to the exercises - 73Moving where you meant
h j k land0 $ w b,gg Gand line numbers. Carry the cursor in one breath.Go to the exercises - 74Removing, and mending
xdwddDrcw, and the shape with a number. Undo withu, repeat with..Go to the exercises - 75Copying, and pastingCopy with
yyand paste withp. Put withddto move lines about.Go to the exercises - 76Searching, and replacingFind by contents with
/and jump. Replace them all with:%s.Go to the exercises
A final challenge
- 77A test of skillPut thirteen chapters of tools together with no instructions. No new commands appear.Go to the exercises