C# 是否可以从 Visual Studio 复制代码并将格式化的代码粘贴到 OneNote?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/783187/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to copy code from Visual Studio and paste formatted code to OneNote?
提问by MedicineMan
Is there a way to copy code from visual studio (C#) and paste it into OneNote, without losing the formatting?
有没有办从 Visual Studio (C#) 复制代码并将其粘贴到 OneNote 中,而不会丢失格式?
I was able to do this, but only if I copy from VS, paste to Word, copy from Word, and then paste to OneNote.
我能够做到这一点,但前提是我从 VS 复制,粘贴到 Word,从 Word 复制,然后粘贴到 OneNote。
采纳答案by Jan Roelof
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;)
幸运的是,有一个适用于 Visual Studio 2010 的解决方案!安装 Visual Studio 2010 Pro Power Tools 扩展并复制/粘贴到 OneNote 保留语突出显示。让我成为一个快乐的人;)
Jan Roelof
扬·罗洛夫
回答by Mitchel Sellers
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.
您在这个过程中一针见血。您要粘贴到的应用程序必须能够正确接受格式正确的代码。MS Word 是少数可以正确处理此问题的方之一,因此,从 VS -> Word -> OneNote 运行即可。但是 VS -> OneNote 不起作用。
回答by Lawrence P. Kelley
There is an add-in for Microsoft Visual Studio that allows you to copy source code, syntax highlighting, and line numbers as HTML.
有一个 Microsoft Visual Studio 插件,允许您将源代码、语突出显示和行号复制为 HTML。
With this add-in, you can copy from VS and paste HTML directly to your target.
使用此加载项,您可以从 VS 复制并将 HTML 直接粘贴到您的目标。
Check it out here: CopySourceAsHtml
在这里查看: CopySourceAsHtml
回答by David
回答by charlie hwang
NoteHighlightwill do the trick. I found it through the following blog post, codefoster.
NoteHighlight可以解决问题。我通过以下博客文章codefoster找到了它。
回答by Eric Labashosky
The GEM OneNote addon has a syntax highlighting feature -> http://www.onenotegem.com/blog/onenote-insert-highlight-syntax-source-code
GEM OneNote 插件具有语高亮功能 -> http://www.onenotegem.com/blog/onenote-insert-highlight-syntax-source-code
回答by Des Horsley
Notehighlightsupports syntax highlighting for : C#, SQL, CSS, JS, HTML, XML, JAVA, PHP,Perl, Python, Ruby, C++
Notehighlight支持语高亮: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)
他们已经发布了一个与 OneNote 2013 兼容的端口(也恰好适用于 OneNote2016)
回答by marcus
The best way of keeping the format of your code completely is constituted from two steps:
完全保持代码格式的最佳方由两个步骤构成:
- In the first step right click the code and click "copy" then paste it in "wordPad"
- In the second step copy from "WordPad" to word. enter image description hereenter image description here
回答by Tom A
Try this elegant solution directly from Microsoft: Productivity Power Tools 2015
直接从 Microsoft 尝试这个优雅的解决方案:Productivity Power Tools 2015
The HTML copy-paste works nicely with OneNote.
HTML 复制粘贴与 OneNote 配合得很好。
回答by qbaloch
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.
好吧,抱歉回复晚了,我知道这是很旧的帖子。但是,它可能对试图为上述问题找到解决方案的人有所帮助。我发现即使是 OneNote 2016 也不适合我,但这是一种非常简单的方。
Just copy your code and paste it to wordpad.exeit suppose to paste with formatting and colors. Save *.rtffile and open it in Ms Word , from there you can copy/paste any document in word, it worked for me.
只需复制您的代码并将其粘贴到wordpad.exe它假设粘贴格式和颜色。保存*.rtf文件并在 Ms Word 中打开它,从那里您可以复制/粘贴 Word 中的任何文档,它对我有用。