How to Learn Vi / Vim

reading time 3 min

A coworker was amazed at my use of Vim, especially that I was able to navigate around files so quickly.

Here’s my advice:

Learn vim one command per day

Find a “vim keyboard command cheatsheet” and print it out.

Every day teach yourself the next command. Start at the top, move to the next command each day.

Use that command a few times to get used to it. Then force yourself to use it throughout the day.

Over the course of a few weeks, you’ll be a much better Vim user.

For example, I never used to use the { and } keystrokes. Yes, they go previous and next paragraph, but I figured I write code, not text, so it wouldn’t be useful.

Then those keystrokes came up on the cheatsheet so I forced myself to try it.

It turns out “paragraphs” are separated by groups blank lines. { and } are a great way to rapidly move up or down a long file.

If you can move, you can delete/change/yank

Here’s another thing. Now that you know a new way to move around a file, you’ll discover that many commands accept a “movement” option.

For example, d followed by a “movement” deletes in that direction. c changes the text (deletes it, then goes into input mode), and y yanks (copies) text in that direction.

  • You already know that h by itself moves one char to the left. dh deletes that char.
  • You already know that j by itself moves one line down. dj deletes the current and next line.

Now that you know } moves to the next blank line…

  • d} deletes from the current line to the next blank line.

Also, since 3} moves 3 paragraphs (you can use any integer), d3} deletes from the current line to the next time 3 groups of blank lines are found.

This works for other commands, such as c (change). Try cw to change the next word… technically from where the cursor is until the end of the current word)

Maybe you knew that % does a pretty cool thing when on any of (){}[] chars. What do you think c% does? (Your guess is probably right!)

How did I discover this?

True story: The summer before my senior year of college I had an internship at AT&T. I spent a lot of time in my manager’s office waiting for her to give me something to do. She had a “VI Cheat Sheet” on her cubicle wall. While I was waiting for her, I’d memorize the next command.

Ready, set, go!

Now do a search for vim cheat sheet and get started.

Tom Limoncelli

Tom Limoncelli

Recent Posts

  1. HBO’s Integration Test Email
  2. Vim n.n.n.n.n.n.
  3. Commonly misused business metaphors
  4. VMware WorkspaceONE Notifications are a crime against productivity
  5. Numberwang (all videos)




I agree that this website may store my data to personalize my journey in accordance with their Terms & conditions

Powered by Hugo | Theme - YesThatTheme © 2017 - 2021 Tom Limoncelli