You must switch to command mode using vim or vi to save and close the file.
vim is among the most well-known file editors on Linux. A large part of its popularity is due to vim’s command line mode. vim that allows users, particularly programmers and experts, to maximize the time spent on modifications to files.
In this post we will learn the steps to save or close a file using vim command line mode.
A file that is open in vim appears like this:
When editing the document, it’s the ‘Insert’ mode in vim that is in use and is indicated through the
-- INSERT --- text at the bottom of the terminal. In order to save the document,, we must switch to the “Command” mode in vim.
the command mode within vim, hit the
Escape key on your keyboard. When in Command mode the user is able to directly type vim commands. The bottom portion of the screen functions as a command prompt.
For saving a document using vim, enter the
the :w command and then press
As you can see that vim shows the number of characters and lines that have been ‘written in ‘, i.e., saved to disk. Similar to that,
:q is the command that is used to close the file and not save the modifications.
For saving and to close a file within vim, make use of the an command
:wqand press Enter.
key to enter. key.