Updated VIM Setup

Michael Sharpe
6 min readDec 23, 2020

--

I learned vi in 1991 at university. I kind of immediately took to it, likely because I had messed around a lot with the DOS edlin.exe. The vi editor was so super powerful in comparison. At the time, Vim did not exist or was not popular. A few years later, Elvis and Vim started becoming popular. I played with Elvis for a while; I think it had syntax highlighting first. But Vim soon became more popular, so I switched to that. I have never really looked back.

I think it was in the early 2000s that Vimscript was born. I was doing a lot of C/C++ programming then, and I ended up writing a small script called a.vim, which switches between the source .c file and the corresponding header .h file. In the years since I played with many other scripts which others published. I never really got into the Vim package managers, so my VIM setup was pretty much a collection of fragments of published scripts and that I had written. Fast forward to yesterday, and basically, it was a mess imploding on itself. Everything worked; it was just all fragile and disorganized.

Today, I decided to start from scratch, toss out almost everything and build a set of config files that are clean, lean, and organized. Thankfully Vim now has a built-in package manager, and most published scripts are actually in git. It is a simple matter of forking/cloning the repos to install Vim packages now, making it super easy to contribute back possibly.

I was super surprised by how smoothly everything went. The latest versions of all the packages I installed, some of which I used from years ago, are now remarkably stable. I did not have to tweak any of the packages I am using; in fact, I spent most of my time dealing with fonts and terminal emulators.

Environments

I primarily work in three environments, Windows 10, macOS, and Linux. One of the primary reasons I use Vim is because it works everywhere. In the 1990s I worked on a product that was ported to every Unix flavor, mainframe systems, windows, OS/2, you name it, we ported it there. Vim was the only common editor. Well, vi was the common editor, but we managed to get Vim compiled and installed everywhere.

The greatest difficulty I had with cleaning up my Vim config was color support in the various environments where I develop. Some terminals supported 24-bit color, others only 256 colors or worse. I ended up settling on the new Windows Terminal for Windows 10. On macOS, I was using the built-in terminal app but switched to iTerm2. On linux each distro seems to have a 24-bit color terminal by default. After the terminals were upgraded or configured correctly, I managed to get color schemes to look the same in both the GUI version of Vim and the terminal version. Its worth taking the time to do that.

I spent a lot of time getting a common font installed on all three OSes. I wanted a font that was patched to include the extra Powerline style symbols. Initially, I tried the Powerline fonts but could not get them to work. Fortunately, I found https://www.nerdfonts.com. These fonts just worked, there are lots of font choices, and they are easy to install on each platform.

Packages

Here is the set of packages I installed in my new setup and some of the reasons I liked them.

NERDTree and Fern

I had used NERDTree in the past; even years ago, it was a super good file browser. It has improved a lot and is still fantastic. The integration with Powerline style fonts is excellent. Fern is a new file browser, it’s also terrific. I’d highly recommend both of them.

Vim Airline and Lightline

Both of these are status line plugins. They aim to put as much useful information into the VIM status line as possible. They are super handy for at glance information, file types, current line/column position, even git status, etc. I initially tried Vim Airline but moved away from it when I could not get the Powerline fonts to work. Lightline looked more agreeable, in my opinion, compared with the airline when no bling was available. However, once I discovered the Nerdfonts package, I moved back to vim-airline in my final setup.

I installed vim-devicons, which adds bling to a lot of existing installed packages.

Vim-fugitive

Fugutive is a script that integrates Vim and git. It seems to be the most recommend integration. I installed it, and it looks promising.

Vimwiki

I recall setting this up in the past too, I never really got it to work well. It works beautifully now, though. It is an excellent way to keep some quick notes. I think this is more of a curiosity for me currently, as I also use ROAM for notes.

FzF

FzF is a fuzzy file finder. It is actually so much more. I had written similar plugging in the past, which integrated grep/find and similar tools via the quickfix feature. I was blown away with FzF and particularly the integration via the preview window. I got it working well on Linux and macOS, but windows needs a little debugging to get it to work with the preview window. It works well in quickfix mode. In addition to integrating the fzf command, it integrates ag (the_silver_searcher) and ripgrep too. All three tools are super fast and the integrations with VIM are clean. These tools will improve your workflow. These have retired a lot of the cobbled together scripts I used in the past.

vim-visual-multi

This is a neat script that brings a multi-cursor implementation from editors like VSCode and Sublime text. So far, I have been impressed with how well it works, and I am trying to use it more.

Language Enhancements

To support the main programming languages I currently use, I installed vim-go, vim-ruby, emmet-vim, and vim-javascript. All are improvements over built-in support. I am still playing with some other javascript enhancements too. But these all seem useful and stable so far.

Conquer of Completion

I did play with CoC on my work machine. It was easy to setup for ruby, vim lang, and a few others. I had trouble getting it to work well with golang. It looks like vim-go and coc-go mess with each other. I have a feeling emmet and coc-html conflict with each other too. Of course, CoC’s features depend on the underlying language servers. There are differences between each language server in terms of supported functionality. But when it works, it is incredible. I am still evaluating CoC.

Colorschemes

I recommend using https://vimcolors.com to pick a good colorscheme. In the past I had my own color scheme. Sadly, it was inconsistent and just missing things. Alot of people have gone to great effort to produce good consistent colorscheme with broad support for all languages. Of course, the color schemes and the desire for enhanced fonts lead down the rabbit hole for terminal setups that support 24bit colors. In the past, I had made the 256 color mac terminal application work, but sheesh, I was missing out a lot here. I Highly recommend iTerm2 on the mac to bypass the limitations of the Terminal App. The color scheme I select was gruvbox, but I tweaked it to make the background black and the foreground white. these two colors are used only in a couple of places.

Gruvbox color scheme, vim-airline status bar with Powerline glyphs

:wq!

I am still playing with some other packages, but am trying to keep things quite minimalist. Of course I have some of my own scripts around too and my initial vimrc. I have managed to eliminate or clean up more than half my vimrc and most of my own scripts have been replaced. FzF eliminated the need for many of my adhoc scripts.

It’s essential to keep your editor configuration good shape. Over the years, it should be cleaned up periodically. I was a little scared to toss everything out and start over initially, but in the end, I think I have ended up with a clean set of config files and a far improved workflow. I have managed to eliminate many things that simply have fallen out of my workflow and added a lot of things to improve my workflow.

--

--

Michael Sharpe

Senior Software Architect located in Houston, Texas