Reputation: 15324
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 to Word, copy from Word, and then paste to OneNote.
Upvotes: 57
Views: 51855
Reputation: 531
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.
Upvotes: 38
Reputation: 1764
I just view the code on the website of my repository of choice and copy from there. Then paste to OneNote with keep source formatting.
Upvotes: 1
Reputation: 21
The best way of keeping the format of your code completely is constituted from two steps:
Upvotes: 2
Reputation: 15685
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.
Upvotes: 45
Reputation: 23
I just figured out a workaround to do this without any plugins.
PS: I have tried in macOS it works fine
Upvotes: 1
Reputation: 472
NoteHighlight will do the trick. I found it through the following blog post, codefoster.
Upvotes: 4
Reputation: 43
Well , sorry for replying late, I know it's very old post. But , it might help to one who is trying to find it out solution for above said question. I found none to work for me even OneNote 2016, but here it is very easy way to do.
Just copy your code and paste it to wordpad.exe it suppose to paste with formatting and colors. Save *.rtf file and open it in Ms Word , from there you can copy/paste any document in word, it worked for me.
Upvotes: 2
Reputation: 615
Try this elegant solution directly from Microsoft: Productivity Power Tools 2015
The HTML copy-paste works nicely with OneNote.
Upvotes: 2
Reputation: 1888
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)
Upvotes: 1
Reputation: 29981
The GEM OneNote addon has a syntax highlighting feature -> http://www.onenotegem.com/blog/onenote-insert-highlight-syntax-source-code
Upvotes: 1
Reputation: 61
For Visual Studio 2008 ---- http://blogs.msdn.com/b/johnguin/archive/2010/11/29/an-addin-to-help-visual-studio-users-with-moving-code-to-onenote.aspx
Upvotes: 6
Reputation: 4326
There is an add-in for Microsoft Visual Studio that allows you to copy source code, syntax highlighting, and line numbers as HTML.
With this add-in, you can copy from VS and paste HTML directly to your target.
Check it out here: CopySourceAsHtml
Upvotes: 4
Reputation: 63126
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.
Upvotes: 22