microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.37k stars 28.93k forks source link

Git: Automatically insert line breaks in git commit messages #2718

Open stkb opened 8 years ago

stkb commented 8 years ago

I'm trying to get into the habit of writing good commit messages. Not sure if this should be the default but it would be really useful if vscode automatically wrapped commit message lines at say 80 chars and inserted line breaks.

I don't mean changing the appearance of the text in the commit message box, just before it's actually committed. The line length could be in an option too.

buondevid commented 10 months ago

Nothing for the commit box in the top-left corner? An automatic wrapping option would be very appreciated. See my previous comment.

zarembas commented 10 months ago

I started using the commit command because of this issue, but to be honest now I prefer it to the input box.

zarembas commented 9 months ago

Setting the rules from a previous message

  "[git-commit]": {
    "editor.rulers": [
      72,
      50
    ],
    "editor.wordWrap": "wordWrapColumn",
    "editor.wordWrapColumn": 72
  }

is not working as expected.

It wraps the commit message to 72 characters, but it doesn't add newlines, so after you commit, the message won't be wrapped.

lszomoru commented 8 months ago

Today's VS Code Insiders release (version details below) contains a new setting, git.experimental.inputValidation ,to enable a new implementation of input validation for the commit input field that uses language diagnostics. Using diagnostics also enabled us to implement quick fixes (ex: hard wrap long lines). Enable the new setting, and try out the hard wrap code action and let me know what you think. Thanks!

Version: 1.87.0-insider (Universal)
Commit: 01f46bb5357baa8f3b9da690e1e34eb78e09a72b
Date: 2024-02-12T05:48:37.277Z
Electron: 27.3.1
ElectronBuildId: 26731440
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Darwin arm64 23.3.0
buondevid commented 7 months ago

In the new VSCode release (1.87) there is a setting that can be enabled now both for subject and message 👌 image

justingrant commented 7 months ago

I'm running 1.87.0 (not insiders) but I'm not seeing any line breaks inserted in my commit message when it goes over the limit. Expected? Here's a screenshot illustrating the problem.

image
dvnrsn commented 7 months ago

@justingrant yeah it's only a validation warning (which is working on yours). If you want it to auto wrap as you type you'll need to use something like rewrap and the full editor (see my comment above). afaict that's the only way to do this in vs code as of yet.

justingrant commented 7 months ago

@dvnrsn the previous VS Code release had a setting where you could see the number of chars in the field as you were typing. This stopped working in the current release. Is there a way to re-enable it?

I'm asking because it was much more convenient to know when the limit was coming, because then I could proactively hit Enter to move to the next line. With that feature removed, now I had to wait until I see the yellow warning squiggle, then back up and remove the last word, then press Enter. That's a lot more unnecessary extra typing.

One possible solution could be a small countdown timer like Twitter uses. Like this? image