LFCS · Question #785
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! To save changes and exit in the vi editor, an administrator can use either the esc ZZ shortcut or the command-line mode sequence esc :wq!.
Question
Options
- Aesc ZZ
- Bctrl :w!
- Cesc zz
- Desc :wq!
- Ectrl XX
How the community answered
(16 responses)- A94% (15)
- C6% (1)
Why each option
To save changes and exit in the vi editor, an administrator can use either the `esc ZZ` shortcut or the command-line mode sequence `esc :wq!`.
The `esc ZZ` sequence is a quick command in vi that saves any changes made to the file and then quits the editor.
`ctrl :w!` is incorrect because the colon (`:`) command is initiated after pressing `esc`, not `ctrl`.
`esc zz` is not a standard vi command for saving and exiting; the correct sequence uses uppercase 'Z' (`ZZ`).
The `esc :wq!` command switches to vi's command-line mode, then writes (saves) the file forcefully (`w!`) and quits (`q`), successfully saving changes and exiting.
`ctrl XX` is not a recognized vi command for saving and exiting the editor.
Concept tested: vi editor save and exit commands
Source: https://man7.org/linux/man-pages/man1/vi.1.html
Topics
Community Discussion
No community discussion yet for this question.