← articles

Loving Vim

March 19, 2018

This post is inspired by Falling in love with Vim again by @michaelsoolee.

I love Vim. I've been using it for a long time for bascially everything. I'm writing code locally in it, use it in ssh sessions remotely and yes, I'm writing this post in it.

The power of Vim and beginner friendliness

The thing I like the most about it is its grammar. For me that's the most powerful part of Vim. No modern editors have figured this out yet, but the fact that you can combine verbs and nouns into commands is what makes the difference.

I don't suggest Vim to beginners. The reason behind this is the fact that Vim operates in modes, which makes it unintuitive to open the file and edit it. Not to mention exiting Vim. If you're just getting started with programming and are searching for a solid editor, I'd recommend Atom. It's free, really intuitive, configurable, comes with syntax highlighting and has a large community providing an endless number of plugins.


The really cool part of Vim is seeing how other people use it, which is made possible by the configuration file Vim uses, which people can share online, in their dotfiles. Github search for that term will give you a lot of repositories to look into for inspiration. Dotfiles are not just for Vim, they are a powerful tool for saving entire environment. From zsh/bash configuration to git configuration to Vim configuration, it's all saved there. You can test someone else's environment configuration by making a new user locally and cloning the dotfiles repo, symlinking those configuration files. If you still don't have it you should consider making a dotfiles repo and storing your settings there. By doing that you'll no longer have to worry about losing your settings if something happens to them locally.

My Vim workflow

This is what my Vim looks like.

These are my decisions:

  • font is 18pt Inconsolata
  • theme is a customization of gruvbox
  • no line numbers, they are a distraction
  • minimal file details at the bottom of the screen
  • no plugins that take too much space like NerdTree
  • branch info is visible

Three plugins I use the most frequently

Here are the plugins I use the most, sorted by the frequency of use.

1. ctrlp

Used for switching between files. Say no to NerdTree.

Here's how I've configured it.

" Set CTRL-P to ignore anything matching this regex
let g:ctrlp_custom_ignore = 'DS_Store\|tmp\|node_modules'

" Set CTRL-P to lookup files based on regex, instead of basename only
let g:ctrlp_regexp = 1

" Set CTRL-P working directory to the first ancestor directory that contains .git/
let g:ctrlp_working_path_mode = 2

2. unimpaired

Also used for switching between files. This is used when files are in the same directory. Typing [f and ]f is really fast.

3. ag.vim

Used for searching for text inside a project. It uses the silver searcher, a replacement for grep under the hood.

Notice how I use [q and ]q to navigate between results. Here's my configuration.

" Tell ag.vim to stop using regex search
let g:ackprg = 'ag --nogroup --nocolor --column --literal'

" Abbreviate ag to Ag
cabbrev ag Ag

" Map CTRL+A to Ag
map <C-a> :Ag 

" Search for word under cursor with ag
noremap <Leader>a :Ag <cword><cr>

And that's it, those are the most essential plugins I would recommend. Other than those plugins, I use <C-o> and <C-i> to navigate between files a lot.

I use Bower as a package manager for my Vim plugins, since it's the package manager that allows Github repos as package locations and I've found that most of Vim plugins are hosted on Github. No changes are required on the repo for it to be acceptable by Bower. It's great because it lets you keep a JSON file of the list of plugins you use in your dotfiles repo.

As an example of how a vimrc file looks after a couple of years of use you can take a look at my vimrc. For plugin suggestions take look at all the plugins I use.

0 kudos
Join my newsletter and get articles that sometimes end up on the front page of Hacker News straight in your inbox.

Unsubscribe anytime. By submitting your email, you agree to our privacy policy.