Skip to content

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

Open

Description

@stkb

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.

Activity

  1. joaomoreno commented on Feb 5, 2016

    @joaomoreno
    Contributor

    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?

  2. added
    help wanted
    feature-request
    on Feb 5, 2016
  3. stkb commented on Feb 5, 2016

    @stkb
    ContributorAuthor

    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.

  4. joaomoreno commented on Feb 7, 2016

    @joaomoreno
    Contributor

    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?

  5. stkb commented on Feb 10, 2016

    @stkb
    ContributorAuthor

    This is an effect used in Github Desktop, as well as elsewhere.

    commitmessage

    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.

    commitmessage2

    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).

  6. removed this from the Feb 2016 milestone on Feb 23, 2016
  7. arirawr commented on Jun 28, 2016

    @arirawr

    João Moreno (@joaomoreno) Anyone working on this? I'm happy to give it a look.

  8. joaomoreno commented on Jul 4, 2016

    @joaomoreno
    Contributor

    Actually we already have this:

    image

  9. nomicos commented on Dec 14, 2016

    @nomicos

    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.

  10. 61 remaining items

  11. buondevid commented on Feb 29, 2024

    @buondevid

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

  12. justingrant commented on Mar 7, 2024

    @justingrant
    Contributor

    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
  13. dvnrsn commented on Mar 8, 2024

    @dvnrsn

    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.

  14. justingrant commented on Mar 10, 2024

    @justingrant
    Contributor

    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?
    image

  15. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestgithelp wanted

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions