即使保留语法突出显示,将代码从Visual Studio代码复制到OneNote也会丢失选项卡缩进

问题描述 投票:3回答:2

这是使用粘贴选项将代码复制到onenote的方法:保持源格式化enter image description here

如果我选择粘贴选项:“仅保留文本”,则会保留缩进(并且语法突出显示已按预期方式消失)

enter image description here

如果我将代码复制到带有粘贴选项的单词:保持源格式,它会被完全复制,同时保留缩进和语法高亮.enter image description here

为什么只在oneNote中丢失缩进?

办公室版本 - 2013年

VS代码版本 - 2017年5月(版本1.13)

AS - Ondos 10 Pro

visual-studio-code onenote
2个回答
2
投票

正如@rambler提到的OneNote忽略粘贴的空格,解决方案是使用以下方法将所有空格转换为文档中的选项卡:

ctrl+shift+p

然后进入

convert indentation to tabs

现在您可以毫无问题地复制代码,

如果要使选项卡缩进默认,可以通过转到首选项并添加以下行来更改设置:

"editor.insertSpaces": false,


1
投票

如果您将  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忽略空格,但制表符格式化为&nbsp;&nbsp;&nbsp

一种解决方案是将所有缩进转换为文件中的选项卡

通常,您可以在用户设置中添加"editor.insertSpaces": false,in; VSCode - How do I set tab-space style?

或者有一个名为S.T.O.N.E的vscode插件,您可以使用它。

© www.soinside.com 2019 - 2024. All rights reserved.