Stuff that occurs to me

All of my 'how to' posts are tagged here. The most popular posts are about blocking and private accounts on Twitter, also the science communication jobs list. None of the science or medical information I might post to this blog should be taken as medical advice (I'm not medically trained).

Think of this blog as a sort of nursery for my half-baked ideas hence 'stuff that occurs to me'.

Contact: @JoBrodie Email: jo DOT brodie AT gmail DOT com

Science in London: The 2018/19 scientific society talks in London blog post

Thursday 24 May 2012

How to get rid of white space / line breaks in Word

I seem to be on a Words / lines thing at the moment.

Right then, I had a 35 page Word document* which had many paragraphs each separated by four lines of white space (the equivalent of 'enter' having been pressed four times). One line suffices so I sought to find out how to quickly Find / Replace (Ctrl+H) the three extra linespaces with nothing (or I could have replaced four linespaces with one linespace).

@dianthusmed had the answer to my question
It works: ^l^l^l is the string to select three linespaces. The ^ is called a caret.

1. Press Ctrl+H to bring up the Find and Replace menu
2. Type ^l (SHIFT 6 on full-size keyboard and the letter L) three times into the 'Find what' dialogue box, leave the 'Replace with' box blank
3. Click the Find Next button to make sure it's selecting correctly and then Replace to replace - once you're satisfied that all is well click the 'Replace All' and smile as your 35-page document trims itself to 23 pages.

Thanks also to @zeno001 who offered suggestions too and this is also a useful read "Special characters you can use with Find and Replace in Word"

*Technically it's a LaTeX document that I'm viewing in Word. Ironically I can't compile the 'tex doc into a pretty thing to read because there are other files (bibliographies) embedded into the doc that it needs to run and I don't have access to them. So this was my workaround, but I like saving paper when printing.

4 comments:

  1. While deleting all occurrences of three line break characters would work well on a consistently formatted document it will miss any 2 consecutive line breaks. Worse still, when only 3 breaks occur it will delete them all causing two lines to be concatenated.

    A more general solution, for less well behaved documents, would be to replace 2 breaks with 1 and then repeat until no more replacements occur.

    This also works with any other repeated character that needs reducing to singular occurrences. I regularly use this to remove excess spaces from text that has been justified using them. You might also want to replace tab characters with spaces first before reducing their number.

    ReplyDelete
  2. I just used this again to make a note of all the tweets sent by and to @chi_med (work account). There are sufficiently few that it's worth copying and pasting them, first into notepad to get rid of all the pictures and formatting - I'd not recommend pasting them straight into Word as there's a lot of other stuff that comes with each tweet - and then paste the 'lite' version into Word. At that point there are massive paragraph breaks (in blocks of eight, so I replaced ^p^p^p^p^p^p^p^p with ^p (that's [Shift+6] and the letter p, on a PC keyboard, shift6 is the caret symbol) and that worked to reduce 55 pages to 39, after which it got a bit more manual.

    ReplyDelete
  3. I also managed to get rid of blocks of three paragraph breaks which had an extra character in. Using ^p^s^p^p didn't work (where ^s = space) but I found you can use ^? for 'any character' so ^p^?^p^p worked.

    I knew where to put the ^? because I clicked on that backwards P icon on Word which shows you all the spaces/linebreaks / parabreaks - it's called a pilcrow ¶ (written with Alt+0182 using the numeric keypad).

    Now down at 13 pages :)

    ReplyDelete

Comment policy: I enthusiastically welcome corrections and I entertain polite disagreement ;) Because of the nature of this blog it attracts a LOT - 5 a day at the moment - of spam comments (I write about spam practices,misleading marketing and unevidenced quackery) and so I'm more likely to post a pasted version of your comment, removing any hyperlinks.

Comments written in ALL CAPS LOCK will be deleted and I won't publish any pro-homeopathy comments, that ship has sailed I'm afraid (it's nonsense).