[Solved] Replace linebreak, new paragraph ...

Discuss the word processor
Post Reply
niasilil
Posts: 3
Joined: Sun Dec 09, 2007 8:11 pm

[Solved] Replace linebreak, new paragraph ...

Post by niasilil »

I cannot figure out how to replace "end of paragraph" hidden character with "end of line"+"end of paragraph".
When I choose More options and check regular expressions, and I use "$" for search for and "\n$" for replace with, then it replaces "end of paragraph" with "end of paragraph"+dollar sign.
If I try to replace "end of paragraph" with "end of line" using $ and \n correspondingly, I end up with replacing "end of paragraph" by "end of paragraph".
It is kind of weird.
Can someone help me, please?

PS winXP, Open Office 2.3.1
Last edited by niasilil on Tue Dec 11, 2007 8:31 am, edited 1 time in total.
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: replace linebreak, new paragraph ...

Post by acknak »

I don't understand what you're trying to accomplish. Why do you need the sequence: "end of line"+"end of paragraph"?
AOO4/LO5 • Linux • Fedora 23
niasilil
Posts: 3
Joined: Sun Dec 09, 2007 8:11 pm

Re: replace linebreak, new paragraph ...

Post by niasilil »

Thank you for the interest.
There are number of tasks I want to do, but I do not know how to do them.
For example, if every line of the text ends with a space (or a tab), I want to remove these spaces(tabs). So I go to replace and find space + end_of_paragraph and replace it with end_of_paragraph". This happens when I have a table copy/pasted from a different source. If each line is ending with a space, then I need to remove these spaces to be able to convert the text to a table.
Another example would be to replace a space to end_of_line in selected portion of the text. If I replace a space with a end_of_line, I get end_of_paragraph in the result. I am wondering if it is a bug or a feature. I could not find the answer anywhere.

The question is not "why?", the question is "how?".
User avatar
floris v
Volunteer
Posts: 4422
Joined: Wed Nov 28, 2007 1:21 pm
Location: Netherlands

Re: replace linebreak, new paragraph ...

Post by floris v »

Enter " $" in the Search box (without the quotation marks); $ is a marker for the end-of-line you're looking for. Enter nothing in the Replace by box. First select a few lines and apply it there to make sure it does what you want it to do. :lol: You cannot replace across paragraphs, that's serious limitation of OOo. That means that you can't replace spaces by paragraph ends.
OpenOffice 4.1.11 on Ubuntu; LibreOffice 6.4 on Linux Mint, LibreOffice 7.6.2.1 on Ubuntu
If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar.
Nederlandstalig forum
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: replace linebreak, new paragraph ...

Post by acknak »

OOo's Find & Replace takes a lot of getting used to.
... if every line of the text ends with a space (or a tab), I want to remove these spaces(tabs).
Edit > Find & Replace
Search for: [space,tab]+$ (type an actual space and tab, no comma)
Replace with: empty
Options > Regular expressions = YES
Replace All

The big trick here is "how to type a tab?". In this case, the only way is to copy one from the document text, then paste it in the "Search for" box.

Alternatively, you could use this pattern: (space|\t)+$

In either case, the "$" represents only a position, not an actual character, so there is no need to include it in the replacement. The "Search for" pattern simply matches one or more spaces or tabs at the end of any line.
Another example would be to replace a space to end_of_line in selected portion of the text. If I replace a space with a end_of_line, I get end_of_paragraph in the result.
Short answer: you can't. There is no provision for using a line break in the replacement text[*].

You can do it one at a time, clicking "Find Next" and typing a Shift+Enter (not so great, right?)
I am wondering if it is a bug or a feature. I could not find the answer anywhere.
It's a buggy, incomplete implementation of a design that was never meant for word-processing. Even so, it's very useful once you get the hang of it.

You may want to read the Regular Expressions in Writer How-To.

If you really need to do this a lot, I strongly suggest that you preprocess the text (using good text utilities or a text editor) before it gets into Writer. You may actually need to make simple HTML, since Writer's text import can't distinguish line breaks from paragraph breaks.

