Skip to content

Instantly share code, notes, and snippets.

@dbrockman
Last active December 24, 2019 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbrockman/1975588 to your computer and use it in GitHub Desktop.
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
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