Snippets of Vim (Part 1 — Modes)

This is part 1 of my learning series of posts on Vim. In a previous post, I introduced what Vim is and why you should use it.

As someone who’s still learning to use Vim regularly, I’ve found that the best way to learn is to do so in digestible chunks that are short, concise, and practical. So my goal with this blog is to publish a series of posts that will help Vim users learn more about Vim by introducing them to new concepts, shortcuts, and ways to become more efficient. To start things off, I’ll cover an aspect of Vim that makes it different — Vim is a “modal” text editor.

What the heck does that mean? And if Vim is a modal text editor, what are the other text editors?

Other text editors normally fall into a category called “mode-less” editors, which simply means that there’s only one mode when using the editor and that’s the mode where you just type text. For many of you, you’re probably thinking — “wait isn’t that all text editors?” Well yea, most of us are familiar with Notepad, Sublime, TextMate, Atom, or other text editors where you open the application, create a new file, and then start typing away. And these are mode-less editors.

However, Vim (and maybe some other text editors I don’t know about) falls into a category called “modal” editors, which simply means that there are different modes in which the editor can be in, and depending on which mode its in, you can do different things. Without overcomplicating things, I will say that for most Vim users, they’ll probably be in 1 of these 3 modes 99% of the time:

Normal Mode

This is the default mode you’ll be placed in when you open Vim. This is also the mode where you’ll execute the vast majority of your keyboard shortcuts, and as a best practice, this should be the mode that you switch back to after finishing up what you have to do in the other Vim modes.

To get from normal mode to insert mode, just press “i” from normal mode.

You’ll know you’re in Insert mode when you see it on the bottom left corner!

To get from normal mode to visual mode, just press “v” from normal mode.

The bottom left corner will tell you what mode you’re in!

Insert Mode

This is the mode you’re probably most familiar with if you’re coming from most other text editors. When you’re in this mode, you’ll just type or “insert” text. That’s it!

Once you’re in insert mode, you’ll want to get back to normal mode after you finish typing. To get from insert mode back to normal mode, just press the “esc” key or if you’re on a Mac, you can also press Control and [ at the same time (for those of you who might have re-mapped Caps Lock to Control, I find this second command easier for my fingers to reach!)

Visual Mode

If you’re used to the mode-less editors I’ve mentioned before, then this mode is analogous to when you select text in the GUI and then perform commands like copy, paste, delete, etc. Since Vim is GUI-less, when you enter visual mode, you’ll get to move around using the same motions available in normal mode and select text to perform different commands.

In the same way as insert mode, you’ll want to get back to normal mode after you’ve performed whatever commands you did in visual mode, and to do so, it’s the same as before: “esc” key or press Control and [ at the same time if you’re on a Mac.

Hopefully this post gave you more of an orientation around Vim’s different modes — I know this was confusing to me at first since I didn’t know what the distinction between each mode was. And I highly encourage you to play around in each mode. If you’re starting from a new file, open it in Vim, add some text via insert mode, and then do some text manipulation in both normal and visual mode. Vim is definitely one of those tools you have to use to learn!

Like what you read? Give Willson Mock a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.