Vim Incipit

I was thinking of developing a game to help build muscle memory for becoming an effective Vim user. These are my notes to help me consider the essential skills we need to practice.

One of the best ways to become more efficient using a computer is to optimize your input. Here we can divide the world into two categories: those who can touch type and those who are slow. You'll meet numerous people who have, like Django, elevated the use of 3 fingers to an art, but even they could be so much better if they unlearned their bad habits and started using all their digits.

I often wonder if people who learned to touch type are also the ones who gravitate towards text-based interfaces, preferring the command line, i3 window managers, and vi-style editors.

Let's begin with the postulate that touch typing is the most effective way to optimize interaction with a computer. Unlearning bad habits may be challenging, but ad astra per aspera.

Normal Mode

Your first time using Vim will be unusual. When you start, you begin in something called normal mode. This is probably not what you were expecting. Here, you can navigate your text and perform several actions, but only if you know the right language. Here are some things you can do in normal mode.

  • dd delete the current line
  • u undo the last action
  • Ctrl+r redo the last undone action
  • y yank (copy) the current line
  • p paste the yanked content after the current line

If you've been pressing buttons, you may find yourself in some other mode, and things will get weirder. Press the Esc key to your heart's content; this will usually bring you back to normal mode.

Insert Mode

Let's be honest: if you're reading this and you found yourself in Vim, you were probably pretty desperate to change a file, and so far, you've not gotten what you want. Chances are you're expecting behavior more akin to what you'd find in insert mode. To edit text in Vim, you need to enter insert mode. But first, to exit insert mode, you can press the Esc key and return to normal mode. Entering insert mode:

  • i for insert, you'll see this kind of thing a lot. By the way, you will start inserting text before the current position of the cursor.
  • a insert text after the current cursor position.
  • o open a new line under the cursor and get ready to wow your audience with your prose.

Command Mode

To enter command mode, press : while in normal mode. Again, if in doubt, hit the Esc key a few times, just to make sure you're in normal mode before you start. Typing : will display a command prompt at the bottom of the screen. Type your command and press Enter to execute it. Some useful commands include:

  • :w write (save) the current file
  • :q quit Vim (fails if there are unsaved changes)
  • :q! quit Vim without saving changes
  • :wq or x write (save) and quit
  • :e filename edit a file or rather open a file to edit

To run an external shell command without leaving Vim, try this:


This will execute the "command" in the shell and display its output.


Finally, it's time to tell you to stop picking up your hands to reach for the mouse or that lesser evil, the arrow keys! Here are some keys that you need to get into the habit of using:

  • j down
  • k up
  • h left
  • l right, because obviously 'l' is the intuitive choice for moving to the right, right?
  • w move forward one word
  • b move backward one word
  • 0 go to the beginning of the line
  • $ go to the end of the line
  • G go to the last line of the file
  • gg go to the first line of the file

Visual Mode