Barbarian Meets Coding
barbarianmeetscoding

WebDev, UX & a Pinch of Fantasy

7 minutes readwizardsusevim

Wizards Use Vim: Tips For Learning Vim

Beasts slain, editors installed, here are more practical tips to help you along The Path of Learning Vim, if you still have the determination to follow (which I’m sure you do because the rewards are plentiful and the glory unmeasurable):

  • Practice, Practice, Practice
  • Prepare for the Dip
  • Be in the Habit of Improving Your Vim. Feel when there’s pain in your workflow and adapt
  • Learn to use and rely on Vim’s help
  • If you haven’t done this already try vimtutor at least once

Deliberate Practice

Most of the rewards with Vim come when the commands become part of your muscle memory. In order for that to happen, you are going to need to practice a lot.

The best way to practice is to isolate the stuff you’re actively practicing and focus on improving that one tiny bit at a time.

So, pick one thing and focus on practicing that until you feel comfortable with it. For instance, for the space of a week you can focus on deliberately using the search command /{pattern} to move your cursor to a position in the source code instead of using the mouse or less efficient methods like hjkl.

Prepare for the Dip

The struggle is real. The dip is real. Everytime we adopt a new tool, a new framework, learn a new skill, there’s gonna be that period of time in which our productivity is going to drop and we’re going to suck. No one can be consistently awesome at something for the first time. The question is: Do you have the patience and grit to push through the other side, beyond the dip, where skill, productivity and mastery await?

You probably recognize this pattern. You find out about a new thing. You are full of excitement and enthusiasm and you hungrily start trying it out and learning about it. After a while, the excitement fades, the enthusiasm disappears and, all of the sudden, you find yourself procrastrinating and finding excuses not to do it any more. That’s the dip right there.

Vim is no different from any other skill that you’ve learned in the past and you most surely will encounter the dip.

So will you quit or will you push through? You are the only one who can make this decision. Is it worthy to you? Envision yourself empowered by that new tool, that new skill. Now, is it worthy?

If it is not, then better to quit right away, before you have wasted more time. If it is worthy, then roll up your sleeves and let’s kick some ass.

Creating a Habit of Improving Vim

Mindfulness pays off with Vim. Whenever you start feeling pain when doing something within Vim (or even outside of Vim), think whether there’s a better way. Can you do what you’re doing more efficiently? Can you create some commands or mappings to make it faster?

An important part of cultivating this habit is making updating your vim configuration (commonly refered to as your vimrc by habitual vimmers) as frictionless as possible. That way, once you find yourself repeating something way too often, you can quickly dive into your configuration and add that new mapping that’ll make your life that much easier.

Later in the book you’ll discover how to customize Vim, and the first thing you’ll learn is how to update your vim configuration with just a few swift keystrokes.

Learning To Use Vim’s Help

Vim’s help is truly amazing. Type :h {keyword} and vim will do its best to fulfill your wishes and find the help you need. The {keyword} itself can be a command, a key combination or just an action that you want to learn more about:

  • Want to know how the :global command works? Then try :h :global.
  • Want to know what the daw key combo does? Test :h daw.
  • Want to know about motions in vim? Then try :h motions.
  • Want to learn how to quit vim? Yes. You guessed it. Go :h quit
  • Want to learn what CTRL-W does in insert mode? Try :h i_CTRL-W

Vim’s help is great for precision lightning attacks of curiosity and/or need, like the ones above, but it is also great to peruse and read like a book. Type :h or :help and you’ll be taken to the help’s index which starts with help… about :help:

A Screenshot of Vim's help

This help document contains a couple of nice tricks that will help you navigate Vim’s help faster:

  • <C-]> to follow a link (they’re highlighted)
  • <C-O> to go back
  • Use /{pattern} to search within a document. (That’s how you normally search for things in Vim by the way.)
  • The help appears in a normal split window so when you’re done with it you can just close it with the :quit command just like any other window

Right below you have the user and reference manuals. The user manual is essentially a book on how to use Vim, from novice to expert with topics ranging from how to move around in Vim to how to create your own syntax highlighters. The reference manual is an in-depth reference of everything Vim.

One thing that is really cool is that Vim’s third party plugins also appear in the help. Just installed a popular plugin and don’t quite know how it works? Then try :h {nameOfPlugin}. If you’re not sure about the name of the plugin’s docs, check at the bottom of :help where third party plugins appear listed:

A Screenshot of Vim's help showing help files for installed plugins

A small warning here: With Vim plugins you’ll often find that the help you can find inside Vim is far superior to whatever you can find outside (like searching the web). So it is very important to get into the habit of using help, even for plugins, specially for plugins.

Exercise Apprentice of Vim!

Let’s do some exercises to coalesce what you’ve learned in this chapter. First, if you haven’t done it yet, I’ll have to insist:

  1. Run the vimtutor. If you chose Neovim type :Tutor. If you ignored my recommendations and opted for Vim type vimtutor in your terminal.

Then, start exploring The Oracle of Vimness:

  1. Use Vim’s help. Open Vim and type :help. Read the super brief help about Vim’s help. Then try to find the introduction to the user manual and open that page.
  2. Use Vim’s help to find more about vim-tutor-mode. (Hint: :h vim-tutor-mode)
  3. Use Vim’s help to find more about :checkhealth. (Hint: :h health)
  4. Use Vim’s help to find the skim over the differences between Vim and Neovim. (Hint: :h vim_diff)

Or mvim for the Mac GUI, gvim for the Windows and UNIX GUI, nvim for Neovim

The .vimrc is the file where you put your vim configuration. Don’t be impatient! You’ll learn more about this later in the book.

Your mileage may vary here, I work as a front-end developer and UX designer, I really, really care about aesthetics and the goodies of modern editors so for me this was a big deal. If you have a different background it may not be that of a big deal to you.

Would you Like To Learn More and Edit Text Like a Wizard? Get the Book!

This is a weird programming book. On one hand it is a awesome book on the superb vim text editor. On the other a spell book of sorts set in a world of fantasy where some people can wield JavaScript to affect the world around them. To essentially program the world and bend it to their will.

Welcome to the world of JavaScript-mancy, may you enjoy your stay, learn and have a lot of fun.

Draft 3 Wizards Use Vim Cover

Jaime González García

Written by Jaime González García , dad, husband, software engineer, ux designer, amateur pixel artist, tinkerer and master of the arcane arts. You can also find him on Twitter jabbering about random stuff.Jaime González García