Reputation: 889
This is how the code is copied to onenote with paste option : keep source formatting
If I select paste option : "keep text only", the indentations are preserved (and syntax highlighting is gone as expected)
If I copy the code to word with paste option : keep source formatting, it is copied perfectly preserving both indentation and syntax highlight.
Why is indentation lost in oneNote only?
Office version - 2013
VS code version - May 2017 (version 1.13)
OS - Windows 10 Pro
Upvotes: 5
Views: 2224
Reputation: 530
You can use Outlook email or Microsoft Word as a placeholder.
Steps:
Upvotes: 4
Reputation: 759
If you copy fourspaces fourspaces
from vscode to onenote
,onenote will show fourspaces fourspaces
The code fourspaces fourspaces
in vscode is stored at clipboard like this
<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 ignore spaces, but tab are formatted to  
One solution is convert all indentation to tabs in your file
Generally, you could add "editor.insertSpaces": false,
in your user setting;
VSCode - How do I set tab-space style?
Or there is a vscode plugin named S.T.O.N.E, you can use it.
Upvotes: 3
Reputation: 8676
As mentioned by @rambler OneNote ignores pasted spaces, the solution is converting all spaces to tabs in your document using:
ctrl+shift+p
then enter
convert indentation to tabs
now you can copy your code without problem,
if you want to make the tab indentation default you can change the setting by going to preferences and adding the following line:
"editor.insertSpaces": false,
Upvotes: 3