Why Vim

I’ve been using, teaching, and stanning Vim since almost the beginning of my programming career. Yet, when asked to explain this preference, I stumble. In this post, I’d like to explore why I love Vim. Disclaimer: I haven’t used every text editor that has ever existed! I haven’t used Emacs or some of the GUI editors that have come and gone over the years. I’m not arguing that Vim is better than any of these. In particular, VSCode in Vim mode seems to rival Vim in some ways. ...

February 23, 2022

Refining Your Terminal Aliases

Any command you type out manually, or even tab-complete a few times, can be shortened. A common shortening technique is the terminal alias. Here are some tips that help me write better aliases and cut my terminal keystrokes. Identify Alias Opportunities With the ’typeless’ Command I found this trick a long time ago from, I believe, Thoughbot’s Upcase course. I call it typeless, and it’s a well-worn alias in my .zshrc: ...

February 10, 2022

Ruby's Frozen String Literal Comment: YAGNI

Open a production Ruby file, and you’ll often see this magic comment at the top. # frozen_string_literal: true Today I’d like to argue that most Ruby files do not need this comment. YAGNI— You Aren’t Going to Need It. Why? I believe it: Is a relic of the past Doesn’t do what people think Isn’t Ruby-ish Is associated with unproven performance claims I’d like to see it deleted from the code I work on, and I don’t think we should be enforcing its presence most of the time. ...

February 9, 2022

How to Organize JavaScript Imports

The import statements at the top of a JavaScript component file can be a confusing, duplicative, churning mess. Is there a way to organize them that makes sense and scales? In this post, I’d like to share the way I handle this detail. Who Cares? Wait; who cares? Isn’t this like discussing the color of the bike shed? Years of programming with other humans has taught me that, for loosely-defined tasks like this, any convention is better than no convention. Without it, you’ll see in many, many codebases: ...

August 30, 2021

My Annotated Vim Configuration File

I love Vim. Folks who’ve programmed with me, or attended a Vim Meetup when I was an organizer, can attest. When I was learning to code, getting fast at Vim changed everything for me. After almost a decade using this editor, here are my personal configurations. My Vim Configuration My .vimrc is broken up into groups. If you open this file in Vim, you’ll see why: it’s long, and so it’s folded by groups as a default. This is one of many tips I picked up reading Learn VimScript The Hard Way by Steve Losh, and the dotfiles of programmers I admire. ...

November 26, 2020

Vim Nonrecursive Mappings

My first PR to a new Vim plugin was merged this week, check it out, adding non-recursive Vim mappings to vim-termbux. vim-termbux is a plugin by my friend Dillon Hafer that emulates the behavior of vim-turbux— sending test run output to somewhere outside of Vim– in iTerm. If you write a lot of tests in iTerm and Vim, but prefer to stay outside of Tmux for whatever reason (fingers don’t like the mappings, etc.), than this plugin is for you. ...

December 17, 2016

Keyword, Match, and Region in VimScript

After a recent talk I gave that included VimScript, an attendee asked a question about the differences between keyword, match, and region following syn in a Vim syntax highlighting file. Here’s my answer. These three short chapters from ‘Learn VimScript the Hard Way’ help explain: Chapter 45 Chapter 46 Chapter 47 Here’s the short version: keyword assigns a variable name directly to a word or multiple words match assigns a variable name to a Vim regex region assigns a variable name to something between a “start” pattern and an “end” pattern For more info, check out the Vim help pages for each: ...

April 20, 2016

Vim Buffer Problem

A few weeks back I tackled the following programming challenge from my colleague Josh Branchaud: Vim Buffer I open up a new Vim buffer and type all the numbers 1 to 10,000, separated by spaces. Then, my cat walks on the keyboard and somehow activates a substitution command that replaces all the ‘0’ digits (zeros) with spaces. If I now sum up all the numbers in the buffer, as delineated by spaces, what is the total? ...

March 6, 2016