Bug 64910 - allow multiline searches
Summary: allow multiline searches
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: 2.1
Platform: openSUSE Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
: 36803 55949 131157 143661 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-09-25 11:40 UTC by Andi Hoeller
Modified: 2008-11-04 18:17 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andi Hoeller 2003-09-25 11:40:21 UTC
Version:           2.1 (using KDE 3.1.1)
Installed from:    SuSE
Compiler:          gcc version 3.3 20030226 (prerelease) (SuSE Linux)
OS:          Linux (i686) release 2.4.20-4GB

both Kate and Kwrite are not able to find newline characters in files on my machine.
no matter if I type in \n into the search field or select 'newline' from the regular express dropdown the result is always a message saying
'Search string '\n' not found!'
(with the regular expression checkbox is checked)
things that DO work are TAB \t, and WHITESPACE \s

the setting of End of Line Mode doesn't influence the result. 
newlines can't be found in files created on Mac, Windows, or Linux
Comment 1 Christoph Cullmann 2003-09-30 21:19:17 UTC
why do you want to find \n ? 
it is not supported, atm, as these chars are not in the buffer, but why to find them at 
all ? you can detect lineend/start via regex, no need for \n, multiline searches not work 
at all atm, that would be a valid reason perhaps 
Comment 2 Christoph Cullmann 2003-10-02 21:09:24 UTC
add it to the wishs, multiline searches would be nice indeed, I guess 
Comment 3 Christoph Cullmann 2003-10-02 21:09:45 UTC
wish :) 
Comment 4 arne anka 2004-01-20 15:21:21 UTC
> why do you want to find \n ?
because automatic wrapping prevents from finding sometimes. looking for "blah bloh" does not match if between blah and bloh a wrap occurs.

mfg
Comment 5 Yves Lavoie 2006-07-18 22:03:05 UTC
Multiline search is a must for programming development issues.
Comment 6 Benjamin Kay 2006-09-04 03:08:15 UTC
Multiline searches would be really helpful for writing code. Pretty much the only time I use vim instead of kate is when I need to do a multiline search.
Comment 7 Tore Ericsson 2006-09-04 18:26:32 UTC
Question: How do you in a simple way replace end-of-line with space in
ADAM
BERTIL
CESAR
DAVID
ERIK
...
in order to produce
ADAM BERTIL CESAR DAVID ERIK ...
This is a trivial and common task in not only programming and easily done in all normally designed editors that recognise end-of-line (written \n, ^p, or similar). And the other way round: To convert space-delimited words into a column is carried out equally simple. -- Please, Kwrite/Kate team!
Comment 8 Matthew Woehlke 2006-09-08 16:44:39 UTC
Tore: the second part of your question is a duplicate of bug 45529. And yes, four years? It's about time this got done!

Since KATE is line-based, I have a suggestion on how to do this. (This assumes 'regular expression' is on; the BOL/EOL matching will be different otherwise and I'm not sure what you would use for the delimiter if not using a regexpr.)

0. Split the expression at all '\n's.
1. If the current split part is not the last one, add '$' to the end.
2. Find the first match (if no match, display dialog as usual).
3. If the current split part is the last one, we have found a match; exit.
4. Make the next split part 'current', and add '^' to the beginning.
5. Repeat step 1 (but continue with 6).
6. If the next line matches the current split part, go to 3.
7. Reset the current split part to the first part and start over at 1.
Comment 9 Dominik Haumann 2006-09-08 17:10:04 UTC
> 0. Split the expression at all '\n's.

^(\n)+$ --split--> ^( and )+$

This will never work. You can not simply split a regular expression.
Comment 10 Matthew Woehlke 2006-09-08 17:22:28 UTC
>> 0. Split the expression at all '\n's.
> 
> ^(\n)+$ --split--> ^( and )+$
> 
> This will never work. You can not simply split a regular expression.


Hmm, good point, you'd have to somehow do this logic in the regexpr 
matcher... but it still might be possible to do something conceptually 
similar (no, it wouldn't be easy or pretty) to do the matching without 
having to do the match against the entire document as one long string.
Comment 11 Dominik Haumann 2006-09-08 18:12:00 UTC
you for example can have a multiline-edit. If line 1 of matches, try to match line 2 etc. This will work and should even be pretty fast.

The other idea was to add an additional interfaces which is character based and not line-based. As kate internally is line based, the character based interface would be very slow I think.
Comment 12 Matthew Woehlke 2007-04-02 20:06:07 UTC
*** Bug 36803 has been marked as a duplicate of this bug. ***
Comment 13 Matthew Woehlke 2007-04-02 20:06:44 UTC
*** Bug 143661 has been marked as a duplicate of this bug. ***
Comment 14 Greg Martyn 2007-04-02 20:56:31 UTC
Bug 36803 mentions that this isn't limited to \n. Also, this isn't only about find, but replace as well.

Microsoft Word's find & replace utility uses escapes like ^p for new paragraph, ^l for linefeed, etc. It might be worth looking at that. It's easier to use than regex, but still lets you specify commonly used whitespace formatting characters.
Comment 15 Matthew Woehlke 2007-04-02 22:50:00 UTC
...but I only see bug 36803 talking about tabs and newlines. Searching for tabs ('\t') already works, and there is already a separate bug (bug 45529 and/or bug 127765) dealing with the ability to use '\n'/'\t' in replace. Maybe the various parts of it are independently duplicates of different bugs, but it still does not report anything new.

I don't want to go the Microsoft way, they don't do ANYTHING consistently. Using '\n' is The Right Way AFAIAC. Anyway there is no such thing as a distinction between a hard break (paragraph) and a soft break (linefeed) in pure text. It's a typesetting distinction. (Unless you count '\n\n' as a hard break, but I just gave the search pattern for that; no need for some new sequence.)
Comment 16 Matthew Woehlke 2007-04-20 22:55:37 UTC
*** Bug 131157 has been marked as a duplicate of this bug. ***
Comment 17 Matthew Woehlke 2007-04-20 22:59:34 UTC
*** Bug 55949 has been marked as a duplicate of this bug. ***
Comment 18 Matthew Woehlke 2007-04-20 23:02:53 UTC
Note: some of the duplicates talk about deleting lines containing certain text (or lack thereof, i.e. blank lines). Assuming 'replace' removes the right text, multi-line find/replace will allow this, but we should be sure to test.
Comment 19 Sebastian Pipping 2007-08-30 23:03:05 UTC
This feature is now implemented in KDE4 trunk. Be sure to search in Escape sequences or in Regular Expression mode. Both now allow multi-line searching.
(For regex the dot ('.') does not match newlines. If you need that search for "(?:.|\n)". The "?:" makes the parentheses non-capturing.)
Comment 20 Maciej Pilichowski 2008-11-04 18:17:41 UTC
There is no option to choose the needed mode, so:
http://bugs.kde.org/show_bug.cgi?id=174281
"continuation" of this report.