Why I Use Vim

Written politely 2018-10-18.

History of Vim

If you want to know some history of Vim, a contraction of Vi Improved, check this article out on that. Vi has been around for over 40 years (1976), and is the basis for Vim, which has been around for around 30 years (1988) at this point. Vim has been ported to most modern Operating Systems and comes standard in every version of Apple MacOS.

One of my favorite reasons to use Vim has become my favorite way to write any text is the semantic way it allows me to think when writing. Some examples:

If I want to move a whole line down, I dd to delete the line and when my cursor is above the line I want to move my deleted line to, I p to paste the line.

If I want to append to the end of a line, I A to append the line with the text I want.

Here is a cheat sheet that I kept as a screensaver until I had absorbed all that I thought I could from this graphic. It is fantastic if you are learning Vim.

alt text

Most of the commands I want to use are mapped to keyboard commands that relate to some semantic prose that also describe what I am doing, rather than just being designated to a random collection of key combinations. I think in terms of what I want to do with the text, and Vim gives me a language that allows me to do that.

Previous Code Editors

Sublime Text

I started out using Sublime Text when I began coding at Nashville Software School. It was the first text editor that really seemed to stick with me. At this point, I don’t really remember much about using it other than the material theme that seemed to really look nice.

First exposure to Vim

At Nashville Software School, I also had my first exposure to Vim. I was overwhelmed with a lot of things at this time, like learning SCSS, HTML, JavaScript, and AngularJS and how they all work together to make the frontend of a website function. At this point, Vim was not a priority, as fancy as the things I could do with it seemed to be. It was overwhelming and at this point, too complicated.

PhpStorm and using Vim for the first time

When I worked at Bernard Health, my engineering manager used terminal Vim and could do things so quickly. This was the first time I saw Vim in action and the power it could provide. I tried for a week or two to just start using Vim, but with learning PHP, Laravel, and Vue.js to build some great HR software didn’t leave me a enough time to also learn Vim while meeting my deadlines. So, I kept using PhpStorm but didn’t forget the potential power I knew Vim possesses in experienced hands. As powerful as PhpStorm is, and as many feature as it comes out of the box with, I never felt comfortable with it.

How I tried to use Vim, Again

I tried again later in my tenure at Bernard Health, but had similar issues as before. I grew more frustrated at this point that I would ever be able to be a Vim user and wield the high power editor skills that I had seen demonstrated.

PyCharm and using Vim again, but not turning back

Shortly after I started to work at Smile Direct Club, I was busy learning Python and getting used to working in an Agile environment with 2 weeks sprints, I started to get curious again about my editor of choice. I was given access to use PyCharm. Just as with PhpStorm, I didn’t fall in love with PyCharm either.

At this point I set up Vim and started playing with it. This time, something clicked and I just started using it full time. I remember using for the first time in front of someone. That was nerve-wracking, for sure. I used it for the first time in front of a marketing team member, and I am sure they didn’t know what kind of new feat I had just taken up, but as they guided me to what they were trying to accomplish, I live coded successfully, but a little slower than normal. This was my litmus test. If I could use Vim somewhat proficiently, I just needed to keep practicing. I was hooked and didn’t turn back.

Trying VSCode with Vim Bindings

Even though I was hooked on Vim, I was curious if Vim was just a set of keybindings that could be used better in a more accomplished text editor that had other features, like refactoring, or an easier implementation of go to definition. I tried using VSCode with Vim bindings, but I couldn’t get anything working like the file explorer NerdTree in Vim.

Favorite features of Vim

Opening the Sidebar File Explorer

I could open NerdTree using <leader>+e and open a file just by pressing <cr>, which I also set up to close NerdTree. To me, Vim isn’t just a set of keybindings that help me write things better, it was also an editor that I enjoy working within.

Using tabs for open files

I set up my vim to open a new buffer and show the buffer using Airline. I can navigate to any of my open buffers using my <leader> plus the number of the open buffer. This is available in pretty much all other text editors, but I needed this to have a visual of what other files I am currently working on.

Snippets

I use snippets to set up new projects and files in a snap without having to enter all of the boilerplate associated with new React components, or Mocha tests for Redux Actions or Redux Reducers. These help tremendously when I am coding, and I know other editors have these features, but so does Vim.

Tight integration with Terminal

I use my terminal for so many things. I do all of my git stuff there, setting up servers, accessing the database, and editing text. I do all of these things inside of iTerm2. Why would I want my editor to be separated. And when I do want things separated, I can use MacVim.

My vim setup

I wanted to set up a dotfiles repo that also housed my bash and zsh files so that I could have them version controlled. This way, I cold have my setup synced over different computers and when I get a new computer, I can be set up and going quickly.

I would later rip the Vim portion of my dotfiles repo into a separate repo for just Vim files, since there were so many intricacies involved in just my Vim setup. I felt it was a better idea to keep them separate.

MacVim vs. Terminal Vim

As much as I like using a dedicated program for Vim development, such as MacVim, I like being able to type ctrl+z and be right back at my terminal. I think MacVim is better for doing a long term project that I have open for possibly weeks at a time. It handles longer larger files better in regards to scrolling and speed. There are advantages to both of these implementation of Vim that are great. Luckily, you don’t have to choose just one. I can have them both and have the same feature available inside of my terminal and in my text editor. They both use my same .vimrc, so my keybindings and extensions work the same in either instance.

Final Thoughts

Hopefully I have shared some of my journey along the path from developer to developer that uses vim. I am not saying it works better than anything else, like Emacs, because they are different beasts. But, if you are using a text editor without either one of these, your development powers could become super powers if you take the time to learn and use Vim. I wish Vim was available in everything I type in now. At least you can in your web browser. Vimium is available for both Chrome and FireFox.

Vim definitely changed the way I think when I am writing about how to accomplish something in an editor. If you give it a chance, maybe it will change the way you write, too.


Lucas McDaniel

Husband, father, teacher, musician, avid gamer, nature enthusiast, and passionate about the human condition.