Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft Word / Outlook trims leading space

I send SQL to interested parties via Outlook as HTML, with Word as the editor.

I like to format my SQL using spaces, rather than tabs.

When I paste the SQL into the editor, formatting is spot on. But the 'sent' version removes leading spaces.

For example:

Select
 *
From
 Employees

becomes

Select
*
From
Employees

Is there an option to prevent this?

like image 308
Bill Roberts Avatar asked Mar 18 '15 16:03

Bill Roberts


People also ask

What is leading space in Word?

Leading is a typographical term referring to the vertical space from the same point on one line to the same point on the next, within the same paragraph. Typically, this distance is measured from baseline to baseline, where the baseline is the reference line on which your characters rest.

What is smart paragraph selection in Outlook?

Use smart paragraph selection Select this option to select the paragraph mark when you select a whole paragraph. If you include the paragraph mark when you cut and paste a paragraph, you don't leave a blank paragraph, and your formatting automatically stays with the paragraph.


1 Answers

I didn't find solution but found workaround - to replace all (and only) leading spaces to Nonbreaking Spaces. No needs to replace all ever spaces, only leading ones. This way Outlook will not trim them automatically while sending email.

Before send an email need to

  1. select the text, you want to keep leading spaces, and run Find and Replace (Ctrl+H)
  2. put into Find what: "^p " (caret, p, space) or click at the bottom [Special] button and choose Paragraph Mark and just a space character
  3. put into Replace with: "^p^s" (caret, p, caret, s) or click at the bottom [Special] button and choose Paragraph Mark and Nonbreaking Space
  4. now press [Replace All] - it will replace leading spaces with Nonbreaking Spaces only in selected text, leaving all the rest text unchanged.

Result with leading spaces:

First without leading spaces
One leading space in this row
No leading spaces again
One leading space in this row
  Two leading spaces here
One leading space in this row
No leading spaces again
One leading space in this row
  Two leading spaces here
  Two leading spaces here
One leading space in this row
  Two leading spaces here
  Two leading spaces here
   Three leading spaces here

With leading nonbreaking spaces:

First without leading spaces
 One leading space in this row
No leading spaces again
 One leading space in this row
  Two leading spaces here
 One leading space in this row
No leading spaces again
 One leading space in this row
  Two leading spaces here
  Two leading spaces here
 One leading space in this row
  Two leading spaces here
  Two leading spaces here
   Three leading spaces here
like image 113
Kostas Grin Avatar answered Sep 29 '22 05:09

Kostas Grin