Reputation: 193
I want to keep a record of code I am working on by saving it in MicroSoft Office OneNote. When I copy and paste the code, all the indentations are gone.
def primeGenerator(primeList1, arr):
for i in range(2, len(arr)):
if arr[i]==0:
primeList1.append(i)
for j in range(i**2, len(arr), i):
arr[j] = 1
Code shown above becomes like this
def primeGenerator(primeList1, arr):
for i in range(2, len(arr)):
if arr[i]==0:
primeList1.append(i)
for j in range(i**2, len(arr), i):
arr[j] = 1
I tried the solutions I found on the internet like
Upvotes: 3
Views: 5946
Reputation: 11
There is an extension for Onenote where you can copy your code into onenote and format it in onenote:
NoteHighlight -> C# for my example
It can be found here: https://github.com/elvirbrk/NoteHighlight2016
Upvotes: 0
Reputation: 184
One and only easy solution.
Copy the code from VSCode and Paste it in Word file
Next copy the code from the Word file to ONENOTE.
And you will keep the code format.
Upvotes: 2
Reputation: 334
On Windows
Editor: Insert Spaces
to checked.\n\n
\n\n\n
Seems to be a bug in the copy paste of LF / CRLF defined text to OneNote.
Upvotes: 0
Reputation: 11
I would advise against using Keep Source Formatting in OneNote under Settings. I just notice that when Copying from Visual Studio Code into OneNote, OneNote replaces all space charactes (0x20) with NonBreak Space (0xA0).
To recreate the problem, copy something from VSC, and paste it here. Then Paste it into OneNote. Then copy from OneNote, and paste it back in that same link. You will see that all the spaces (0x20) has been turn into NonBreak Space (0xA0), which Visual Studio Code does not like (CSS, JS, etc).
Instead use Keep Text Only
Upvotes: 1
Reputation: 182076
There is a OneNote Settings/Options/Paste Options/
Make sure that is set to Keep Source Formatting
.
My pastes into OneNote retain indentation and syntax highlighting (I have Editor: Copy with Syntax Highlighting
enabled).
Upvotes: 2
Reputation: 31
It isn't supported natively, however there are open source workarounds such as: https://github.com/elvirbrk/NoteHighlight2016
Upvotes: 2