SCA_SLES15 practice question 2 of 15

Which Vim command will save the current file without exiting?

Full set: 69 questions
Answer options
A: q!
B: w-no-exit
C: wq!
D: w Correct answer
E: w!
Correct Answer:
D. w
Explanation

In Vim's command-line mode (accessed by pressing : in normal mode), the w command stands for "write". Executing :w saves the changes made to the file currently being edited to the disk. This action does not cause Vim to exit, allowing the user to continue editing the file after saving. This is the standard and most direct command to save the current file without exiting the editor.

Why Incorrect

A. q! quits the editor without saving any changes made since the last write. It discards the current work.
B. w-no-exit is not a valid Vim command. The command to write is simply w.
C. wq! forcefully writes the file and then quits the editor. This command exits Vim.
E. w! forcefully writes the file, which is used to overwrite read-only files. While it saves, the ! is unnecessary for a normal save operation.

References

- SUSE Linux Enterprise Server 15 SP5 Administration Guide, Section 5.2.2. "Basic VIM Commands", Table 5.1 "VIM Command Overview" lists :w with the description "Save file." and :q with "Quit VIM."

- vimtutor interactive tutorial, Lesson 1.4: "To save the changes made to the file, type :w ". This lesson clearly separates the save (:w) and quit (:q) commands.

Scroll to Top