Linux Labs

First steps / Stage 9 of 15

Text and editors

Not running Starting usually ~20 s
Leave the lesson

Step 5 of 8 · on a machine · 5 min

Editing with a copy

A config edit gets two moves around it: a copy before and a check after. Then a bad edit is undone with one command.

While you type, Vim changes the buffer — a copy of the file in the editor's memory. The file on disk changes only on :w. So correct text on the Vim screen does not yet mean another program will read the new version.

Before editing a config, copy the original: cp app.conf app.conf.bak. Take the copy before the edit, or it will hold the changed text. If the edit goes wrong, put the original back: cp app.conf.bak app.conf.

After leaving Vim, read the file with cat: that shows what is on disk.

Exercise · do it

Save a focused edit

In ~/text-lab, first copy app.conf to app.conf.bak. Then open app.conf in Vim, change port=8080 to port=9090 and keep mode=training. Save, quit, and read both files with cat.

Sign in and start The machine is available after signing in

Goals · 0 of 2

  • Keep the original in app.conf.bak not done yet
  • Change the port in app.conf to 9090 not done yet

Step goals

0 of 2
  • Keep the original in app.conf.bak — not done yet
  • Change the port in app.conf to 9090 — not done yet
Ubuntu 24.04

Step goals

0 of 2
  • Keep the original in app.conf.bak — not done yet
  • Change the port in app.conf to 9090 — not done yet
Loading…