Forum Discussion

alex-franco's avatar
alex-franco
Brass Contributor
Jun 22, 2021

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! 

24 Replies

  • gkbrenne's avatar
    gkbrenne
    Copper Contributor
    I 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
  • marcvanbreemen's avatar
    marcvanbreemen
    Copper Contributor
    For 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.
    • hifeinstein's avatar
      hifeinstein
      Copper Contributor

      If you want the code to visually look like an isolated code block in-line with other notes in the same text box, select the pasted code and insert a 1x1 table.  Clunky, yes but it’s a decent workaround for isolating code blocks similar to how other note taking apps do it.  Add shading and it really pops. 

      • bbetnar's avatar
        bbetnar
        Copper Contributor

        The 1x1 table is actually a genius workaround. Extremely quick and simple. Clever thinking. Thanks!

Resources