At user groups and in online communities they keep talking about Vim and how cool it is to use this text editor. Let’s explore what all the Fuzz is about.
What is Vim?
Vim is a text editor that operates within the terminal and works with keyboard shortcuts only. It is known for the editing speed you can achieve and therefore increased productivity.
Why is Vim so popular?
Despite its age (at the time of writing, 28 years) it’s still popular among a lot of software developers. Vim is available on almost any operating system. It comes preinstalled on Linux Distributions and macOS, and there are packages available for Windows as well. Once you mastered the keyboard shortcuts, you can edit files very quickly.
How does Vim look like?
How can I get started with Vim?
If you’re on Linux or macOS, open a terminal and type in
vim. This will open the editor and it’s ready to open a file. On Windows, you might need to install it first.
If you have used other editors such as Notepad++, Sublime, TextMate or Visual Studio Code, Vim will seem quite obscure. In these other editors, you use keyboard shortcuts as well as the mouse to open, save and edit files.
Since Vim is keyboard-only, it comes with shortcuts for all operations (also those you’d use a mouse for otherwise).
The main difference to other editors is its two different modes. Vim has a Normal and Insert Mode.
In Normal Mode you execute commands such as open or save file but also navigating across the file.
Vim is already in Normal Mode once it opens. Some commands consist of a single letter such as
w. Others require a colon, such as
:e. (More on those commands below.)
Once in Insert Mode, every key you hit will result in a character in your file as you’re used to it in other editors.
Switching Between Modes
When you open Vim, it’s in Normal mode already. To get into Insert Mode, press
i. You will see
-- INSERT -- in the bottom left corner.
Once you’re done adding / changing characters, hit the
<ESC> key to switch back to Normal mode. You will notice, that
-- INSERT -- will disappear again.
When you edit a file, you will constantly change between both modes, with Normal as the default mode. When you navigate through a file, copy or delete characters, you do all of that in Normal Mode. Insert Mode is for character manipulation (Insert and Delete) only.
The list of Vim Commands is pretty long, but you won’t need to know all of them to get started.
In fact, only a handful commands will do in the beginning:
|Switch into Normal Mode|
|Switch into Insert Mode|
|Save file and Close Vim|
|Open a file|
These six commands will get you quite far already, allowing you to open, manipulate and save files, as well as closing Vim.
Additionally, download the Cheat Sheet below with additional commands that build on top of the foundational commands above.
It will take time to pick up speed and come back to a productivity level you’re used to. Start with the commands in the table above and focus your effort on switching between Normal and Insert Mode.
Once you’re comfortable with that, add one command at a time from the Cheat Sheet to your repertoire. You will notice over time how your muscle memory will build up. That will also be the time to install additional plugins.
Let’s get started with learning! I’m curious about your learning experience. Follow me on Twitter and share your progress with me!