Vim Autocompletion is Underrated

Recently I found writing commit message with vim auto completion is surprisingly delightful.

How many times did you give up writing a useful commit message because you don’t want to type a very long class name or hard to remember variables? Instead, I shamefully put “update” in my commit message from time to time.

Let’s see how vim auto completion come to the rescue.

Firstly, we should remember, unlike an IDE, vim can not perform auto completion by searching keywords across files. So when writing a commit message, we should provide vim with the context:

git commit -av

I always use -v argument to perform a quick last minute check. Regarding writing commit message, it also provides vim the context for auto completion.

Then try to type something related to your changes.

In the following example, after typing “rename Te”, simply press “ctrl+n”, vim will auto complete the class name, which is very often what we need to provide in a commit message.

Note how vim auto complete class name before and after change, that’s because git display both of them below.

vim-autocompletion

Hats off to whoever implemented this!

Posted 2020-01-28

More writing at jakehao.com