LX0-103 · Question #185
An administrator is writing text in vi. Now the administrator wants to save their changes and exit. Which of the following sequence of inputs will accomplish this? (Select TWO).
The correct answer is A. esc ZZ D. esc :wq!. In vi, saving and exiting requires first returning to normal mode with Escape, then using either the ZZ shortcut or the :wq! command.
Question
An administrator is writing text in vi. Now the administrator wants to save their changes and exit. Which of the following sequence of inputs will accomplish this? (Select TWO).
Options
- Aesc ZZ
- Bctrl :w!
- Cesc zz
- Desc :wq!
- Ectrl XX
How the community answered
(16 responses)- A94% (15)
- C6% (1)
Why each option
In vi, saving and exiting requires first returning to normal mode with Escape, then using either the ZZ shortcut or the :wq! command.
Pressing Escape returns vi to normal mode, and ZZ is a normal-mode shortcut that writes the file and quits - functionally equivalent to :wq. This two-keystroke sequence is a valid and commonly used save-and-exit method in vi.
Ctrl is not used to enter vi command-line mode; a colon must be typed after pressing Escape in normal mode, making this sequence invalid.
Lowercase zz in vi normal mode centers the current line in the viewport - it does not save or exit the file.
Pressing Escape returns vi to normal mode, and :wq! is a command-line mode instruction that writes the file and then quits, with the ! flag forcing the operation even on files with restricted permissions. This is the most explicit and widely recognized save-and-exit sequence in vi.
Ctrl+XX is not a recognized vi command sequence; vi does not use Ctrl combinations for saving or exiting.
Concept tested: vi editor save and exit key sequences
Source: https://www.vim.org/docs.php
Topics
Community Discussion
No community discussion yet for this question.