Lesson 8.2: Vim basics: modes, saving and quitting
What vi and Vim are and why they're on every server, the idea of modes (normal, insert, command-line), typing text with i and Esc, saving and quitting with :w, :q, :wq and :q!, moving with h j k l, deleting with x and dd, opening a line with o, undoing with u, and read-only files.
20 min
You will learn to
- Explain normal, insert and command-line mode
- Insert text and return to normal mode
- Save and quit, or quit without saving
- Move with h j k l and delete with x and dd
- Undo a change
- Read Vim's E37 and readonly messages
Key terms
- vi
- The standard Unix screen editor, written by Bill Joy in 1976. POSIX requires a vi, so some vi exists on practically every Unix-like system.
- Vim
- Vi IMproved: Bram Moolenaar's extended vi (1991). On Ubuntu and Rocky Linux the vi command starts Vim.
- Modal editor
- An editor where the same key does different things depending on the mode. In Vim, x in insert mode types an x; in normal mode it deletes a character.
- Normal mode
- The mode Vim starts in. Keys are commands: move, delete, copy, paste. Esc always brings you back here.
- Insert mode
- Keys type text. Entered with i, a, o and similar; the bottom line shows -- INSERT --.
- Command-line mode
- Entered with : from normal mode. You type a command at the bottom and press Enter: :w write, :q quit, :wq both, :q! quit and discard changes.
← Editing files with nano · All lessons · Working efficiently in Vim →