Mint

How to Save and Quit File in Vim?

How_to_Save_and_Quit_File_in_Vim_

Introduction:

The Vim text editor provides extremely good functionalities when it comes to creating and editing files. All you need to understand is its different modes after which you will be able to use this text editor quite effectively. In this article, we will be talking about the method of saving and quitting a file in the Vim text editor while using a Linux Mint 20.3 system.

Method of Saving and Quitting a File in the Vim Text Editor on Linux Mint 20.3:

For saving and quitting a file simultaneously in the Vim text editor on a Linux Mint 20.3 system, you will have to proceed as explained in the following steps:

Step # 1: Coming out of the Insert Mode of the Vim Text Editor:

Whenever you create and edit a file in the Vim text editor, you are always doing that in the Insert mode as shown in the image below:

Therefore, you first need to come out of the Insert mode by pressing the “Esc” key of your keyboard. As soon as you will press this key, you will instantly come out of the Insert mode as shown in the following image:

Step # 2: Executing the Relevant Command for Saving and Quitting a File in the Vim Text Editor:

Now, for saving and quitting a file simultaneously in the Vim text editor, you will have to type in the command shown below and then press the Enter key:

:wq

As soon as you will do this, your desired file will be saved and you will also exit the Vim editor and return to your Linux Mint 20.3 terminal. For confirming if the changes have been saved to your file or not, you can open it again with the Vim text editor. The sample file that we have used to demonstrate this method is shown in the following image after being reopened with the Vim text editor. From here, you can confirm that our changes have been saved successfully before quitting from the Vim text editor.

Conclusion:

By following the method explained above, you can simultaneously save and quite a file in the Vim text editor while using a Linux Mint 20.3 system. In this way, you will be able to save your time that would have been consumed if you would have saved your file first and then quitted from the Vim text editor.

Similar Posts