You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Git - Automatically insert line breaks in git commit messages #2718
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.
Reacted by Ralf Sternberg, nomicos, f, Mariusz Nowak, Juan B. Rodriguez, Tim Northover, Jason Stathopulos, Martins Barinskis, François Best, Max Biegert and 102 more
How about a little UI that would tell you that some lines are over 80 characters, and you'd format them yourself? Would that work?
Reacted by Rodrigo Roa Rodríguez, Tony Jackson, James Harrang, Richard Waller, Atlinx, Dan Albert, Mark Donnellon, David Fahlander, Leonid Gaiazov, Jack W and 14 more
João Moreno (@joaomoreno) Maybe, and actually that was my first thought, though these points came to mind:
It might be difficult to do without cluttering up the currently nice and clean UI
It might look weird/be difficult to format the text given that the comment box uses a variable width and not a monospaced font.
If it was on by default, some people might not like in it a "I don't care/stop telling me what to do" kind of way.
Having the wrapping done automatically is easier for you than having to do it manually anyway, and in special cases where you need to do it manually you can still do so.
Overall I felt that just inserting hard line breaks before committing would be easier, though it does mean writing or finding the code to do the word-wrapping (not sure what the policy is on using external js libraries). There could be a setting something like "git.commentLineLength" with a default 0 (no word wrap) so no-one gets any unexpected behavior.
In any case if it's wanted it is something I'm prepared to work on.
As for the UI, I was thinking something like what you get when you try to rename a file to / in the explorer. I would't use the red color but something smoother, that doesn't sound such a big alarm. I would also put it behind an enablement setting.
I would like to stay away from automatic wrapping, since it might not do what the user intends to do. Also, we'd have to make it work for non-latin languages too: Arabic, Japanese, Chinese, etc. Not a trivial task.
There's a double edge sword in automatic wrapping: turning it on by default would be transparent to the user and, if the outcome is not desirable, he will only detect that when it's too late, probably when the commit was pushed to his server. If we set it off by default, we risk that no one will find and/or use it.
This is an effect used in Github Desktop, as well as elsewhere.
Although here the effect is a bit too subtle; I find it a bit difficult to see the limit. In Twitter it's much more visible.
Something between the two would be really neat, and maybe with the right balance it could be on by default.
However I don't know if the edit box is capable of that kind of rich text, so failing that, yeah the popup that comes up when entering an invalid filename is also nice and that would be ok (as you say, in a less flashy color).
João Moreno (@joaomoreno) That is a tooltip addressing the first line of the commit message. But I think the proposal described in this issue was about having Visual Studio Code automatically wrap the commit message body to 72 characters per line (the 50/72 convention). In that case, the user's only worry would be the message itself, with VSC wrapping it right after they click 'Commit' and before the actual commit is made.
Reacted by Mariusz Nowak, Robin Munn, Eric Kidd, Wayne Werner, Mat Brown, Dan Palmer, Sipho, Ivan Bobev, Jeremy Spiegel, adab4d and 13 more
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.
Justin Grant (@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.
Devin Rasmussen (@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?
Reacted by Davide Briano, Devin Rasmussen, Peter S. Hollander, Jacob Hands and Mick Dekkers
changed the title [-]Git: Automatically insert line breaks in git commit messages[/-][+]Git - Automatically insert line breaks in git commit messages[/+]on Dec 10, 2024
Activity
joaomoreno commentedon Feb 5, 2016
How about a little UI that would tell you that some lines are over 80 characters, and you'd format them yourself? Would that work?
stkb commentedon Feb 5, 2016
João Moreno (@joaomoreno) Maybe, and actually that was my first thought, though these points came to mind:
Overall I felt that just inserting hard line breaks before committing would be easier, though it does mean writing or finding the code to do the word-wrapping (not sure what the policy is on using external js libraries). There could be a setting something like
"git.commentLineLength"with a default0(no word wrap) so no-one gets any unexpected behavior.In any case if it's wanted it is something I'm prepared to work on.
joaomoreno commentedon Feb 7, 2016
Good points.
As for the UI, I was thinking something like what you get when you try to rename a file to
/in the explorer. I would't use the red color but something smoother, that doesn't sound such a big alarm. I would also put it behind an enablement setting.I would like to stay away from automatic wrapping, since it might not do what the user intends to do. Also, we'd have to make it work for non-latin languages too: Arabic, Japanese, Chinese, etc. Not a trivial task.
There's a double edge sword in automatic wrapping: turning it on by default would be transparent to the user and, if the outcome is not desirable, he will only detect that when it's too late, probably when the commit was pushed to his server. If we set it off by default, we risk that no one will find and/or use it.
What do you think?
stkb commentedon Feb 10, 2016
This is an effect used in Github Desktop, as well as elsewhere.
Although here the effect is a bit too subtle; I find it a bit difficult to see the limit. In Twitter it's much more visible.
Something between the two would be really neat, and maybe with the right balance it could be on by default.
However I don't know if the edit box is capable of that kind of rich text, so failing that, yeah the popup that comes up when entering an invalid filename is also nice and that would be ok (as you say, in a less flashy color).
arirawr commentedon Jun 28, 2016
João Moreno (@joaomoreno) Anyone working on this? I'm happy to give it a look.
joaomoreno commentedon Jul 4, 2016
Actually we already have this:
nomicos commentedon Dec 14, 2016
João Moreno (@joaomoreno) That is a tooltip addressing the first line of the commit message. But I think the proposal described in this issue was about having Visual Studio Code automatically wrap the commit message body to 72 characters per line (the 50/72 convention). In that case, the user's only worry would be the message itself, with VSC wrapping it right after they click 'Commit' and before the actual commit is made.
61 remaining items
buondevid commentedon Feb 29, 2024
In the new VSCode release (1.87) there is a setting that can be enabled now both for subject and message 👌

justingrant commentedon Mar 7, 2024
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.
dvnrsn commentedon Mar 8, 2024
Justin Grant (@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 commentedon Mar 10, 2024
Devin Rasmussen (@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?

[-]Git: Automatically insert line breaks in git commit messages[/-][+]Git - Automatically insert line breaks in git commit messages[/+]Format Git commit messages with Prettier
Format Git commit messages with Prettier
Format Git commit messages with Prettier
Format Git commit messages with Prettier
Format Git commit messages with Prettier
Format Git commit messages with Prettier
Format Git commit messages with Prettier
style: add Prettier overrides for Git commits+tags
Format Git commit and tag messages with Prettier
Format Git commit and tag messages with Prettier