← til

Writing custom Vim snippets

May 8, 2020

vim-snipmate is a really useful Vim plugin that adds support for custom autocompletion. vim-snippets adds a bunch of useful snippets for various languages.

This helps me save keystrokes. For example, writing:


And pressing <TAB> will autocomplete this to:

require "pry"; binding.pry

There's other useful snippets, for defining classes, methods or test cases.

I've noticed I use focus a lot, in order to run a single test. These plugins don't come with a snippet for that, so I needed to write my own custom snippet.

I needed to place this in ~/.vim/after/snippets/_.snippets:

snippet f

After I did this, pressing f<TAB> autocompletes to focus.

0 kudos