deleting hard returns

Help! I am wanting to delete hard returns that were placed at the end of
every line of a large document. All I've seen is how to delete a paragraph
(hard) return in a blank paragraph. I'd also like to convert hard returns to
soft returns in a couple places. That is the opposite action of what I've
seen explained elsewhere. Any help would be appreciated.

If your file contains plain text you can "easily" fix that with an advanced
text editor like Notepad2-mod.

However if the text is formatted it requires some LibreOffice function that
I'm not aware of but would be interested to learn :slight_smile:

Anyone?

Help! I am wanting to delete hard returns that were placed at the end of
every line of a large document. All I've seen is how to delete a paragraph
(hard) return in a blank paragraph.

If by "hard return" you mean Shift+Enter, it's pretty easy:
1. Open find and replace dialog (by default it is Ctrl+Alt+F in LO 3.4).
2. In "More options" check "Regular expressions".
3. Search for "\n" (backslash and n).
4. Click "Replace all" (don't enter any replacement string).

That's it. All hard returns disappear.

I'd also like to convert hard returns
to soft returns in a couple places. That is the opposite action of what
I've seen explained elsewhere.

With "Regular expression" you can search for "\n" and replace it with "\n"
(backslash n again). This will convert hard return to soft return
(if I understand these words correctly).

The tricky part is to tell LO which hard returns you want to delete and which
converted to soft return. I can think of one way:
at beginning of line after hard return you want converted to soft return,
place some character, like "ß" (German scharfes S - if your document isn't in
German, it's unlikely that you have it anywhere in it), and then search for
"\nß" and replace it with "\n". Now search for "\n" and replace it with
nothing in order to delete unwanted hard returns.

HTH.

How do you delete a paragraph in a blank paragraph???

Suggest you learn about regular expressions. You could copy your text
into a text editor (everyone has a personal favourite: jedit).
Standard syntax to remove new lines is:

\n

within any standard 'find and replace' dialogue window in your text
editor. The syntax for regular expressions may not be as extensive in
LO, so read the manual ('list of regular expressions'). Not sure what
you mean by "soft returns" (new line?).

Hi :slight_smile:

I'm surprised there doesn't seem to be an easier way to do find&replace for the paragraph mark!

A text editor is likely to remove all the formatting. One way around might be to open the file as a compressed folder.

It's important to make a back-up copy of the file before starting to play around with this sort of thing! (Just copy&paste the file into the same folder it's already in)

If you saved in docX or Odt then you can open the file with an archive manager or just rename the file-ending from .odt to .zip. Then use the text-editor to edit the file "contents.xml". I don't know how radically you can play around with that file so do a quick test before spending too much time on it.

Many text-editors such as SciTe, gedit, kate and so on allow you to view text as html/css, mxl. Often either in the View menu or on the status-bar at the bottom. Look for where it says "Plain text" and click on that. The text-editor then cleverly works out which parts of the text are coding and colours it = colour coding the xml-coding!

Sorry i couldn't find a more straight-forwards answer!
Apols and regards from
Tom :slight_smile:

Hi :slight_smile:
The \n doesn't seem to work in Writer 3.3.2. But there has to be something like that, some mark to show a hard-carriage return. Knowing what it is would make this easier!
Regards from
Tom :slight_smile:

You have to search using regular expressions. Its in the help files.

Hi Tom and e-letter

I think you both missed step number 2 in Miroslaw's answer

2. In "More options" check "Regular expressions".

Although this is not quite user friendly, it works perfectly and it is good
to know that LO has this feature.

I'm keeping this one on my personal Tips and Tricks list :wink:

Thank you, Miroslaw!

Hi to all,
I use ^p to designate paragraph returns in LO and I think it works in MS Word as well. I have a need to remove blank lines (empty paragraphs) from time to time.
I search for ^p^p and replace with ^p (the ^ (caret) is above the 6 ).
I'm not sure what a 'soft return' is, but to take out the hard return and just let the text flow, I search for ^p and replace with ' ' (one blank) assuming there was no blanks after the . before the hard return. If you need to take out tabs ^t will work.
Bob
Bob Houston eBook Formattinghttp://about.me/BobHouston
http://facebook.com/eBookFormatting

I'd suggest that, before giving advice, people actually try what they are
suggesting.

In OOo and LO, unlike MSO, paragraphs are designated by surrounding the
text with <p></p> symbols (like html). As a result, there is no "paragraph
mark" to search for, and using either ^p or \n in the search field will
give you a "search key not found" error.

On the other hand, if you ended a line with a Shift-enter, no new paragraph
is created. Instead, a \n symbol is inserted into the text. If you enable
regular expressions and put a \n in the find field, the \n will be found
and can be replaced by anything you like (including nothing).

There is no way I've ever found in OOo or LO to use ^p in the search field.
^p works in every version of MSO I've tried, but not in LO.

I verified what I'm saying by actually trying it in LO 3.4.3

jomali

Hi :slight_smile:

I'm surprised there doesn't seem to be an easier way to do find&replace for the paragraph mark!

A text editor is likely to remove all the formatting. One way around might be to open the file as a compressed folder.

It's important to make a back-up copy of the file before starting to play around with this sort of thing! (Just copy&paste the file into the same folder it's already in)

