Become a Vim Chad

Take yourself from a fan to an enjoyer.

Become a Vim Chad
Image generated with DALL-E

I learned vim two years ago, and since then, I haven’t been able to imagine working without it.

Prior to using Vim, I started my programming journey using VScode. While it was useful when I first started, I moved from using the terminal on mac to using i3 on Manjaro. The terminal-heavy environment encouraged me to use a text-based editor. There were plenty of options, you have Emacs, Nano, Helix, and others; but something about Vim called to me. I remember seeing ThePrimeagen’s speed run demonstrations in Vim and being blown away by the possibilities.

Vim has so many hidden features and key combinations tucked away into it. After two years, I’m still discovering new combinations and commands. On my dev laptop, I have custom keybinds set to automatically run Go or Python code. The benefits don’t just come in the way of pure speed or efficiency. I end up fighting the editor less and work more harmoniously with it. I’m not waiting for it to start up, not bogged down by feature changes, or extensions (sort of).

Learning wasn’t easy, I would practice on vimgenius.com whenever I had the free time. I would turn on a show or a podcast and zone in. The movement was completely foreign, but it started to become more organic after a day or two. After a week of practice, I set my $EDITOR to vim and used it wherever possible.

I could cover the basics here but everyone has a “Vim for Beginners” tutorial. Rather I’ll give some useful suggestions for the amateur enthusiast looking to improve their workflow.

Navigating with strictly the hjkl keys is extremely inefficient. It’s slow and most importantly, it’s BORING.

There are much more efficient ways to move both vertically and horizontally. The fun of using Vim is opening the editor, making the changes and “:wq” in fewer keystrokes as time goes on.

INSTEAD OF:

  • holding down j
  • holding down k

TRY:

  • Shift + (
  • Shift + )

This moves you up or down by paragraph (chunk of text) rather than line by line.

INSTEAD OF:

  • holding down h
  • holding down l

DO:

  • ‘b’ to jump back one word
  • ‘w’ to jump forward a word

Text Editing

You’ll often hear that vim is almost like language. Typically following a <verb:noun> cadence. With a little more specificity, you can speed things up dramatically.

i = inside

Using ‘i’ when changing or deleting allows you to be much less strict with your cursor placement. Rather than placing your cursor directly at the beginning of the word. You can hover it anywhere as long as it’s on the word. From there just replace ‘cw’ with ‘ciw’ and watch the magick happen.

This might lead you to think that using ‘i’ is not limited to words. You may be inclined to think that you can use ‘i’ with quotes, or parentheses. Chicanery? Not in the slightest. This is a MASSIVE speed up. Think of the possibilities.

Command Evaluation

Sometimes you wish you could run a command and immediately store the output in the file you’re editing. The possibilities could be endless, dates, cal, maybe a process tree? Discovering that I could evaluate text was akin to a spiritual experience. I don’t use it everyday but I’d be lying if I said it doesn’t save me when I need it most.

A prime example is when I send an email to users using our systems, we have a script that opens up vim for us to write a message to a user (often misbehaving) on the cluster. There are times where I’ll `ps U <username> — forest` and dump a users processes into the body of the email.

How to do it? simple.

  1. Write a command string of syntactically sound bash.
  2. :.!bash

You may be inclined to assume the same can be done with any interpreted language instead of bash. Try it, you won’t be disappointed :)

I’m sure there’s an even faster way to evaluate the string than using command mode, but I haven’t discovered it yet.

Closing

Vim opens up over time, It will match your investment. The more time you give to learning it, the less resistance you will face when editing.

Stay Speedy