Thursday, January 29, 2015

Paste SQL (and other) text into OneNote 2013 with syntax highlighting (really)

I've been searching for a way to get SQL scripts into OneNote while retaining syntax highlighting from SSMS for a long time now. It's seems unnecessarily hard: OneNote doesn't support RTF-formatted text from the clipboard, which shouldn't be a problem, since it *does* support HTML-formatted text. Unfortunately, its HTML rendering seems to lack support for the <whitespace> tag. 

So pasted text doesn't generally work right.

Lots of folks use MS Word as a go-between, which makes the text look right, but Word uses the NBSP (non-breaking space) character for many of the spaces, which SSMS doesn't like at all.

Here's the best option available, I think, for OneNote 2013:  http://notehighlight2013.codeplex.com/.  I've used it, and it's just like the NoteHighlight 2010 plug in, with the advantage that the installer is in English.  I love this, and I'm grateful to smsmith0 for porting this.

It also appears that Outlook handles things differently, so it mostly works using an Outlook email body as an intermediary for your pasted text from SSMS.  NoteHighlight is better.


7 comments:

  1. Thanks, was driving me crazy having to reformat the code on every copy paste.

    ReplyDelete
  2. Peter E, NetherlandsSeptember 24, 2015 at 9:22 AM

    How I would have kept struggling not knowing this sends shivers up my spine ! Tested it once > it worked perfectly > bookmarked this page > sent you a sincere THANK YOU > Done !

    ReplyDelete
  3. Hey, just to let you guys know, there is a OneNote Syntax Highlighter for Office 2013! http://notehighlight2013.codeplex.com/

    ReplyDelete
    Replies
    1. Oh, dang: this is fantastic. Thanks for the heads-up.

      Delete
  4. Replies
    1. Hi, John,
      There is a 64-bit download for Notehighlight2013 (see http://notehighlight2013.codeplex.com/releases/view/615734). I've not tried it, as my Office install is 32-bit, but I suspect it'll work.

      Delete
  5. 32 bit 2013 version worked for me on Onenote 2016, it doesn't appear under the Insert tab, it has its own tab called NoteHighLight.

    ReplyDelete

Thanks for leaving a comment!