Hacker News new | ask | show | jobs
by dredmorbius 4440 days ago
gq for reflowing.

The main problem I have is when I'm authoring in vim and pasting to another editor which interprets hard returns as, well, hard returns.

Mostly I play games with piping through a formatting tool or join up lines manually before pasting them. Hrm. Now you've got me wondering if there's a good way to do that generically.

1 comments

And here's what I've come up with, as ~/bin/unwrap:

    #!/usr/bin/perl -p
    
    use strict;
    
    BEGIN{$/=undef;} 
    
    { s/(?<!\n)\n(?!\n)//sg; }
    
    END {print"\n"}