I need to set a shortcut for the Edit - Wrap - Wrap at XX characters
command in Sublime Text 3.
I'm aware of the AutoWrap package, but that works as you write splitting long lines into new ones.
The article Adding Word Wrap Toggle Shortcut Key in Sublime Text 3 explains how to add a shortcut but not to break long lines, it just wraps them.
I need to wrap at 80 chars, but it'd be great if I could set the XX
number of characters.
The command that the menu items you reference above use to perform the wrap is the wrap_lines
command. It takes an argument width
that specifies at what column the wrap should occur, so you can provide any width you want in your binding, or have multiple bindings to have multiple pre-set wrap amounts.
For example:
{
"keys": ["super+w"],
"command": "wrap_lines",
"args": {
"width": 80
},
},
{
"keys": ["shift+super+w"],
"command": "wrap_lines",
"args": {
"width": 40
},
},
The width
argument to the command is optional; if you don't provide it, Sublime chooses a default:
View > Word Wrap Column
menu Automatic
, the ruler from the View > Ruler
menuNone
, then the wrap happens at column 78.Note also that the value of the wrap column can be adjusted infinitely by altering the wrap_width
setting, and the list of rulers can be adjusted to whatever you want by using the rulers
setting. The related menu items are just modifying the value of the setting in the current view.
As a note on rulers
, there can be more than one of them listed; if that is the case, the first one in the list would be used as the wrap point in #2 above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With