I use Vim extensively outside of professional work. Not only do I use it when working on side software projects, but also for just about any kind of writing. I write daily posts in my TIL repository about using Vim. I even put together a project-specific vimrc file to give myself a custom utility function just for that project. I also blog with markdown files in Vim. I recently discovered that the vim-markdown plugin supports syntax highlighting of fenced code blocks, so that is a game changer.
I’ve been using Vim since college, so for about 6 or 7 years. It has only been in about the last 2 years though that I’ve really felt like I’ve had any mastery of Vim. I used to do a lot of Java development in college and it didn’t make a lot of sense to do that outside of any IDE (like Eclipse), so I used Vim less frequently then than I do now.
I like to use Vim in the terminal with the Macvim binary. I almost
exclusively use a Mac and while the system Vim is fine, the Macvim binary
provides tighter integration with OS X. This means
that I can copy stuff from another program into Vim with
p and likewise I
can yank text from Vim for use in another program. I sometimes use Atom and
Sublime (with Vim-mode enabled), but I usually end up getting frustrated
when I start hitting the bindings for my favorite plugins and they aren’t
A long time ago I wanted to step up my Vim game, but I didn’t really understand how to tailor/configure Vim to my needs. I ended up copying a fellow developer’s vimrc file, which was heavily customized. As I’ve came to understand those settings and develop my own opinions, I’ve began to tweak things here and there. In the last couple years, I’ve started to cull back some of the customizations. Many of them were there but I wasn’t even using them.
I’ve heard people say, “Don’t put anything in your Vim configuration that you don’t understand.” I mostly agree with that. However, the defaults for Vim are not great for extended use. People just getting started with Vim are going to experience a lot of friction with the defaults. Learning to use Vim and configure it at the same time is a daunting task. For this reason, I really like sensible.vim. It makes Vim behave in a sane way without over-customizing it.
What I’m getting at is that I’m not too picky about any particular vimrc settings as long as the stuff you find in sensible.vim is turned on and I have my plugins (see below).
One line in my vimrc that I really like having around for everyday development, but don’t see very often is:
This enables a built-in plugin that opens man pages in a Vim split window by
:Man command (e.g.
Some of my favorite plugins are the ones that can be used in just about any context. The three that come to mind are:
I use many more plugins, but these are the ones I’d have a hard time living without.
I don’t get to caught up in a particular color scheme as long as the different syntax elements are clear. I do, however, prefer a black background. My current color scheme seems to be railscasts.
My leader key is backslash (
\). I don’t tend to use many leader mappings,
but there are a couple that I’ve been experimenting with recently.
I have mapped
\d to quickly open the parent directory of the current file
nmap <leader>d :e %:h<cr>
I also have
\D to quickly create any directories for the current file
nmap <leader>D :!mkdir -p %:h<cr>
Although, I’ve been using this less and less since discovering eunuch.vim’s
I mentioned earlier that despite having been using Vim for the past 6 or 7 years, it was only in the last couple years that I’ve really started to feel like I’ve mastered it. The reason for this is because I am just now discovering the best resources for learning Vim.
First and foremost, I learn an incredible amount my pair programming everyday in Vim. All my coworkers at Hashrocket combine to be a wealth of Vim knowledge. Every time I switch pairs I learn a handful of new things and more efficient workflows.
I’ve started to effectively use the Vim help files. There is so much information in those files. Sometimes I will be looking up one command and 15 minutes later I will be halfway down the help file reading about all these Vim features I had no idea about.
Drew Neil’s Practical Vim is another really valuable resource. I only recently read it. I wish I would have discovered it years ago.
I recently wrote a blog posted titled “How to get help with Vim” which is a big part of this.
I recently learned about the
gn motion for interacting with matches to a
search pattern. I’ve yet to use it much, but I can see how it is a great
complement to doing standard substitutions.
What I love about Vim is the composability aspect. In learning one simple motion, I’ve actually learned a bunch of different ways to interact with and manipulate a piece of the buffer.
I help organize VimChi, Chicago’s Vim Meetup. We meet once a month and we either invite a single speaker to talk about something they are interested in or we do lightning talks. Any Vim users in the Chicago area should definitely check it out.
I’ve given talks about how I use buffers in Vim and how sensible.vim works.
It’s not much, but I added this small snippet of vimscript to my TIL repository to make it easier to get a count of the TILs:
function! CountTILs() execute '%s/^- \[//n' endfunction nnoremap <leader>c :call CountTILs()<cr>
It is a fairly standard substitution command, except for the
n on the end.
n there, instead of doing a substitution, this returns a count of
the number of matches for the given pattern. I feel like this is a little
known feature of the substitution command. It’s pretty handy though.
I am constantly exploring new languages. It is always interesting to see what sorts of tooling different communities have wrapped into Vim plugins.
For instance, I do Clojure development in Vim from time to time. While many people might recommend using Emacs for a lisp-style language, there is actually some pretty good tooling for Vim. There is a plugin (fireplace.vim) that connects to a Clojure REPL so that you can execute snippets of code from within Vim. Another plugin (vim-sexp-mappings-for-regular-people) provides some handy mappings for manipulating Clojure code.