Is it possible to copy code from Visual Studio and

2019-03-09 15:55发布

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.

11条回答
beautiful°
2楼-- · 2019-03-09 16:47

The best way of keeping the format of your code completely is constituted from two steps:

  1. In the first step right click the code and click "copy" then paste it in "wordPad"
  2. In the second step copy from "WordPad" to word. enter image description here enter image description here
查看更多
趁早两清
3楼-- · 2019-03-09 16:56

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.

查看更多
在下西门庆
4楼-- · 2019-03-09 16:56

The GEM OneNote addon has a syntax highlighting feature -> http://www.onenotegem.com/blog/onenote-insert-highlight-syntax-source-code

查看更多
祖国的老花朵
5楼-- · 2019-03-09 16:56

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

screenshot image

查看更多
We Are One
6楼-- · 2019-03-09 17:00

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.

查看更多
登录 后发表回答