A simple way to Code Syntax HIghlight...No extension required !
I was searching for any extension that can help me format my code on my OneNote Mac, but I failed. Now finally I discovered a way to do it.
If you want to paste a code from any source into your onenote with all the syntax and formatting highlight intact, heres a simple solution.
Here's the trick:
Visit the stack overflow site and in the reply section, paste your code in the CODE block, after this stackoverflow will show you the preview of your code in Syntax highlighted manner.
Now just code from the preview and paste in OneNote.....DONE !!
OneNote now shows the exact code snippet as that of the StackOverflow after pasting.
This worked for me, hope this helps.
Roberto Fernandez commented
The thing is I don't just use Visual Studio to have code snippets. I also code for embedded systems with multitude of IDEs. I need a centralised place to keep code snippets as well as general constructs that I find on the internet.
Ideally OneNote should support Markdown - e.g. if you do something like below, OneNote should automatically detect this as code and format it correctly. See https://onenote.uservoice.com/forums/245490-onenote-developer-apis/suggestions/8088735-markdown-support-right-from-onenote-just-like-the
James Salisbury commented
To get the syntax and highlighting you can install productivity power tools extension(I know its an extension but it takes 5 seconds to install) in visual studio. Once installed in VS editor go to ->Tools->Options->Productivity Power Tools->Html copy -- there is an option ~ before code snippet with settings you can change like the back ground color if your using the dark theme.
Come on MSFT put this on the road map push for windows development
This is workaround, not solution! And this only shows how Microsoft is lazy in requested feature delivery. I have surface book and i really wanted to use OneNote, but this is game changer for me and onenote never will be anything more than hand drawing app for me, despite having enormous potential to crush competition with recent modern look. I can live without markdown, but I cannot live without code highlights, how can i read my notes if i can't even see the code chunks properly???
Ľudovít Priezviskoo commented
past it to word and copy/past it to onenote, after this it wil have sql formatting.. simple way :-)
Matt Wilkie commented
This is a usuable work around, but I'd much rather use a keyboard combination, similar to Ctrl-Alt-1 for headings and Ctrl-Shift-N for Normal Paragraph.
all this is only considered convenient in the world of microsoft
Sergey Gumenyuk commented
Guys! It have embedded "Code" formatting in Styles. It not highlight a code, but at least not break formatting.
dude. there are much easier ways.
Best for me is Visual Studio Code. It's free. It might be better than onenote for your purposes.
Turn on right text copy/pasting and it'll paste exactly as you see. Colors and all.