Skip to content

Instantly share code, notes, and snippets.

Created December 10, 2010 13:58
  • Star 11 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Add this to your ~/.nanorc and when running "git commit" (if your editor is nano) you'll have syntax highlighting in your commit message. Includes support for "git commit -v" too!
syntax "gitcommit" "COMMIT_EDITMSG$"
color white "#.*"
color green "#.(modified|deleted).*"
color yellow start="# Changes.*" end="# Changed.*"
color cyan start="# Untracked.*" end="diff"
color cyan start="# Untracked.*" end="$$"
color brightred "^deleted file mode .*"
color brightgreen "^\+.*"
color brightred "^-.*"
color brightyellow "^(diff|index|---|\+\+\+).*"
color brightmagenta "@@.*@@"
color white "# (Change[ds]|Untracked) .*"
color white "#.*\(use .*"
color white "^#"
Copy link

ob-ivan commented Feb 21, 2019

Great highlighting! My life has just become so much better!

Some ideas to add to this:

  • Put this into a separate file (I use .config/nano/gitcommit.nanorc) and then reference to it from your .nanorc with an include line as described here:
  • Use different colors for comments and the message itself. E.g. cyan for the comments.
  • Special highlighting for the "cut" line with ---- >8 ----.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment