Special offer
+370 5 205 5502 sales@monovm.com

How to Save and Exit in VIM

There are many text editors you could use to edit files in Linux. Today, we will show you how to save and exit in VIM editor.

20 Jul, 21 by Antoniy Yushkevych 3 min Read

List of content you will read in this article:

Vim is one of the most reliable and powerful open-source text editors available for several operating systems. Commonly, the Vim text editor is also known as Vi. Initially, Bill Joy discovered this editor in the 1970s. At that time, Vi was short form for the visual editor

Vim is an extremely fast and efficient UNIX text editor. It is also inclusive in Linux and macOS. You can feel free to write or edit text with the help of this tool via a command-line interface or as an application. There are ample features and commands associated with Vim. Here, we are going to learn about the method to save and exit Vim.

Let’s dive in!


For starters, when you launch vim, by default, the file opens in the command mode. This tells you that you are not able to enter any new text, instead, you can edit or move the file.

If you wish to enter the text, switch on the insert mode. Press I. From now on, you are able to type any text in the file. 

Let’s move to our main segment and understand the procedure to save changes in Vim. 


To save and quit your file in Vim, follow these steps in a step by step fashion:

  • Initially, turn to the command mode. To do that, press the ESC key
  • Now, press colon. In the bottom left corner, it directs you to the prompt bar 
  • Type x and press enter. It saves and exits 

Additionally, you can also accomplish this task by using a command. Take a look:


w = write (save)

q = quit

Now, there is another method to save your file in Vim, without exiting. Let us see how!

If you want to save a file and do not wish to exit in Vim, follow these steps:

  • Press the Esc key to switch to the command mode
  • Now, type colon. It takes you to the prompt bar as shown in the snapshot below:

  • Type w and now press Enter. This helps you to make changes in the file without exiting from the text editor

Besides, you can rename the file name also. Just type in the following command:

:w [newfilename]

Here is a snapshot for you.

Moving on to the next segment, what if you wish to exit without saving the changes you make in the text editor.


Follow these steps:

  • Press the ESC key and turn on the command mode
  • Again, press colon to open the prompt bar
  • Now, type q, and press enter to exit the text editor without saving any changes. 

Take a look at the snapshot.


There are a lot of other keyboard shortcuts in Vim. These were some of them. No wonder, Vim makes life easier for the developers by its simple commands and executions.

We hope that these methods help you to understand the methods regarding saving and exiting Vim. Keep exploring, keep learning!

Antoniy Yushkevych

Master of word when it comes to technology, internet and privacy. I'm also your usual guy that always aims for the best result and takes a skateboard to work. If you need me, you will find me at the office's Counter-Strike championships on Fridays or at a.yushkevych@monovm.com