I use OneNote to keep track of useful coding resources and templates in R and Python. This is not usually a problem but I am having difficulty typing any code with indices containing double square brackets e.g.

df.iloc[[0, 12]]

instead of just displaying the code, OneNote interprets this as a command to create a new page called "0, 12" and then links to this new page and removes the square brackets from the code.

I have tried right clicking and selecting "remove link" but this also removes the square brackets and does not delete the created page.

Is there any way to turn this functionality off so it just lets me type in double square brackets without creating a new page?

  • I don't see any way around the double quotes (that is a One Note way of interpreting things). Single quote however works just fine if you can adapt to this
    – John
    Feb 13, 2020 at 16:47
  • idk onenote, but \ is often used as an escape character, so df.iloc\[\[0, 12\]\] might do it.
    – Tetsujin
    Feb 13, 2020 at 17:24

1 Answer 1


Easy: just Undo (Ctrl+Z) immediately after creation of the link

Type df.iloc[[0, 12]] and then press Ctrl+Z. Your text is back.

...or produce ]] using the Paste command

Put ] or ]] into the clipbard and then use Ctrl+V (Paste) to produce it.

...or do not enter the link at once

Type df.iloc[[0, 12] ] (with space between right brackets) and then return and remove the space. This avoids triggering of the link creation.

...or paste the entire part of the code from the clipboard

Put df.iloc[[0, 12]] or bigger portion of your code into Notepad and then paste it into the OneNote.

...or use something unique and then mass-replace it

In longer texts, just use ]@] instead of ]] and when finished, perform find/replace of ]@] back to ]].

Tested with OneNote which comes with Office 365 in March 2020.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.