If you saved in docX or Odt then you can open the file with an archive manager or just rename the file-ending from .odt to .zip. Then use the text-editor to edit the file "contents.xml". I don't know how radically you can play around with that file so do a quick test before spending too much time on it.

Many text-editors such as SciTe, gedit, kate and so on allow you to view text as html/css, mxl. Often either in the View menu or on the status-bar at the bottom. Look for where it says "Plain text" and click on that. The text-editor then cleverly works out which parts of the text are coding and colours it = colour coding the xml-coding!

Sorry i couldn't find a more straight-forwards answer!
Apols and regards from
Tom :slight_smile:

I think the problem is that in xml or html you can enter a CR in the <p></p> tag that is ignored when displaying xml/html by a browser to make the text easier to read while editing. The CR may cause other programs to display the text incorrectly because they assume the CR is an editing command that must be obeyed. Xml/html have a tag for inserting a CR (<br />).

Jomali, I stand corrected. And thank you. I receive the documents I work on in MSO '97, work on them in LO, and return as MSO '97 or HTML. Sometimes, at my age, it's hard to remember where I'm at, let alone what editor I'm using. Could also be why the last manuscript I worked on went back to the author with some blank lines still in it. |:>(
I'll put this out, to add to the discussion. I have found that when editing text documents (I use Notepad++) in the extended search mode, \r\n\r\n will find back to back hard returns (CRLF). And I just did test it again. |:>)
Bob

Bob Houston eBook Formattinghttp://about.me/BobHouston
http://facebook.com/eBookFormatting

I know that ^p works in MS Word but it does not work in LO 3.4.3 with regular expression turned on or without.

The help discusses removing the Line break that is entered with the Shift+Enter and replacing with a hard return as if the enter key was pressed but there is no discussion of which regular expression works to find the end of paragraph marker that may be at the end of each line of text copied from a webpage and pasted into a Writer document.

Interesting question.

John McAtee

Hi Tom and e-letter

I think you both missed step number 2 in Miroslaw's answer

The reason for this is that the option is always selected manually! :slight_smile:

2. In "More options" check "Regular expressions".

Although this is not quite user friendly, it works perfectly and it is good
to know that LO has this feature.

Agreed, it would be good if LO saved the option chosen from the last
time the dialogue window was opened (as occurs in a text editor). If
this worthy of a bug notification?

Hi all,

Tom Davies schrieb:

Hi :slight_smile:

I'm surprised there doesn't seem to be an easier way to do
find&replace for the paragraph mark!

Check "regular expressions" in the "More Options" part.
Search for $
Replace with blank
Click on "Replace all"

Kind regards
Regina

Maybe you mean some specific circumstances, but my Writer *does* remember
regular expression checkbox state. If I checked it, it will be checked next
time I open search and replace dialog. It will work even if I shut down LO in
between!

It does not remember search strings, though.

I am using LO 3.4.3 from Debian testing repositories on amd64 machine.

Do you mean $ (dollar sign)?

It is described in online help:
<http://help.libreoffice.org/Common/List_of_Regular_Expressions>.

Hi :slight_smile:
Regina's answer worked for me. Just open the document as normal, not the
messy way i described last time. Then search for $ (= hard carriage
return), That does find the hard-returns. I tried replacing with \n but it
didn't work for me. When i searched for \n it found all the soft-returns
that i had made by using shift&enter
Regards from
Tom :slight_smile:

Regina
 
Thank you.  That was the answer the original poster and I were looking for.
 
John McAtee

Miroslaw
 
The $ did what the original poster was asking for.  The local and online help show the same thing.  I just did not grasp that you could just search for the $ alone.
 
John McAtee