Skip to content Paweł Grzybek

Multi-paragraph git commit messages (CLI and Visual Studio Code)

I recently joined a new team that follows Conventional Commits methodology for git commit messages. Multi-paragraph format of commit messages was new to me and I didn’t have a clue how to do it. Turns out there are multiple ways of doing it using CLI and also my favourite code editor Visual Studio Code.

Multi-paragraph git commit message using CLI

Presumably, git CLI is the most common way to interact with this version control system. I found three different methods to achieve multi-paragraph commit message using this method.

git commit -m 'Line  one' -m 'Line two' -m 'Line three'
git commit -m 'Line one

Line two

Line three'
git commit -m $'Line one\n\nLine two\n\nLine three'

All three methods above will produce exactly the same commit message:

Line one

Line two

Line three

Multi-paragraph git commit message using Visual Studio Code

Let’s be honest, it is a lot of typing and I am a crap touch typer. Luckily we can always use the code editor to edit commit messages. By default most UNIX operating systems come with vim preconfigured as a default editor. This is not the option that I love. I barely can exit this editor and “How do I exit the Vim editor?” post on Stack Overflow makes me think that I am not the only one. Luckily we can change core.editor for git. My preferred one is Visual Studio Code.

git config --global core.editor "code --wait"

Now on you can simply use git commit command to enter Visual Studio Code to edit a message. It is going to wait until the VSCode tab is closed to send a signal to git CLI that we finished editing. That’s so much nicer for multi-paragraph git commit messages in my opinion!

There is more to it. If you follow some particular pattern for your commit messages you can create a VSCode snippet for it. I made one for conventional commits, look!

Conventional Commits snippet for Visual Studio Code
  "Conventional Commits": {
    "prefix": "commit",
    "body": [
      "${1|build,ci,docs,feat,fix,perf,refactor,revert,style,test|}${2:scope (optional)}: ${3:description}",
      "${4:body (optional)}",
      "Refs #${5:ticket number}"
    "description": "Conventional Commits"

Keep on coding and I will catch you next time 👋

Leave a comment

👆 you can use Markdown here

Your comment is awaiting moderation. Thanks!