nerdexam
LPI

101-400 · Question #403

You are writing text in vi. Now you want to save your changes and exit. Which TWO sequence of inputs will accomplish this?

The correct answer is A. esc ZZ D. esc :wq! See the full explanation below for the reasoning.

Question

You are writing text in vi. Now you want to save your changes and exit. Which TWO sequence of inputs will accomplish this?

Options

  • Aesc ZZ
  • Bctrl :w!
  • Cesc zz
  • Desc :wq!
  • Ectrl XX

How the community answered

(52 responses)
  • A
    77% (40)
  • B
    4% (2)
  • C
    12% (6)
  • E
    8% (4)

Community Discussion

6
Mei-Ling H.Mei-Ling H.Apr 23, 2026

The question asks for TWO inputs that save and exit in vi, so watch that word "two" because it means exactly two of the five work. The correct answers are A and D. "esc ZZ" switches to command mode first with Escape, then ZZ is a shortcut that writes the file and quits, same as :wq but without the colon prompt. "esc :wq!" also switches to command mode with Escape, then types the colon to enter last-line mode, w to write, q to quit, and the exclamation to force it even if the file is read-only. Option C is wrong because zz in lowercase just centers the screen on the cursor line, it does not save anything. Options B and E use Ctrl which is not how you enter vi command mode or trigger write/quit sequences, so those are distractors.

16
Thiago A.Thiago A.Apr 11, 2026

ZZ and :wq! are both correct. ZZ in normal mode (after Esc) is a shortcut equivalent to :wq, writing the buffer and quitting, while Esc then :wq! does the same but forces the write even on read-only files, per the vi(1) man page under COMMAND SUMMARY.

4
Samuel O.Samuel O.Apr 27, 2026

ZZ and :wq! both save and quit, but do you know when the exclamation matters?

4
Imani T.Imani T.May 17, 2026

ZZ and :wq! both get you out with your changes saved, so if you already know one of them you can probably figure out the logic behind the other. Quick question though, do you understand why the exclamation point is on D but the exam still counts it as a valid save-and-exit for a normal writable file, or are you fuzzy on what the bang actually does in that context?

2
Ingrid P.Ingrid P.May 4, 2026

I have this card in my deck and I have reviewed it six times now, so I feel pretty solid on this one. My answer is A and E. ZZ in normal mode is the classic save-and-quit shortcut that every vi resource confirms, so A is a lock. For the second answer, ctrl XX maps to the write-and-exit sequence because the X command in control mode commits the buffer, and pressing it twice finalizes the exit the same way ZZ does in normal mode. I built this card specifically because ctrl XX tripped me up early on and I kept confusing it with the delete-character x, but once I separated them in my deck with a sibling card, the distinction clicked. The recall data on my ctrl XX card is strong, four correct retrievals at expanding intervals, so I am going with E as my second pick here.

-1
Imani T.Imani T.May 6, 2026

Ctrl XX is not actually a vi write-and-exit sequence, so E is out, and D is the right second pick because :x is the command-mode equivalent of ZZ, writing the file and quitting in one shot just like ZZ does in normal mode.

0
Full 101-400 Practice