Is there a way to copy code from visual studio (C#) and paste it into OneNote, without losing the formatting?
I was able to do this, but only if I copy from VS, paste
NoteHighlight will do the trick. I found it through the following blog post, codefoster.
Try this elegant solution directly from Microsoft: Productivity Power Tools 2015
https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProductivityPowerTools2015
The HTML copy-paste works nicely with OneNote.
There is fortunately a solution for Visual Studio 2010! Install the Visual Studio 2010 Pro Power Tools extension and copy/paste to OneNote retains syntax highlighting. Made me a happy man;)
Jan Roelof
This is an option that seems to be disabled by default.
Go to Tools -> Options
type copy in the search box
Under Text Editor -> Advanced
...
Check Copy rich text on copy/cut
Once the feature is enabled, depending on the target, this may be a two-step process. If, after copying and pasting code, it still appears as unformatted (e.g. if pasting into a web browser), use the approach suggested by marcus, by first pasting into wordpad.exe (start -> run ->
type wordpad
), then copying the text from within Wordpad again, and pasting into the target application/browser.
Notehighlight supports syntax highlighting for : C#, SQL, CSS, JS, HTML, XML, JAVA, PHP,Perl, Python, Ruby, C++
They have release a port has been release compatible with OneNote 2013 (Also happens to work with OneNote2016)
I just figured out a workaround to do this without any plugins.
PS: I have tried in macOS it works fine