My Vim Configuration (2020)

Photo by Kevin Ku on Unsplash

Yup. Here’s another “here’s my Vim configuration” post. These are a dime a dozen these days, as it seems “hip” to post your Vim config. That being said, as a programmer I often find it useful to see other people’s configuration, as sometimes it gives me an idea, or I learn a new trick. So, with that spirit in mind, here is my configuration.

For my Vim configuration I use Plug to manage plugins, so if you use another plugin management system, your mileage will vary. Also, I have some keybindings specific to the programming languages I spend the most time in, namely Go, Javascript, and Typescript. So without further ado, here’s the config.

Let’s break down the fun parts. Some of the settings above are to change default Vim behavor. Others are plugins.

A leader key is a way to execute commands using a sequence of key strokes. In my Vim configuration I have set the leader key to comma on line 52.

On line 33 I have setup Vim to remember my cursor position when navigating between buffers. Without this, every time I changed buffer the cursor was reset to the beginning of the line. That got annoying fast.

On line 45 I’m setup to use the global system clipboard. By default Vim has registers for the clipboard which is managed internally. I find it easier just to integrate with the system clipboard, personally.

On line 100 I set Vim to display relative line numbers. If you turn on line numbers it will normally default to displaying absolute values. Relative shows the line number relative to the cursor position. This is super handy for navigation. Couple this with the vim-numbertoggle plugin on line 19, which shows absolute line numbers when in insert mode, and I get the best of both worlds!

NERDTree is a directory and file explorer for Vim. It’s a great way to navigate your project files and directory. I’ve bound <leader>1 as my key combination to toggle NERDTree on/off.

Simply the best way to search for text in files while in Vim. It opens a window with search results which you can navigate and see a preview.

junegunn/fzf.vim — Fuzzy finder. Simply the best way to search for text in files while in Vim. Opens a window with search results which you can navigate, getting a preview. I’ve set this up to use RipGrep, which is a crazy fast grep replacement.

Lightline is a really nice, lightweight status bar. I’ve got mine configured pretty close to the recommended, basic configuration, and have added the current Git branch I’m working on (using Fugitive). See lines 11 and 176–185.

The rest of the configuration should be easy enough to follow. I have comments for what each configuration item does. Do note, however, that a number of these plugins requires configuration and installation of 3rd party tools (such as Ripgrep, Fuzzy Finder, etc…).

Overall I’m pretty happy with what I’ve got. If you have an awesome configuration tip drop it in the comments! Cheers!

Just a guy who loves his wife, kids, and writing software.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store