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.
Question
Options
- Aesc ZZ
- Bctrl :w!
- Cesc zz
- Desc :wq!
- Ectrl XX
How the community answered
(15 responses)- A87% (13)
- B7% (1)
- C7% (1)
Why each option
This question tests common key sequences used in the `vi` editor to save changes and then quit the application.
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.
`ctrl :w!` is incorrect; entering command-line mode is done with Esc then `:`, not Ctrl.
`esc zz` (lowercase z twice) is not a standard `vi` command for saving and exiting; the command is `ZZ` (uppercase).
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).
`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
Community Discussion
No community discussion yet for this question.