Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm a programmer. I hate status reports. I found a way to live with it. While I am working in my IDE ( Visual Slickedit ) I keep a plain text file open in one of the file/buffer tabs. As I finish things I just jot down a quick note into that file. At the end of the week that becomes my weekly status report. Example entries:

  The Datatables.net plugin runs very slowly in IE 8 with more than 2,000 records. I   
  changed the way I did the server side code to process the data to make less work for the 
  plugin to get decent performance for the IE 8 users.

  I made a class to wrap data from the new data collection objects into the legacy data 
  holder objects.  This will let the new database code be backward compatible with the  
  legacy code until we can replace it.

  I found the bug reported by Jane.  The software is fine.  The database we use for the
  test site has data that is corrupted in a way it wouldn't be for production site

At the end of the month I go back to each weekly *.txt file and paste all of the entries into a MS Word file for a monthly report. I give the monthly report to a liason to the contracting company who has to compile everyone's monthly reports into a single MS Word 2007 document. His problem, soon to be my problem, comes when he highlights my paragraphs like the ones above to put bullets in front of my paragraphs.

When he highlights my notes to put bullets in front of them with MS Word 2007, Word rearranges the text a bit and the new line chars/carriage returns stagger the text so the text is no longer in neat chunks.

This:

I found the bug reported by Jane.  The software is fine.  The database we use for the
test site has data that is corrupted in a way it wouldn't be for production site

Becomes This:

I found the bug reported by Jane.  The software is fine.  The database we use for 
the
test site has data that is corrupted in a way it wouldn't be for production site

I tried turning word wrap on in my IDE for the text files I put my status notes in. It just puts some kind of newline character in anyway. Searching/Replacing those chars in the text files has the result of destroying the paragraphs.

Once my notes are pasted into MS Word, Word automatically translates them into paragraph breaks. Searching/Replacing them there has similar results. Blank lines separating the notes disappears. One big mess.

What I would like is to be able to keep adding my status notes to a text file as I am now, but do something different when I paste the notes into MS Word such that my liason can select the text, hit the bulleting command and NOT have the staggered text as shown above.

Any ideas?

Thanks much in advance

Steve

share|improve this question
    
Which text editor are you using? It seems to me that you may be hitting the enter key in the text file to keep the text on the screen. Have you opened the text file in VBA and run the characters through to see if they are carriage returns or not? chr(!3) and/or chr(10) –  wbeard52 Jul 7 '12 at 14:56
    
My IDE, Visual Slickedit, is what I am using to edit the text file. I just discovered that it has both "word wrap" and "soft word wrap", the second seeming to have fewer formatting characters. I don't have a windows box at home, but Monday I am going to try "soft word wrap" to see if it leaves the extra newlines/returns out. –  user787832 Jul 7 '12 at 15:17
    
Since in Word anyway, I’d do it by: 1. temporarily replacing paired pilcrows (Replace ^p^p) with something easy to find but not in the text (say zzz) 2. replacing ^p with nothing then 3. resinstating ^p for zzz. (And paired spaces for single as often as required.) –  pnuts Sep 10 '12 at 23:33
add comment

1 Answer

up vote 2 down vote accepted

You are using a single new line for wrapping and double new lines for paragraphs. Word recognises one or more new line as a new paragraph, which becomes a new bullet point. You need to introduce an extra step of manipulation before pasting into Word, where single new lines are removed.

If you can use regular expressions, it's a simple matter of replacing \r\n(?!\r\n) with nothing. This removes new lines (of the CR+LF variety) if they are not followed by another new line, therefore removing single line breaks.1

It has the side effect of reducing multiple new lines by one.2 You can do this with many advanced text editors; pretty much anything that supports Perl Compatible Regular Expressions (PCRE).

For example, in Notepad++:

Screenshot before
Click for full size

Screenshot after
Click for full size


To further tidy things up, you can replace multiple spaces with a single space, by replacing [ ]+ (one or more spaces) with (a single space).


1\r means carriage return (CR), \n means line feed (LF). Windows uses CR+LF for new lines, Linux uses just LF. (?!something) denotes a negative lookahead in PCRE; i.e. it only matches if something does not appear. Also, the lookahead is not included in the match and therefore not replaced, it is only checked.

2(?<!\r\n)\r\n(?!\r\n) will not match/reduce if there's more than one line. It uses the negative lookbehind, (?<!something).

share|improve this answer
    
Wow, thanks for the educational and detailed answer. –  user787832 Jul 9 '12 at 13:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.