Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy code from vscode to OneNote without losing the formatting?

I want to keep a record of code I am working on by saving it in MicroSoft Office OneNote. When I copy and paste the code, all the indentations are gone.

def primeGenerator(primeList1, arr):
    for i in range(2, len(arr)):
        if arr[i]==0:
            primeList1.append(i)
            for j in range(i**2, len(arr), i):
                arr[j] = 1

Code shown above becomes like this

def primeGenerator(primeList1, arr):
for i in range(2, len(arr)):
if arr[i]==0:
primeList1.append(i)
for j in range(i**2, len(arr), i):
arr[j] = 1

I tried the solutions I found on the internet like

  1. convert indentations to tabs in vscode
  2. copy the code first in MS Word then in OneNote.
like image 320
Atulya Jha Avatar asked Oct 25 '25 01:10

Atulya Jha


1 Answers

It isn't supported natively, however there are open source workarounds such as: https://github.com/elvirbrk/NoteHighlight2016

like image 94
M.McMoran Avatar answered Oct 26 '25 23:10

M.McMoran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!