vim

What are the VIM Survival Commands that you need to Operate it?

Whenever you are learning to use a new utility in any operating system, there are some basic hacks that you must learn to operate that utility successfully. These hacks will not necessarily make you a pro of that utility; however, they will ensure that you never get stuck while performing the basic functions in that utility. In the Linux operating system, most of the functions are performed through commands since it provides you with a command-line interface (CLI). VIM text editor also has a hand full of beneficial commands that you must learn to use it well. Therefore, in this article, we will share with you some survival commands that you need to operate the VIM text editor in Ubuntu 20.04.

VIM Survival Commands that you need to Operate it in Ubuntu 20.04:

The survival commands that you need to operate the VIM text editor in Ubuntu 20.04 are discussed below:

Command # 1:

VIM text editor has multiple different modes of operation. However, the most common out of these modes is the Normal mode and the Insert mode. If you ever feel the need for toggling between these two modes, then all you have to do is to press the Esc key. By default, the VIM text editor is in the Normal mode. Pressing the Esc key for once will take you to the Insert mode where you can edit files, whereas pressing the Esc key again will take you back to the Normal mode.

Command # 2:

If you are a naïve user of VIM text editor, then you may make mistakes while editing your files and then get worried about how to revert the changes that you have accidentally made. However, VIM provides you with a very powerful command for undoing what you have unintentionally changed. All you have to do is to switch to the Normal mode and then press u key. Doing this will undo the recently made changes.

Command # 3:

Now when you have edited your file completely and want to quit from VIM text editor after saving this file, then you will need to switch to the Command mode or Cmdline mode. For doing that, first, you need to be in the Normal mode. Then type a colon to get into the Cmdline mode. Now type wq followed by the colon and press the Enter key to save your newly created file and for exiting from the VIM text editor. This command is also shown in the following image:

Command # 4:

If you have created a very long text file or you are reading a long text file, then you might need to toggle up and down every now and then. For going half page up, all you have to do is to press Ctrl+ u. Typing this key combination will immediately take you to half page up.

Command # 5:

Similarly, for going half page down, all you have to do is to press Ctrl+ d. Typing this key combination will instantly take you to half page down.

Command # 6:

The last survival command that we will talk about is the search command, with the help of which you can easily find something that is written in your file. All you have to do is to press the Forward Slash “/” key. Tap on this key, then type whatever you want and then press the Enter key to find the desired results. If there is more than one result, then you might feel the need to check them all. Press the n key for going to the next search result, whereas if you want to go back to the previous search result, you can press the N key. For demonstrating this command, I had a dummy text file in which I wanted to search for the alphabet “k”. Therefore, I typed “/” followed by the alphabet “k”. The search results of this query are shown in the image below:

Conclusion:

In this article, we talked about a few very basic commands that are also referred to as VIM survival commands because whatever you want to do with the VIM text editor, you must know these basic commands for operating it properly. This is not an exhaustive guide; therefore, we did not intend to bombard the reader with tons of different commands. The commands discussed in this article are particularly meant for the people who are new to this text editor.

About the author

Karim Buzdar

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.