Page MenuHomePhabricator

Find and replace should be able to operate on multiple lines in NWE
Open, LowPublic8 Estimated Story Points

Description

The search and replace tool should be able to work with more than one line at once in NWE, just like it is currently possible in WikiEditor. E.g. replacing \s*\n\*\s* (as regular expression) with , should convert a bulleted list into a simple one-line list with commas. As far as I can see, currently a match must be contained in one line/paragraph.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Given that we currently store lines in the model as wrapped paragraphs, this is not going to be trivial.

Jdforrester-WMF set the point value for this task to 8.
Esanders renamed this task from Search and replace should be able to operate on multiple lines in NWE to Find and replace should be able to operate on multiple lines in NWE.Dec 24 2016, 1:50 PM

This is incredibly frustrating as I've been trying to remove a bunch of terribly formatted citations on Wikipedia (meaning they can't be edited in VisualEditor, where searching for "\n" or "\u000a" would work in matching the line feed character ↵ if it were in text):

image.png (255×759 px, 33 KB)

But none of the following metacharacters match anything in any article:

\n: line feed character
\r: carriage return character
\f: form feed character
\u000a: Unicode for line feed
\u000d: Unicode for carriage return
\u000c: Unicode for form feed
\u0085: Unicode for next line
\u2028: Unicode for line separator
\u2029: Unicode for paragraph separator

Additionally, the multiline modifier, m, cannot be used, because the way the input box is designed is such that you can't place your own modifiers, except through the preset buttons at the side (currently only case sensitivity).

This means I can't find all spaces that come after new lines, which are the problem in this article. Even if there weren't spaces, I couldn't find all pipes after new lines (like you would see in an infobox, but here they're not appropriate). I also can't replace them.

VisualEditor also needs to be updated so that it can actually match new lines and not just ↵'s littered all over the place in rare instances on articles.

This is a relatively significant issue, because it affects the ability to edit basically any badly formatted template or citation. Indeed, as far as VisualEditor goes too, it affects the ability to edit basically anything on any new lines. How are you supposed to quickly find and replace "line feed character in <parameter> at position <number>" warnings (which also do not warn for multiple line feed characters)?

This means I can't find all spaces that come after new lines, which are the problem in this article. Even if there weren't spaces, I couldn't find all pipes after new lines (like you would see in an infobox, but here they're not appropriate). I also can't replace them.

You can use ^\s+ to find all spaces after a linebreak. That probably won't help you much, as merging lines by replacing is not possible, but at least finding something at the start (or end) of a line indeed is possible.

This means I can't find all spaces that come after new lines, which are the problem in this article. Even if there weren't spaces, I couldn't find all pipes after new lines (like you would see in an infobox, but here they're not appropriate). I also can't replace them.

You can use ^\s+ to find all spaces after a linebreak. That probably won't help you much, as merging lines by replacing is not possible, but at least finding something at the start (or end) of a line indeed is possible.

Yes, thank you. But there were a lot, so the replacement functionality would've helped tonnes.