Omar Abid

The VIM Experience

For the Vim crowd, my .vimrc file is available on Github.

I got introduced to Vim 7 years ago. Getting started with Vim was a challenge. I think it was a typical experience: Vim has a steep learning curve and requires lots of customization to hit that nice spot. There is even a cost to start typing actual text. As I've never been introduced to a Vim-like model, my intuition for a text editor is to just start typing. When you opt for a new experience to increase your productivity, it is hard to be convinced to hit a key to start typing. It seemed counter-intuitive.

That made me bail of Vim multiple times. But I always had the inklings to give it another shot. I think a part of it is "jealousy". Seeing other developers wrangling code in unusual ways, I wanted to have that kind of power. Also, carpal tunnel syndrome is real and I needed to relieve my hands of constant switching.

It is fair to say now that I'm comfortable enough with Vim. Vim was a game changer and had a significant impact on my productivity. I can see that the time spent on configuration and customization has been paying off dividends.

I rely heavily on Vim and though I made it sound like it is all roses; I do have some frustration. The editor has some considerable shortcomings; especially if you are expecting an IDE-like experience. The process of augmenting Vim to be able to support proper code formatting is rather expensive. That's something you get by default in most of the IDEs out there.

The most annoying of these were:

  • You don't get proper language support; even for formatting. The default formatter is very basic and language agnostic. You'll have to install different plugins for different languages.
  • Usually, there are different competing plugins for any particular language. You'll have to make a decision of what is best for you.
  • Many plugins require external programs to function. They also need to be able to call these properly from Vim. It can be a challenge to get that working properly and the documentation might be lacking.
  • Syntax checking is still lagging and years behind what most IDEs will offer you. This is, of course, my opinion.

Lately, I've been diving into Rust. So my Vim configuration has been getting accommodated accordingly. It makes this configuration a bit biased, though you can make use of the keyboard shortcuts and other goodies.

Pictures

Here is a sneak peek of Vim in action.

Image 1: Splitting and switching windows.

Gif Image 1

Image 2: Alternate between NerdTree and TagBar.

gif-2-prod.gif

Image 3: Easymotion to navigate through text.

gif-3-prod.gif

Image 4: Autocompletion for Rust.

gif-4-prod.gif

Shortcuts

Some of the custom shortcuts I added to Vim.

  • jj on insert mode to switch to command mode.
  • Arrow key are disabled and instead they resize the current split window.
  • tab to move between buffers
  • space + x to close the current buffer.
  • F to auto-format code. For Rust, it calls the rustfmt formatter.
  • Double space to toggle between fast and slow scrolling modes.
  • C moves to visual mode and select the text between quotes.
  • X move to visual mode and select the text between brackets.
  • W move to visual mode and select the current word.
  • B to select the text inside a Tag, and V to select the whole tag.
  • cc to comment/uncomment a block of code.
  • nj to toggle the NerdTree window.
  • nk to toggle to Tagbar window.

Plugins

This is not an exhaustive list, but these are some Vim plugins that I'm relying on.

What's next?

I don't think my Vim setup is anywhere close to maturity.

  • Documentation: The Readme file could be improved. There are several steps to get the final Vim functioning which are not documented throughly.
  • Source Control: Make frequent use of Git. It helps to remind what did change and when. It can also explain why some of these changes were made.
  • Docker: It'd be great if I can run my Vim instance through a Docker container. It'll make the install process easy and ubiquitous. I'm yet to try that and not quite certain of the volumes/files handling and performance.
  • Language Server Protocol : I think this could be a solution to the auto-complete and syntax checking mess. Along with a containerized Vim instance, it might be possible to finally have several popular language on functioning and stable auto-complete.
  • Undo and Redo: Currently I only use u to undo the last action. I think this is an area where things can improve.

Subscribe to the Newsletter

Get the latest posts from this blog delivered to your inbox. No spam.