Red Green Repeat Adventures of a Spec Driven Junkie

Minimum Viable vim

Continuing from a previous post about a minimum configuration for emacs, I am now configuring vim.

Vi was my first code agnostic editor. I read The Pragmatic Programmer which recommneded learning a single editor and learn it well. I chose vim and I learned it so well, I even read The vi Editor.

I do not use vim as my “workhorse” editor anymore, even though Pragmatic Programmer says to use only one editor.

Vim is good for what it’s designed to do (efficient editing), emacs is good at what it’s designed to do (powerful editing).

When to vim?

I use vim in situations where I want to quickly jump in and out of a single file. Whenever the operating system is really bare, vim is usually installed by default (whereas emacs is not.)

I also love using vim to configure system files: sudo vim /etc/nginx/nginx.conf. vim by default does not leave auto-save files (i.e. nginx.conf~) lying around as well. So I do not have to configure or clean up after the editor.

As much as I love emacs, not everyone loves emacs as much as I do. There are people that love vim as much as I love emacs. So when I work with them, having a solid working knowledge of vim is essential so both of us can be productive.

Where to find

My .vimrc file is available here.


I am so acustomed to using esc to get out of any mode in vim that I could not even imagine another key to replace it.

When Collin introduced the idea and mentioned that using jk is super fast, it piqued my interest.

Setting jk to be the escape key sequence is nicer than having esc key to be the escape key. Typing jk is quick as it uses two fingers on the same hand and the keys are right on home row. After getting used to this, I don’t like reaching for the escape key anymore.

imap jk <Esc>

The new touch bar MacBook Pros have a virtualized esc key, so this change is useful on keyboards without a physical escape key.

Syntax Highlighting

set syntax on

Looking at large files in just black and white text is just too rough for me, especially if some colour is possible. So have vim do any kind of syntax highlighting possible in the current file.


set nowrap
set smartindent
  • nowrap - don’t wrap long lines, yes, even ones greater than 80 characters. Some files are like that and I don’t want to fix everything in it.
  • smartindent - indent based on the last line, so I don’t have manually enter spaces and tabs to compensate on indented files.

Highlight Searches

set hlsearch

Case Insensitive Search

This is from Collin’s vimrc settings, with comment:

make searches case-sensitive only if they contain upper-case characters

set ignorecase smartcase

Incremental Search

Combined with the above, makes searching a file smoother.

set incsearch

Show Matching Parenthesis

This is on by default, but just in case… When selecting a parenthesis it will highlight the one matching:

set showmatch

Auto Reload Open Files

I got this from Collin’s vimrc setting, which lists: “If a file is changed outside of vim, automatically reload it without asking.”

I find this useful whenever working with files tracked by version control such as git. Just changing git branches will “alter” files on disk and vim will ask to reload before the next time saving the file, which may result in pain to resolve any branch differences.

set autoread
  • useful when working with different git branches
  • single source of truth: the disk!

Line Numbers

Show line numbers so I know where I am in the file. Vim has some great numbering methods to jump/cut/copy X lines at a time. I use those whenever a number is faster than visual mode.

set number

Window Navigation

Vim allows splitting screens horizontally and vertically via :split and :vsplit. Navigating between two windows with c-w c-w is efficient but navigating between more than threewindows with c-w {h,j,k,l} to be a bit of work.

Collin’s vimrc inspired me to remap this to make it the same as my emacs setup:

nnoremap <Esc>h <c-w>h
nnoremap <Esc>j <c-w>j
nnoremap <Esc>k <c-w>k
nnoremap <Esc>l <c-w>l


Recently, I have been adding commands I forget in the config files as they are probably the first place I look when wanting to remember a command.

  • gq - wrap selected text to 80 characters. emacs equivalent: M-q
  • zz - center window to cursor. emacs equivalent: C-l


Vim is a great editor. I really love for: efficient editing. Anytime I need to edit a single file, vim is my goto editor.

At the same time, vim’s defaults are a bit sparse for my liking so I’ve added a handful of configurations that make it useful in most situations I use vim in.