nerdexam
Linux_Foundation

LFCS · Question #810

Which of the following sequences in the vi editor saves the opened document and exits the editor? (Choose TWO correct answers.)

The correct answer is A. esc ZZ D. esc :wq! This question tests common key sequences used in the vi editor to save changes and then quit the application.

Submitted by katya_ua· Apr 18, 2026Essential Commands

Question

Which of the following sequences in the vi editor saves the opened document and exits the editor? (Choose TWO correct answers.)

Options

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

How the community answered

(15 responses)
  • A
    87% (13)
  • B
    7% (1)
  • C
    7% (1)

Why each option

This question tests common key sequences used in the `vi` editor to save changes and then quit the application.

Aesc ZZCorrect

From `vi`'s normal mode, typing `ZZ` (capital Z twice) is a common shortcut command that saves any changes made to the file and then exits the editor.

Bctrl :w!

`ctrl :w!` is incorrect; entering command-line mode is done with Esc then `:`, not Ctrl.

Cesc zz

`esc zz` (lowercase z twice) is not a standard `vi` command for saving and exiting; the command is `ZZ` (uppercase).

Desc :wq!Correct

From `vi`'s normal mode, typing `:` enters command-line mode. The `wq!` command then writes (saves) the file, quits the editor, and the `!` forces the action even if the file is read-only (permissions permitting).

Ectrl XX

`ctrl XX` is not a standard `vi` command for saving and exiting the editor.

Concept tested: vi editor save and quit commands

Source: https://www.freebsd.org/cgi/man.cgi?query=vi&sektion=1

Topics

#vi editor#Text editing#Saving files#Exiting editor

Community Discussion

No community discussion yet for this question.

Full LFCS Practice