

The difference here is that :wq will save the file no matter if you made changes to it or not. According to :h :x, it is "like :wq, but write only when changes have been made". :x is another command that works almost the same as :wq. You can find this in the Documentation under :h :wq. In this case, we'd need to use :wq, which means "write and quit".

It does mention, though, that this command will fail "when changes have been made and Vim refuses to abandon the current buffer" (if you still remember, buffer is just opened file(s), nothing fancy). That being said, we can also quit Vim by executing :q. You may also notice the :q there, which is actually the shorthand version of the :quit command. Now that we are in Command-line Mode, just type in quit and press Enter or return. In order to enter Command-line Mode, first we need to make sure we are in Normal Mode, then simply type in. This means that quit is used within Command-line Mode. If you take a look at the documentation of :h quit, note that the quit is prefixed with. Similarly, press ESC if you'd like to switch back to Normal Mode.įind it in the Documentation: :h Command-line, :h cmdline-lines. For example, if you run the commands above to see the documentation, you are actually using the Command-line Mode as soon as you type in. You can enter Command-line Mode by typing : in Normal Mode. Also note that the "Ex command" in Command-line Mode is different from the "command" in Normal Mode. Both vi and ex were developed by Bill Joy.Īnother fun fact for macOS users: there is only Vim on macOS and the command vi is symlinked to vim. And vi is based on a line editor named ex. What is command-line mode in Vim?Ĭommand-line Mode is normally a "short-lived" mode, which you use to run "Ex commands" (not to be confused with the "commands" in Normal Mode).įun fact: Vim is actually a contraction of Vi Improved and it is based on another text editor named vi. There are actually many other ways to enter Insert Mode as well, like o, O, a, A, I, and so on.įind it in the Documentation: :h Insert, :h i_, :h o, :h O, :h a, :h A, :h I. The most common way to make this switch is by pressing i in Normal mode after navigating the cursor to the place that we are going to edit. If we need to make changes to the current file, first we need to switch to Insert Mode. By default, we are in the Normal Mode right after we open a file. You use Insert Mode to edit the current file (in Vim, this is normally referred to as buffer). Even if you are already in Normal Mode, pressing ESC will keep you in Normal Mode, so no worries.įind it in the Documentation: :h Normal, :h mode-switching. And the most canonical way of entering Normal Mode is by pressing ESC. Say, if we want to read the documentation of vim-modes, then we have to first make sure we are in Normal Mode before typing in :h vim-modes. Normal Mode is crucial since it's only in Normal Mode that we can run commands (there are exceptions but those are beyond the scope of this article). But there are three modes that we need to be aware of: Normal Mode, Insert Mode, and Command-line Mode. You may run :h vim-modes inside Vim to read the documentation if you would like to know more.įortunately, we don't have to know all of them in order to get started. There are seven BASIC modes in Vim and seven additional modes that are considered variants of the BASIC modes. If you want to understand in more detail how this works, let's dive in. If you made some changes and would rather discard them, type :q! and press Enter/ return.If you made some changes and would like to keep them, type :wq and press Enter/ return.If you didn't make any changes, type :q and press Enter/ return.The next step depends on the current status and your expectations:.Make sure you are using the English input method.To do that, first we need to press ESC a few times, and run the command provided, for example, :h vim-modes, and press Enter. I will also include the command that you can use to reveal the corresponding help documentation.
#Controller editor not saving changes how to#
In this article, we'll cover some fundamental topics like how to exit Vim, rather than quitting Vim. I know that Vim can be challenging to work in for people who are not familiar with it. For all the IDEs/editors that I have used, the Vim plugin is always the very first plugin that I install. I've been using Vim since the first year I started coding.