[*] I just noticed that, in Linux, I can type a line-break in the "replace with" entry using the Unicode input sequence: Ctrl+Shift+u, a, space. That inserts a U+000a, or ascii linefeed character, which Writer uses as a line break in the text. It may work in Windows using the Alt+010 on the number pad.
AOO4/LO5 • Linux • Fedora 23
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: replace linebreak, new paragraph ...

Post by acknak »

floris_v wrote:You cannot replace across paragraphs, that's serious limitation of OOo. That means that you can't replace spaces by paragraph ends.
Oops. You can replace spaces with paragraph ends (use "\n" in the replacement); you can't replace anything with line-breaks, unless you use the trick I mentioned above.

In the "Search for" pattern, "\n" stands for a line-break. In the "Replace with" text, it stands for a paragraph break. Go figure.
AOO4/LO5 • Linux • Fedora 23
User avatar
floris v
Volunteer
Posts: 4422
Joined: Wed Nov 28, 2007 1:21 pm
Location: Netherlands

Re: replace linebreak, new paragraph ...

Post by floris v »

:oops: :oops: My bad, must have forgotten to hit the regexp checkbox when I tried that.
OpenOffice 4.1.11 on Ubuntu; LibreOffice 6.4 on Linux Mint, LibreOffice 7.6.2.1 on Ubuntu
If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar.
Nederlandstalig forum
huw
Volunteer
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

Re: replace linebreak, new paragraph ...

Post by huw »

acknak wrote:I just noticed that, in Linux, I can type a line-break in the "replace with" entry using the Unicode input sequence: Ctrl+Shift+u, a, space. That inserts a U+000a, or ascii linefeed character, which Writer uses as a line break in the text. It may work in Windows using the Alt+010 on the number pad.
Thanks for posting that.

Is "Ctrl+Shift+u, a, Space" a unicode input method universal to all breeds of Linux?

In Windows I unsuccessfully tried some of the various methods linked here http://www.fileformat.info/info/unicode/char/000a/ - I couldn't test all methods due to not having admin rights to set them up.
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: replace linebreak, new paragraph ...

Post by acknak »

Is "Ctrl+Shift+u, a, Space" a unicode input method universal to all breeds of Linux?
I honestly doubt that there is any feature that is "universal to all breeds of Linux". I guess that's the down side of being so easily modified.

The "Ctrl+Shift+u... space" is part of the Gtk toolkit, so any application that uses the stock Gtk text widgets will provide this method. So Gnome apps provide it; KDE does something different (as far as I know). Unfortunately, the sequence is not standard across toolkits, or interfaces: the Linux text console uses Alt+nnn; emacs provides several other alternatives.

OOo uses Gtk but not the standard Gtk widgets. However, OOo does seem to provide this input method wherever you can type text.
AOO4/LO5 • Linux • Fedora 23
niasilil
Posts: 3
Joined: Sun Dec 09, 2007 8:11 pm

Re: replace linebreak, new paragraph ...

Post by niasilil »

Thank you very much for the answers. It is better now. I can live without having "end of line" in the replace box.
acknak wrote:If you really need to do this a lot, I strongly suggest that you preprocess the text (using good text utilities or a text editor) before it gets into Writer. You may actually need to make simple HTML, since Writer's text import can't distinguish line breaks from paragraph breaks.
The idea was kind of opposite. :) I was trying to migrate from MSOffice to OOo.

I am marking this thread as solved
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: [solved] replace linebreak, new paragraph ...

Post by acknak »

MSOffice is not what I meant by "a good text editor"--neither is Notepad or Wordpad ;-)

Someone else will have to give you a recommendation for a good Windows editor. I use Emacs on Linux, and it runs on Windows and is free, but it's not exactly "friendly".

Here's one example of what I'm talking about: Notepad++[wikipedia.org]. That's just a sample, not an endorsement.
AOO4/LO5 • Linux • Fedora 23
Post Reply