You are not logged in.

Dear visitor, welcome to KDE-Forum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Sunday, February 20th 2005, 1:20pm

Kate Reg. Exp. & Newlines

I'm going insane trying to work out why Kate (KDevelop) ignores the newline character \n in Find/Replace.

I can't add or replace newlines in a Replace operation - a very basic function that I used all the time with Ultraedit edit in Windows. Stripping out empty lines (for example) from a several thousand line file is no fun done manually!

Can anyone tell me a workaround, a way of changing Kates behaviour or give the Kate developer a poke in the eye?

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

2

Monday, February 21st 2005, 1:36pm

I remember a similar question on a KDE user mailinglist.
If I remember correctly the problem is not that it doesn't match newline, but that it cannot replace it with "nothing", i.e. cannot remove it.

You could try using the reg exp on the commandline with sed for now and have a look if you can vote for the respective bug on bugs.kde.org (I am pretty sure there is already one for that)

Cheers,
_
Qt/KDE Developer
Debian User

3

Monday, February 21st 2005, 2:10pm

I'll check the bug-list again, although I failed to find a similar problem listed the last time.

It does definately fail to match a newline though and can quite happily replace a string with nothing. I've replaced other special characters (e.g. Tab) with nothing too - but if you do a search for newline (\n) nothing is found.

wysota

Trainee

Posts: 65

Location: Warsaw, POLAND

  • Send private message

4

Monday, February 21st 2005, 4:24pm

I managed to match the newlines, but I can't remove empty lines. I even tried matching more than one line in a go (with something simmilar to: [^\n][\n]+[^\n]) but I wasn't able to get rid of those empty lines, although that might be the way to do it (in this situation those chars that match [^\n] have to be put back into the text).

The simplest solution would be to match

Source code

1
^\n$
or even

Source code

1
^$
but that won't work :(
Live and let live - use the search engine.
"Use the docs Luke, use the docs!"