Skip to content

Instantly share code, notes, and snippets.

@zzamboni
Created May 19, 2009 11:23
Show Gist options
  • Save zzamboni/114048 to your computer and use it in GitHub Desktop.
Save zzamboni/114048 to your computer and use it in GitHub Desktop.
# From http://blog.macromates.com/2006/wrapping-text-with-regular-expressions/
def wrap_text(txt, col = 80)
txt.gsub(/(.{1,#{col}})( +|$)\n?|(.{#{col}})/,
"\\1\\3\n")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment