How to permanently hard-fold selection at specified line length?


#1

I need an action that would act like the *nix fold command when triggered on a line or on a selection, e.g.:

$ echo This is a very long line that I would like to have folded at a certain length and my son likes tigers, cougars, leopards, cheetahs, and lions | fold -sw60
This is a very long line that I would like to have folded 
at a certain length and my son likes tigers, cougars, 
leopards, cheetahs, and lions

Obviously, the fold-width would need to be configurable.

I also need a way to easily & quickly insert characters at the beginning of multiple lines without having to do regex search & replace (which would work). I could do the same thing in *nix on the cmdline with, e.g.:

$ echo This is a very long line that I would like to have folded at a certain length and my son likes tigers, cougars, leopards, cheetahs, and lions | fold -sw58 | sed 's/^/> /'
> This is a very long line that I would like to have folded 
> at a certain length and my son likes tigers, cougars, 
> leopards, cheetahs, and lions

Any thoughts? Am I gonna have to learn how to do packages for this?


#2

For the first request, see this topic:

For the second, you might consider submitting a PR to the autoflow package to do this.


#3

Thanks @leedohm. I somehow missed autoflow. That covers the first issue. Cheers.