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
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.
9 thoughts on “Git Tip of the Day – syntax highlighting for commit messages”
This line in my .bashrc is a must-haver.
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.
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)
Glad to help 🙂
Alternatively you can globally set the ‘core.editor’ git option to ‘vim’:
git config –global core.editor vim
thank you very very much 🙂 that was my problem
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.
You’re a goddamn genius, Gump!!
Christ, that was bothering me. What a simple solution.
That was it! Thanks!