62.0k views
3 votes
What is the command to save a file in the vi/vim editor?

:w
:q
:s
:set nu

User Danielrozo
by
7.6k points

1 Answer

5 votes

Final answer:

To save a file in the vi/vim editor, the command is :w. This writes the current file to disk without exiting the editor. Other commands like :q for quitting and :set nu for line numbers are not for saving changes.

Step-by-step explanation:

The command to save a file in the vi/vim editor is :w. This command writes the current file to disk, allowing you to continue editing the file. If you want to save the changes and exit the editor, you can use the command :wq or :x, which saves and closes the file. The command :q is used to quit the editor, and it will warn you if there are unsaved changes.

The command :s is for substituting text within the file, it is not related to saving. Finally, :set nu is used to display line numbers in the editor and does not save the file.

To save a file in the vi/vim editor, you would use the command :w. This command writes (saves) the changes made to the file without quitting the editor. If you want to save and quit, you can use :wq.

:w - Save changes.

:q - Quit (exit) the editor.

:wq - Save changes and quit.

:s - This is not the command for saving. It is typically used for search and replace.

:set nu - This command sets line numbering and is not directly related to saving the file.

So, in the context of saving a file, the correct command is :w.

User Corvuscorax
by
8.1k points