Backdrop
I was pasting text from a PDF to a LibreOffice Writer doc. At the end of each line is an annoyng space. I had to either a) manually erase those spaces or b) find a better way.
Hopefully this ‘better way’ will help you since it was oddly a bit hard to figure out.
Solution
This post ultimately contained the solution (especially user ‘ajlittoz’ post), but it was pretty hard to read and quickly pull the next steps out. I’m busy and would have preferred a quick tutorial with steps. So this post will be that.
Step 1 – Copy your PDF Text to Clipboard
This should require little / no explaining. Copy text like you know to copy
Step 2 (optional) – Paste text to a Text Editor before Moving to Libre Office
On ubuntu, I always open my Text Editor app, and paste the copied text in there first. This gives me one more level of view of what the paste ‘truly’ looks like since it removes most formatting when you paste, or, exposes it. You could probably skip this step in most cases, but you might also like to make this a habit.
Step 3 – Paste into LibreOffice Writer
If you are coming from optional Step 2 above, copy the text from your text editor (again). Paste into LibreOffice Writer wherever you want it to go. If you are coming from Step 1, paste into LibreOffice Writer wherever you want it to go.
Step 4 – Change View to See Special Characters
This step is helpful so you can see exactly what kind of spaces are now being adjusted. Blue ‘markers’ will show up with a ‘P’ like symbol to show you where your ‘paragraph breaks’ are.
- Go to “View” in menu
- Click the ‘Formatting Marks’ option so there is a check mark
Done. You should now see the blue markers
Step 5 – Semi-Automatically Removing the Spaces
If you have already created some text work in your LibreOffice Writer document, then you need to do this step manually. To be clear, do NOT select all the text in your document and run this over your whole work – it very likely will remove spaces you do not want to. If it happens, though, Control-Z is your friend…
- Manually select / highlight the text block you wish to remove spaces from (likely the block you just pasted in Step 3 above)
- Click ‘Edit’ from the main menu
- Click ‘Find & Replace* – the dialogue box will open
- In the ‘Find’ field, type the dollar sign ($). The dollar sign represents the paragraph break (I guess…)
- In the ‘Replace’ field, type a single space. If you leave this blank (and it’s easy to do since you can’t see it) it will remove the paragraph break and squish it to the word prior – likely not what you want. So just make sure you see your cursor move the single space in the field before executing.
- Click ‘Replace All’ button (this executes on everything within your highlighted text block)
- Click ‘Close’ button on dialogue box to inspect / tweak your work
Step 6 – Revert View to Hide Special Characters
I don’t like the blue markers so it felt nice to quickly turn them off after this was done. Just do the inverse of Step 4 above:
- Go to “View” in menu
- Click the ‘Formatting Marks’ option – this will UN-CHECK the check mark
Done.
Conclusion
Hope you liked it!