Forum Discussion
OneNote - Inserting Code Blocks
Are there any plans for a way to format code blocks in OneNote without inserting a 1 column/row table or an ugly print out? The most relevant Google search brings up a post from 2018 where the top answer says its been requested on UserVoice and directs OP there, but 3 years later, still no code block formatting options and Microsoft isn't using UserVoice anymore so I don't where else I can submit feature requests besides this discussion board.
Thanks!
- marcvanbreemenCopper ContributorFor now you can do this:
Paste your code in Visual Code. Be sure that the language is supported and/or install support for it first (extension). Your code will be color coded.
Then copy/paste ("with format" option) that in OneNote. - gkbrenneCopper ContributorI just tried "OneMore" by Steven Cohn and I'm impressed: https://onemoreaddin.com/get-started/Welcome%20to%20OneMore.htm. This works with OneNote 365 v2306 build 16529.20182
You might also try NoteHightlights 2016 by Elvir Brkić at https://github.com/elvirbrk/NoteHighlight2016 - nclinchIron ContributorMakes me sad. I would like to have a OneNote for all of our IT documents/Notes and most of the time there is code involved.
I can insert Code into Teams... why not OneNote- WOS-MAnthonyCopper Contributor
nclinch, check this out:
Mac: Format > Styles > Code
Windows: Ribbon > Styles > CodeIt's not perfect but it does seemingly remove unnecessary formatting and allow you to paste in and format code blocks.
- JediSQL47Copper ContributorThank you. That does work for a quick and dirty. We'll still need to do the via-Word method if we want to retain the syntax color highlighting. Also, Styles > Code is a paragraph style, so you can't style just a few words within a sentence. I tried via-Word for inline code, and it doesn't work well either.
- asksockCopper ContributorMicrosoft please add this feature.
- THaha2050Copper Contributor
alex-franco when I google the exactly the same question, microsoft community hub is the first one in the google search results, the answer provided is 2 years old and absolutely useless....
- JediSQL47Copper Contributor
Just copy/paste the code to MS Word first. The re-copy the code from Word and paste it to OneNote with "keep source formatting." I have been using this in SharePoint wikis also.
- Charlotte18241Copper Contributor
- Charlotte18241Copper ContributorI think it is only for OneNote on the web though.
- JediSQL47Copper Contributor
Thank you for the update. I can confirm the Loop component in the web version and that they cannot be added via the desktop version. When I add via web, and then view the page with the desktop app, I get this:
- DantoysCopper Contributor
alex-franco The Loop Components feature seems very poorly executed, why does it need to spend 20 seconds online to access the note, another MS attempt to steal our information?
I really like the way this works in cherrytree, I wish it was the same in microsoft. as for installing another program like visual studio, no thank-you. I don't need that beast. I'm not a developer, just need to keep notes on the coding I can do inside some software. If MS ever reads this, please look at other software, and try to make your software more friendly. It was a mission in Microsoft in the early years to make thinks easy to use, now a days it seems they want to make things more difficult. I'm unfortunately stuck with whats available, due to security in my organization. if I get desperate, I can maybe email it to myself, and code fomat/style it on my home computer, and email it back to myself. Why should anyone have to do this? computers are ment to make my job easier not harder, and yet, it just keeps getting harder.. Why M$, Why ??