For starters, Vim is installed pretty much everywhere. I can’t remember ever logging into a system and not being able to use the Vim editor. Most Linux distributions install it by default. With other editors such as nano or Emacs, they may or may not be available. If you’re working on a system and your only editor choice is Vim, then you need to at least be able to use it to make simple edits.
Also, many programs rely on an external editor. By default, in most cases, that external editor is Vim. Typically this can be overridden by setting an environment variable such as EDITOR. However, if you execute one of these commands and find yourself looking at the Vim editor, you’ll be happy to at least know how to make simple edits and exit out of Vim. Just a couple of commands that rely on an external editor such as Vim include crontab, visudo, and git.
Typing speed is irrelevant up to a certain level. Your ability to navigate through code is much more important. This is where Vim along with its keybindings, layout and set up can help you speed up the process. The skills that you build while learning Vim can be used in many different editors, such as VSCode (with the Vim plugin) or Sublime Text and so on…
By default, Vim starts in normal mode. Normal mode can be accessed from other modes by pressing Esc.
Normal mode is where one should spend most of their time while using Vim because in this mode you can navigate in the text with these commands and change blocks of code with other commands.
In normal mode, there are multiple ways to move around in an open file. In addition to using the cursor keys to move around, you can use movement commands as well.
But in the normal mode you can’t insert text with the keyboard because you need to enter in the Insert Mode.
This is the second most used mode, and will be the most familiar behavior to most people. Once in insert mode, typing inserts characters just like a regular text editor. You can enter it by using an insert command from normal mode.
To leave insert mode and return to normal mode, press Esc.
Visual mode is used to make selections of text, similar to how clicking and dragging with a mouse behaves but without a mouse. Selecting text allows commands to apply only to the selection, such as copying, deleting, replacing, and so on.
In Visual Mode you can use normal mode commands to edit text and other visual mode specific commands.
Press v to enter visual mode, this will also mark a starting selection point. Move the cursor to the desired end selection point; vim will provide a visual highlight of the text selection.
Visual mode also has the following variants:
Command mode has a wide variety of commands and can do things that normal mode can't do as easily. To enter command mode type : from normal mode and then type your command which should appear at the bottom of the window. For example, to do a global find and replace type: %s/foo/bar/g to replace all foo with bar.
Replace mode allows you to replace existing text by directly typing over it. Before entering this mode, get into normal mode and put your cursor on top of the first character that you want to replace. Then press R to enter replace mode. Now whatever you type will replace the existing text. The cursor automatically moves to the next character just like in insert mode. The only difference is that every character you type will replace the existing one.
Vim allows for really awesome customization, typically stored inside a .vrmc file. Typical features for a programmer would be syntax highlighting, smart indenting and so on. In this file you can also save your macros.
This version of the .vimrc file already has basic plugins stored in it.
This version of the file .vimrc includes a ton of useful plugins, color schemes, and configurations.