LFCS · Question #786
While editing a file in vi, an administrator realizes that the wrong file is being changed. Which of the following vi command sequences will allow the administrator to quit without saving any changes?
The correct answer is B. :q! To quit the vi editor without saving any changes, the administrator should use the esc :q! command sequence.
Question
Options
- A:Q!
- B:q!
- C:w!
- D:wq!
How the community answered
(38 responses)- A3% (1)
- B87% (33)
- C5% (2)
- D5% (2)
Why each option
To quit the vi editor without saving any changes, the administrator should use the `esc :q!` command sequence.
While `:Q` can be equivalent to `:q` in some vi variants, the exclamation mark `!` is crucial to force quit without saving, and `:q!` is the canonical form.
The `esc :q!` command sequence forces vi to quit without saving any modifications made to the file, which is useful when realizing the wrong file is being edited.
`:w!` saves the file forcefully but does not exit the editor.
`:wq!` saves the file and then quits the editor, which is the opposite of quitting without saving.
Concept tested: vi editor quit without saving
Source: https://man7.org/linux/man-pages/man1/vi.1.html
Topics
Community Discussion
No community discussion yet for this question.