Is it possible to copy code from Visual Studio and paste formatted code to 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
You have hit the nail on the head on the process. The application that you are pasting to must be able to accept the code with the formatting properly. MS Word is one of the few that handles this properly, therefore, going from VS -> Word -> OneNote will work. But VS -> OneNote doesn't work.
This is an option that seems to be disabled by default.
To enable (in VS 2019):
Go to
Tools -> Options
type copy in the search box
Under
Text Editor -> Advanced
...Check Copy rich text on copy/cut
Top copy as formatted
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.