Skip to content

Instantly share code, notes, and snippets.

Embed
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 "^#"
@hraban

This comment has been minimized.

Copy link

commented Jan 6, 2016

great!! thanks man

@lol-russo

This comment has been minimized.

Copy link

commented Nov 29, 2016

Legend cheers mate

@dacdave

This comment has been minimized.

Copy link

commented Dec 5, 2016

Will this work for .vimrc as well?

@dos1

This comment has been minimized.

Copy link

commented Sep 22, 2017

Thanks <3

@ob-ivan

This comment has been minimized.

Copy link

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: http://milianw.de/code-snippets/git-commit-message-highlighting-in-nano
  • 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
You can’t perform that action at this time.