Back in 1976, Bill Joy created
Vi for the Unix operating system. The name comes from the first two letters of Visual, which makes sense. Before Vi, people used
Ex, a line editor, which was itself an upgrade from an even older tool,
Ed, built by Ken Thompson in 1971.
Why “Visual”? Because back then, being able to edit an entire document on screen, visually, was revolutionary. Ex let you edit one line at a time, but Vi brought the whole thing into view.
Then came Vim (short for Vi Improved). In 1988,
Bram Moolenaar built Vim on top of Vi, adding better performance and more flexibility. Over time, it spread to more platforms beyond Unix. Today, you’ll find it pre-installed on most Unix-like systems, including Linux and BSD. As of this writing, the latest version is Vim 8.1.
Why is Vim So Popular?
You Never Have to Leave the Keyboard Vim’s biggest selling point? You never have to touch the mouse. Everything, from basic typing to complex text manipulation, happens through keyboard shortcuts. Once you learn them, you’ll be faster than ever. But if you don’t invest the time, this same feature can be frustrating.
It Works in the Terminal You’re SSH’d into a server on the other side of the world, say, in Germany. No graphical interface. No Sublime, no Atom. Just you, the terminal, and the text. Vim is one of the few editors that’s built for this situation. It thrives in environments where others can’t even run.
Extensibility Vim can grow with you. For every task, there’s probably a plugin that makes it easier. With some setup, Vim can outperform even IDEs like PHPStorm.
It’s Hardcore (and we love it) Let’s face it: some of us like using a tool that confuses others. There are simpler options, like
Micro, which even supports mouse input. But there’s a certain satisfaction in using something more cryptic.
Bonus Info for the Curious
Vim was the first software released under a
charityware license. This means Moolenaar asks users to donate to a charity in exchange for using Vim.
It’s also the reigning champion in the
editor wars. It’s been around longer than almost any other editor and continues to have a dedicated community of fans.
Getting Started with Vim
Vim works in three modes:
Insert Mode: This is for typing.
Command Mode: For saving, searching, and moving around.
Visual Mode: For selecting text.
You move between these modes using just a few keystrokes:
To switch from Command Mode to Insert Mode (to type), press i or a.
To get back to Command Mode from Insert or Visual Mode, press Esc.
To move around in Command Mode, use the arrow keys or, if you want to look cool, use H, J, K, and L for left, down, up, and right.
Useful Commands
Here are some basics that will get you through most situations:
View current directory: :Ex
Undo: u
Redo: Ctrl+R
Show line numbers: :set number
Search for a string: /search_term (for the next occurrence, press n; to go back, press Shift+n)
Search from cursor onward: Use ? instead of /
Replace text: :s/text1/text2/gc% (the g means all instances, and the c asks for confirmation before each replacement)
Copy/paste:
Copy selected text in Visual Mode: y
Copy a line: yy
Copy a word: yw
Paste: p
Cut: d
Cut a line: dd
Cut a word: dw
Repeat last command: . (period)
Save the file: :w filename
Save and exit: :wq
Exit without saving: :q!
Learn More
You’ve now got 90% of what you need to survive in Vim. If you want to go deeper: