Microsoft Word/Outlook 修剪前导空格

fla*_*Zer 5 html outlook ms-word editor trim

我通过 Outlook 作为 HTML 将 SQL 发送给感兴趣的各方,并使用 Word 作为编辑器。

我喜欢使用空格而不是制表符来格式化我的 SQL。

当我将 SQL 粘贴到编辑器中时,格式是正确的。但是“已发送”版本会删除前导空格。

例如:

Select
 *
From
 Employees
Run Code Online (Sandbox Code Playgroud)

变成

Select
*
From
Employees
Run Code Online (Sandbox Code Playgroud)

有没有办法防止这种情况发生?

小智 4

我没有找到解决方案,但找到了解决方法 - 将所有(且仅)前导空格替换为Non Breaking Spaces。无需替换所有空格,只需替换前导空格即可。这样 Outlook 就不会在发送电子邮件时自动修剪它们。

在发送电子邮件之前需要

  1. 选择要保留前导空格的文本,然后运行查找和替换( Ctrl+ H)
  2. 输入查找内容:( "^p "脱字符、p、空格)或单击底部的[特殊]按钮并选择段落标记和空格字符
  3. 输入替换为: "^p^s" (caret, p, caret, s) 或点击底部的[特殊]按钮并选择段落标记不间断空格
  4. 现在按[全部替换] - 它将仅在选定的文本中用不间断空格替换前导空格,而其余所有文本保持不变。

带有前导空格的结果:

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
Run Code Online (Sandbox Code Playgroud)

具有前导不间断空格:

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
Run Code Online (Sandbox Code Playgroud)