Wanna see something cool? Check out Angular Spotify 🎧

Copy Code with Syntax Highlighting from VSCode to PowerPoint

Problem

When preparing presentations with code snippets, I often encounter two annoying issues when copying code from VSCode to PowerPoint:

  1. The copied code includes the background color from VSCode.
  2. The indentation of the code is not preserved.

To better understand the problem, refer to the following images:

Copy Code from VSCode to PowerPoint

Copy Code from VSCode to PowerPoint

Solutions

Let’s address each problem individually:

1. Remove background color

To remove the background color, simply copy the code from VSCode to PowerPoint, select the code, and set the Text Highlight Color to No Colour.

Remove Background Color

2. Preserve indentation (tab, space)

Preserving indentation can be a bit tricky. Although I couldn’t find a direct way to copy code with preserved indentation, I discovered a solution on GitHub. According to vscode/issues/31829#issuecomment-592138395, it used to be possible to preserve indentation in VSCode version 1.39.2, but it stopped working in later versions.

Preserve Indentation

To overcome this, you can download VSCode 1.39.2 and use it specifically when you need to copy code with preserved indentation to PowerPoint. Even on a Mac with an M2 chip, selecting the VSCode Intel version should work fine.

Preserve Indentation

So, the next time you need to copy code from VSCode to PowerPoint, remember these two simple solutions to make your life easier.

Published 19 Jul 2024

    Read more

     — Notion: Rounding to 2 Decimal Places
     — Adding "loading=lazy" to GIF files on my 7-year-old Gatsby blog (with ChatGPT assistance)
     — Angular v17’s View Transitions: Navigate in Elegance
     — Improving Website Performance with Browser-Level Image Lazy Loading (simply add loading="lazy")
     — Enhancing Cross-Document Navigation with the View Transitions API