The Vim editor is a popular Free and Open Source text editor. It is an improved version of the vi text editor. Vim is extremely popular among the Linux, macOS and Unix-like system users. this one has many commands that help you to edit your text files efficiently. It comes with a pretty extensive built-in manual as well.
Here we discuss mainly two topics
- How to install Vim
- Understanding modes of Vim (command modes and insert modes)
How to install Vim
- Debian and other Debian-based distros like Ubuntu, Linux Mint:
sudo apt-get install vim
sudo dnf install vim
- Arch Linux:
sudo pacman -S vim
For more details
Understanding modes of Vim (command modes and insert modes)
In the command mode, a user can move around the file, delete text, etc. In the insert mode, a user can insert text.
Changing mode from one to another:
- From command mode to insert mode type a/A/i/I/o/O
- From insert mode to command mode type Esc
Some useful commands for VIM
|Append text following current cursor position
|Append text to the end of current line
|Insert text before the current cursor position
|Insert text at the beginning of the cursor line
|Open up a new line following the current line and add text there
|Open up a new line in front of the current line and add text there
The following commands are used only in the commands mode.
Cursor Movement Commands
|Moves the cursor one character to the left
|Moves the cursor one character to the right
|Moves the cursor up one line
|Moves the cursor down one line
|nG or :n
|Cursor goes to the specified (n) line (eg. 10G goes to line 10)
|^F (CTRl F)
|One page forward
|One page backward
|Up half screenful
|Down half screenful
|Move cursor to the end of current line
More about Vim:
Vim is the editor of choice for many developers and power users. It’s a “modal” text editor based on the vi editor written by Bill Joy in the 1970s for a version of UNIX. It inherits the key bindings of vi, but also adds a great deal of functionality and extensibility that are missing from the original vi.
What do we mean by modal? When you’re using most word processors and text editors, the alphanumeric keys (i.e., a through z, 1 through 9) are only used to input those characters unless they’re modified by a control key. In Vim, the mode that the editor is in determines whether the alphanumeric keys will input those characters or move the cursor through the document.In Vim, you can save a file without your hands leaving the keyboard, and sometimes without even leaving the home keys. From Vim’s insert mode, hit Escape and then :w. That’s all. More on that later.