I use Sublime Text (3) for my default Git commit message editor. I try to follow Git conventions using a hard limit on the number of characters per line (50 for the first line and 72 for the rest). I currently have guides set up at those intervals for visual reference, however rather than manually having to put a line return at the end of 72 characters, I would love to have ST automatically insert a line return for me. Essentially, I want to be able to write without line returns, but have actual returns put in for wrapping instead of just visually wrapping in the editor. Is there a reasonable way to do this?
Asked
Active
Viewed 1,482 times
1 Answers
7
There is a useful plugin for this (that I somehow missed in prior searches) called AutoWrap. AutoWrap does exactly what I wanted and automatically wraps the line after a certain number of characters with a line return, and the settings for activating it and the number of characters can be set by syntax type. Here is my associated Git Commit Message.sublime-settings
file (from Packages/User
):
{
"rulers": [50, 70],
"spell_check": true,
"auto_wrap": true,
"auto_wrap_width": 70
}
The auto_wrap
and auto_wrap_width
lines work perfectly with the plugin and I can keep or remove the rulers as need be.
![](../../users/profiles/817496.webp)
RedBassett
- 2,955
- 3
- 27
- 46
-
Thanks for answering your own question :). Can you be more specific please to where should I put this configuration? – appostolis Oct 06 '16 at 10:49
-
Find the packages directory in your machine (just Google it for your OS) and our this in a file inside the `User` subdirectory. The file can be titled anything, but I used the name in the answer. – RedBassett Oct 06 '16 at 10:53
-
I know where `User` folder is. Inside there I have Preferences.sublime-settings and some other files. Should I create a new txt file with `.sublime-settings` extension? I want this behaviour only for my commit messages. This is what I dont get. :D. Thanks for the quick reply though. – appostolis Oct 06 '16 at 11:45
-
`Git Commit Message` is its own syntax to Sublime, so it should be in a file called `Git Commit Message.sublime-settings`. – RedBassett Oct 06 '16 at 12:28
-
1For future reference, the easiest thing to do is open a Git commit message in Sublime then choose **Preferences** > **Settings – Syntax Specific** (on a Mac the Preferences menu is under the **Sublime Text** menu). Then you can use these (or any other) settings and they'll only apply to files with that syntax. On my machine, for instance, the filename needed to be `commit-message.sublime-settings`. – Kit Grose Jul 20 '17 at 05:27