Is it possible to copy code from Visual Studio and paste formatted code to OneNote?

后端 未结 12 1679
时光说笑
时光说笑 2021-01-31 07:53

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

相关标签:
12条回答
  • 2021-01-31 08:18

    NoteHighlight will do the trick. I found it through the following blog post, codefoster.

    0 讨论(0)
  • 2021-01-31 08:19

    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.

    0 讨论(0)
  • 2021-01-31 08:20

    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

    0 讨论(0)
  • 2021-01-31 08:22

    This is an option that seems to be disabled by default.

    To enable (in VS 2019):

    1. Go to Tools -> Options

    2. type copy in the search box

    3. Under Text Editor -> Advanced...

    4. 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.

    0 讨论(0)
  • 2021-01-31 08:22

    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)

    0 讨论(0)
  • 2021-01-31 08:28

    I just figured out a workaround to do this without any plugins.

    1. Insert a table to OneNote with only one cell
    2. Change the shading color of this table to vscode background color, you can use the color picker to pick the bg color of vscode
    3. Choose the code block you want to copy and convert the indent to tab(otherwise the indent will be lost when pasting) reference: https://github.com/Microsoft/vscode/issues/35954
    4. Copy the selected code and paste it into the cell
    5. Change back the code indent of source code to space.

    PS: I have tried in macOS it works fine

    0 讨论(0)
提交回复
热议问题