Microsoft OneNote is an incredible one-program solution for taking notes, but it isn't very good for jotting down bits of code. If you want features like syntax highlighting and code formatting, you need an add-on like NoteHighlight2016 for OneNote.
NoteHighlight2016: Syntax Highlighter for OneNote
NoteHighlight2016 is an open-source add-on for OneNote (2016 or later and Microsoft 365) that lets you insert formatted code into OneNote pages. To download NoteHighlight2016, go to the releases page and look for NoteHighlight2016.msi under Assets (use the x86 version if you’re using 32-bit OneNote).
After installing NoteHighlight2016, just restart OneNote and you’ll find a new tab at the top titled “NoteHighlight.” Clicking on this tab will open a configuration menu showing you all of the supported languages, which include C, HTML, CSS, Python, SQL, PHP, Java, JavaScript, and more.
Add Code Blocks in OneNote With NoteHighlight2016
Storing code blocks in OneNote with NoteHighlight2016 is simple. To start a new code snippet, click on the NoteHighlight tab and select a language. In the pop-up window that appears, paste your code and click OK. You will see your highlighted source code appear.
Afterward, you can change the code style and choose a Box Color to surround the code. You can also make other edits to the code within the pop-up window, which essentially acts as an intermediary.
Unfortunately, you can only make changes to code blocks you've written by deleting them and repeating the process. Despite this limitation, edits are still easy because you're inserting reusable text rather than a screenshot where text can't easily be altered.
Before clicking 'OK' to save your new code snippet, you should click the checkbox for 'Copy to Clipboard(C)' so that you can insert your code by pasting it.
OneMore: Increase the Functionality of OneNote
OneMore is a free add-in for OneNote (2016 or later and Microsoft 365) that integrates with the ribbon, context menu, and keyboard shortcuts to provide you with several features to increase the functionality of OneNote. With OneMore, you can create and edit custom styles for text, manage a menu of favorites to give quick access to referenced pages, save and reuse custom snippets, add formulas to table cells, use many cleanup commands, and apply colorized syntax highlighting to snippets of source code.
To add OneMore to OneNote, head to the OneMore releases page and look for OneMore_[Version Number]_Setupx64.msi under Assets. “4.18” is the version number, and “Setupx64” means you’re downloading the 64-bit version of the add-in.
The OneMore add-in stores its settings as XML files in the "%AppData\Roaming\OneMore" directory. Once OneMore is successfully installed, you'll see the More button in the Home tab in OneNote. For convenience, you can add OneMore to Quick Access Toolbar before continuing.
You should download the 'x86' version of OneMore if you want to insert code in an older 32-bit version of OneNote.
Writing Code in OneNote With OneMore
As with NoteHighlight2016, writing code blocks in OneNote with OneMore is surprisingly simple. You can start by inserting a code box with Home > ... > Snippets > Code Box and then pasting your text inside.
To apply color formatting, you can navigate to Home > ... > More > Colorize and choose a language from the list of options. The syntax highlighting offered by OneMore isn't as comprehensive as what you'll usually find in code editors, but it gets the job done.
The languages that OneMore supports colorization of include C#, C++, CSS, HTML, JavaScript, Python, and SQL. You can also use the built-in formatting options in OneMore to change the spacing between your lines of code, convert your code to lowercase, or even search for and replace specific snippets within the code.
OneMore isn't quite as versatile as NoteHighlight2016 when it comes to the formatting options it offers, especially in terms of colorization styles. Still, it's a great option if you're looking for an all-purpose tool that can also format code blocks in OneNote.
Whether you end up using NoteHighlight2016 or OneMore with OneNote, these add-ons will let you format and highlight your code easily, without much configuration. With that kind of convenience, you'll find that studying programming becomes much easier.