0.x — Chapter 0 summary and quiz

0.x — Chapter 0 Summary and Quiz#

Let’s review what we’ve learned in Chapter 0 and test your understanding with a quiz.

Chapter Summary#

Lesson 0.1: Introduction to Vim#

Lesson 0.2: Installing and Launching Vim#

Lesson 0.3: Survival Guide#

The Three Essential Modes:

ModePurposeEnterExit
NormalNavigate, manipulateEscEnter another mode
InsertType texti, a, oEsc
Command-lineEx commands:Esc or Enter

Save and Exit Commands:

CommandAction
:wWrite (save)
:qQuit
:wqWrite and quit
:q!Quit without saving
ZZSave and quit (shortcut)

Basic Navigation:

KeyMovement
hLeft
jDown
kUp
lRight

Basic Editing:

CommandAction
xDelete character
ddDelete line
uUndo
Ctrl-rRedo

Key Terms#

Quiz Time#

Test your understanding of Chapter 0 concepts.


Question #1

What is the key difference between Vim and traditional text editors?

Show Solution

Vim is a modal editor. Unlike traditional editors where pressing a key always types that character, Vim has different modes for different purposes:

  • Normal mode: Keys trigger commands (navigation, deletion, etc.)
  • Insert mode: Keys type characters

This separation allows simple keystrokes to perform powerful operations without modifier keys.


Question #2

You’ve opened Vim and started typing, but instead of text appearing, the screen is doing strange things. What happened and how do you fix it?

Show Solution

You’re in Normal mode, where keystrokes are interpreted as commands, not text.

To fix:

  1. Press Esc to ensure you’re in Normal mode
  2. Press u repeatedly to undo any unintended changes
  3. Press i to enter Insert mode
  4. Now you can type text normally

Question #3

How do you exit Vim without saving your changes? How do you exit while saving?

Show Solution

Exit without saving:

  • :q! (quit and discard changes)
  • ZQ (Normal mode shortcut)

Exit with saving:

  • :wq (write and quit)
  • :x (write if modified, then quit)
  • ZZ (Normal mode shortcut)

Question #4

What do the keys h, j, k, and l do in Normal mode? Why are these keys used instead of arrow keys?

Show Solution

In Normal mode:

  • h - Move left
  • j - Move down
  • k - Move up
  • l - Move right

These keys are used because:

  1. They keep your fingers on the home row of the keyboard
  2. Historical reason: The original vi was created on a keyboard where these keys had arrow symbols
  3. Efficiency: No need to move your hand to the arrow keys

Tip: Remember j points down (like a fishhook).


Question #5

You made several edits to a file and realize they were all wrong. What command undoes changes? What if you undo too much?

Show Solution

Undo: Press u in Normal mode. Each press undoes one change. You can press multiple times to undo multiple changes.

Redo (undo the undo): Press Ctrl-r in Normal mode. This “redoes” changes you’ve undone.

Alternative: If you haven’t saved, you can also use :q! to quit without saving and reopen the file to start fresh.


Question #6

Describe three different ways to enter Insert mode from Normal mode, and explain when you might use each.

Show Solution
  1. i (insert): Enter Insert mode before the cursor

    • Use when: You want to insert text at the current cursor position
  2. a (append): Enter Insert mode after the cursor

    • Use when: You want to add text immediately after the current character
  3. o (open): Open a new line below and enter Insert mode

    • Use when: You want to start typing on a new line

Other options include:

  • I: Insert at the beginning of the line
  • A: Append at the end of the line
  • O: Open a new line above

Question #7

What happens if you try to quit Vim with :q when you have unsaved changes? What are your options?

Show Solution

Vim will display an error:

E37: No write since last change (add ! to override)

Your options are:

  1. :w then :q - Save the changes, then quit
  2. :wq - Save and quit in one command
  3. :q! - Quit without saving, discarding all changes

The ! after :q forces Vim to quit despite unsaved changes.


Question #8

What is the command to delete the entire current line in Normal mode? What about deleting just the character under the cursor?

Show Solution
  • dd - Delete the entire current line
  • x - Delete the character under the cursor

Both commands can be undone with u.

Note: dd is actually the delete operator d applied twice, which Vim interprets as “delete the current line.”


What’s Next?#

In Chapter 1, we’ll dive deeper into Vim’s modes, understanding:

You now have the survival skills to edit files in Vim without getting stuck. The next step is building efficiency and fluency with Vim’s command language.