In this blog post, we will introduce the amazing efficiency and features of Vim, the king of text editors, and why it is called a “super notepad.”
Vim is a text editor that belongs to the same type as the Windows Notepad that people are getting used to. Vim’s text editing efficiency is so high that it can be called a “super notepad.” Vim is mainly used for editing computer program codes, and it is also widely used for editing other texts such as general documents and data files. If you edit a lot of text, it would be a shame not to try Vim.
Compared to Notepad, the biggest advantage of Vim is that you can easily and quickly complete all complex editing tasks without having to leave the middle section of the keyboard while editing text. When editing text with Notepad, you have to type in the middle section of the keyboard, move the cursor in the direction key section, and perform complex tasks such as copy-and-paste with the mouse. Moving the right hand between the center of the keyboard, the arrow keys, and the mouse like this wastes a lot of time and destroys the continuity of the work, which is unpleasant. However, with Vim, all complex editing tasks can be completed using only the middle section of the keyboard.
For example, to move the cursor, you usually use the arrow keys or a mouse, but in Vim, pressing “j” (or “k”) moves the cursor down (or up), and pressing “h” (or “l”) moves the cursor left (or right). By moving the cursor with the four keys “h”, “j”, “k”, and “l” located just below the right hand, you can completely avoid the inconvenience of touching the direction keys with your hand. In addition, you can move the cursor to the next word by pressing “w” and to the previous word by pressing “b”. Similarly, the cursor can be moved to the next or previous paragraph, the first or last character in a line, the top or bottom of the screen, or any other position in an instant, without the need for a mouse and with both hands always focused on the center area of the keyboard.
Then, the question naturally arises. If “h”, “j”, “k”, and “l” act as the direction keys, how can you enter the four characters “h”, “j”, “k”, and “l”? The answer is “mode.” Vim has roughly two modes: normal mode and insert mode. In normal mode, all keys become “function keys,” and among them, “h,” “j,” “k,” and “l” act as directional keys. In insert mode, you can type as you would normally type in a notepad, so “h,” “j,” “k,” and “l” type the corresponding characters. To switch from insert mode to normal mode, press Esc. There are various ways to switch from normal mode to insert mode, the simplest of which is to press “i”. When editing with Vim, you will frequently switch between the two modes.
Normal mode is not just for moving the cursor. When you enter Normal mode, you can cut, copy, and paste much more efficiently than with Notepad. To cut or copy with Notepad, you must first select the target text with the mouse and then press “ctrl+x” or “ctrl+c” on the keyboard. No matter how fast your hands are, this destroys the relevance of the work. However, Vim allows you to complete this task smoothly in an instant. To cut a word, press “dw”, to duplicate two words, press “2yw”, to cut a line, press “dd”, to duplicate a paragraph, press “y{”, to cut characters in parentheses, press “di(”, and to duplicate brackets and the characters within them, press “ya[”. Pressing “v” will enter visual mode, and as in normal mode, you can move the cursor with the keys “h,” “j,” “k,” and “l” to quickly select a character in a region, and then press “d” or “y” to cut or duplicate the selected character.
Here is a comprehensive example. The given text is “The quick brown fox jumps through the lazy dog,” and the goal is to correct the typo “bronw” to “brown” and change “through” to “over.” The current cursor position is after the “g” in “dog.” To complete this goal with a notepad, the right hand leaves the keyboard and grabs the mouse, clicks exactly between the “n” and “w” of “bronw,” the right hand returns to the keyboard and presses backspace, the right arrow key is pressed to move the cursor behind the “w,” and the “n” After entering, you must hold down the mouse and double-click “through” to select it, then return to the keyboard and type “over.” No matter how fast your hands are, it takes a few seconds and the process is tedious, making it easy to make mistakes. To complete the same task in Vim, type “Fnxpftcwover” in normal mode and you’re done. It takes less than a second for an experienced person. It would take a long time to explain in detail the meaning of “Fnxpftcwover”, but in a nutshell, Vim’s efficiency is superior to that of a regular notepad by an impressive margin.
Vim itself can only edit text files, but you can install Vim plugins in many popular software such as MS Word and Chrome. By installing Vim plugins, you can edit text efficiently by switching modes like Vim in these software.
Vim has many more features than described in this article, and it usually takes several months to learn and become familiar with most of Vim’s features. The only drawback of Vim is that it requires study and training. However, once you become proficient with Vim, you will be completely hooked from that moment on, and you will no longer be able to go back to a regular text editor.