这是使用粘贴选项将代码复制到onenote的方法:保持源格式化
如果我选择粘贴选项:“仅保留文本”,则会保留缩进(并且语法突出显示已按预期方式消失)
如果我将代码复制到带有粘贴选项的单词:保持源格式,它会被完全复制,同时保留缩进和语法高亮.
为什么只在oneNote中丢失缩进?
办公室版本 - 2013年
VS代码版本 - 2017年5月(版本1.13)
AS - Ondos 10 Pro
正如@rambler提到的OneNote忽略粘贴的空格,解决方案是使用以下方法将所有空格转换为文档中的选项卡:
ctrl+shift+p
然后进入
convert indentation to tabs
现在您可以毫无问题地复制代码,
如果要使选项卡缩进默认,可以通过转到首选项并添加以下行来更改设置:
"editor.insertSpaces": false,
如果您将 fourspaces fourspaces
从vscode复制到onenote
,onenote将展示fourspaces fourspaces
vscode中的代码 fourspaces fourspaces
存储在这样的剪贴板中
<meta http-equiv="content-type" content="text/html; charset=utf-8"><div style="color: #bbbbbb;background-color: #282c34;font-family: Fira Code;font-weight: normal;font-size: 15px;line-height: 20px;white-space: pre;"><div><span style="color: #bbbbbb;"> fourspaces fourspaces</span></div></div>
Onenote忽略空格,但制表符格式化为  
一种解决方案是将所有缩进转换为文件中的选项卡
通常,您可以在用户设置中添加"editor.insertSpaces": false,
in; VSCode - How do I set tab-space style?
或者有一个名为S.T.O.N.E的vscode插件,您可以使用它。