We’re going to look at some unique features that an almost 30–year–old editor provides us. Vim is an improvement of the vi text editor that was released in 1976, which was itself an improvement of the Ex line editor! Vim is the fifth most popular development environment, according to a 2019 Stackoverflow survey.
Curious to know what it feels like to work with Vim? I think this tweet describes it well:
Let’s explore the reasons behind its popularity.
Text Objects:
These are like magic; it’s like talking to your editor in human language and watching as it obeys your orders, for example:
- Delete a paragraph -> dap
- Change a paragraph -> cap
- Visually select a paragraph -> vap
Or
- Delete inside parentheses -> di(
- Change inside parentheses -> ci(
- Visually select inside parentheses -> vi(
You can use these letters as the indicator of your objects:
- w -> word
- W -> case insensitive word
- s -> sentence
- p -> Paragraph
- t -> tag
- { –> brace
- ( –> parentheses
- [ -> bracket
- ‘ -> single quote
- ” -> double quote
Test them, and they’ll blow your mind. To learn more, read this blog post or watch this wonderful video.
Modal editing:
You have to explicitly switch between modes like Insert mode, Visual mode, Command mode and Search mode with modal editing. This gives us better opportunities to work with our editor, by creating an efficient and robust workflow, without even touching the mouse.
If you learn Vim keybindings and modes, the knowledge gained is applicable in other programs, such as:
Highly available and customisable:
Last but not least is the impressive ability to work with vim on remote machines. Imagine you are ssh-ing into a server; most of the servers have vim preinstalled – if you know how to work with it, you can release the Kraken without installing anything else!
It’s highly customisable, with the ability to install tons of plugins, you can work however you prefer. Check out some examples like SpaceVim, or famous vim plugin developer GitHub pages, like tpope.
Hopefully, this article has persuaded you to try Vim out and see the old dragon’s power for yourself.
Author
This article was written by Farid Ahmadian, a Systems Engineer at Bonial.