Git Tip of the Day – syntax highlighting for commit messages

If your favorite editor is vim, you surely already noticed that even with default configuration you’ll get a nice syntax highlighting for commit messages. It notifies you if your commit message is too long, it auto-wraps long lines in the description. Pretty.



But sometimes all of this does not work. You still get only black and white display, no colors, no highlighting, nothing. My colleague spent two hours of googling for vim documentation, adjusting configuration, copying my configuration, to no avail.

Well if you reached that point in your life, and I believe some of you did (according to similar problems mentioned throughout the Internets), then…

… just ensure vim is your default editor, will you? 😀

Because vi is the default editor in Fedora. If you don’t put something like

export EDITOR=vim

into your ~/.bashrc or somewhere, then you have vi by default. And that does not do any of that pretty stuff.

The solution can be simple, but sometimes it can be really hard to find. Enjoy the day.

Flattr this

9 thoughts on “Git Tip of the Day – syntax highlighting for commit messages

  1. I’ve been wondering since for ever why I didn’t have the line/column number indication when typing a commit message.

    Turns out this is exactly that.


  2. By the way, you’ve just fixed two of my biggest annoyances with Git on the same day.

    I will forever remember August the third as a sacred day and worship the Holy Kamil and his infinite Git knowledge.

    (But only on that specific day, the rest of the year is dedicated to the Beefy Miracle :P)

  3. Alternatively you can globally set the ‘core.editor’ git option to ‘vim’:

    git config –global core.editor vim

  4. That moment when you consider yourself a respectable software developer and after trying different vim plugins and scratching your head about why the heck vim commits do not have any syntax highlighting you notice that you weren’t on vim at all.

    Thanks, really.

Leave a Reply (Markdown syntax supported)

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s