Last active
December 24, 2019 22:05
-
-
Save dbrockman/1975588 to your computer and use it in GitHub Desktop.
Wrap line at the highest column (<= 80) divisible by the length of the line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wrapLineAtDivisibleColumn(line) { | |
var column = 80; | |
while (line.length / column % 1) --column; | |
return line.replace(new RegExp('.{' + column + '}(?!$)', 'g'), '$&\n'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment