A Nedit macro by Michael Collette and Joachim Lous to "undo hard word wrap" by removing \n characters.
See:
Undoing Hard Word Wrap (removing \n)
Subject: Re: Some macro/regex help needed
Date: Tue, 20 Nov 2001 10:51:58 +0100 (MET)
From: Joachim Lous
Reply-To: discuss@nedit.org
To: NEdit <discuss@nedit.org>
On Mon, 19 Nov 2001, Michael Collette wrote:
> Aside from this just being kinda messy, it still has one outstanding bug.
> It's unable to clean up spaces to the left of text on the very first line.
> For everything past the first line it cleans up the text pretty well.
>
> Anyboy have a nicer way of doing this?
Well, just as messy, but fixing your problems:
Use $ and ^ for what they're worth, rather than \n. Also always use
double escapes (\\) in regexes in macros, since there are two rounds
of escape processing: one for parsing the literal code to a string and
one more when parsing the string as a regex. (This is just the sort of
thing I'd like my single-quote patch incorporated for)
So you end up with something like:
# Remove all extra spaces to the left
replace_all("^\\s*", "", "regex")
# Change blank lines to @@@@@
replace_all("^$", "@@@@@", "regex")
# Remove all line feeds
replace_all("\\n", " ", "regex")
# Now go back and replace any @@@@@ with dbl line feeds
replace_all("@@@@@", "\\n\\n", "regex")
# Clean up extra blank space to the right and left of text
replace_all("^\\s*", "", "regex")
replace_all("\\s*$", "", "regex")
If you don't need to handle indented paragraphs you can replace the
first two comands with:
replace_all("^\\s*$", "@@@@@", "regex")
Joachim Lous
Contributors
- () TWikiGuest - 2012-05-28
- If you edit this page: add your name here; move this to the next line; and if you've used a comment marker (your initials in parenthesis), include it before your WikiName.
Page Ratings