DEV Community

Cover image for Setting up VSCode to write commit messages like a boss
crespire
crespire

Posted on • Edited on

4

Setting up VSCode to write commit messages like a boss

So you've got your shiny code all ready to push up to remote, and you're about to write a commit message.

I am sure you've heard all the tips about writing excellent commit messages, like making sure the title is only so long, that the body is only x characters per line and all that fun stuff. Did you know that you can use VSCode to make your commit messages?

First, configure VSCode as the default editor for git:

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

This command sets git to open up VSCode when you type git commit without passing in a -m "message" so that you can provide more context about your commit message. The --wait part just tells git to wait until the user closes the file before moving on.

Now, when you type git commit without -m, you'll see a file open in your VSCode called COMMIT_EDITMSG and git will wait until that file is saved and closed before continuing.

Second, we can actually set up some rulers to help you make sure you stay within the recommended formatting! You'll want to open up your settings.json and insert these lines:

"[git-commit]": {
        "editor.rulers": [50, 72],
    },
Enter fullscreen mode Exit fullscreen mode

This will add two rulers to the editor that will open for any git commit! The ruler is the 50 character limit for the title and the second is the 72 character limit for the body of the commit.

That's it, now you can write all the commit messages you want and know that they will render properly!

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️