Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code how to copy colored syntax from terminal

I am running Visual Studio Code on Linux Ubuntu (on virtual machine). The host machine is Windows 10.

Seems VSC for Linux Ubuntu offers some default syntax highlighting for terminal output (at least I do not remember that I have installed any extension for this), as follows: vsc_bash

How to copy terminal output to Microsoft Word/Outlook (on host machine) keeping this colourization and formatting? To copy terminal output I am just using right click mouse and then Copy

like image 729
heniczyna Avatar asked Jun 22 '26 09:06

heniczyna


1 Answers

In v1.66, see the release notes

Copied text retains HTML styling

To copy rich text from the terminal, run the Terminal: Copy text as HTML command or use the terminal context menu entry Copy text as HTML.

BUT the actual command is:

Terminal: Copy Selection as HTML`

You have to select your desired text first and then trigger the command.

It is unbound by default, the command is workbench.action.terminal.copySelectionAsHtml.

You can also right-click and choose Copy as HTML.

copy as HTML in terminal

Note that I have this setting set to default:

Terminal >Integrated: Right Click Behavior

Oddly, vscode's "default" for that setting is copyPaste NOT default ??. I get better results if I actually change that setting to default.

like image 174
Mark Avatar answered Jun 25 '26 22:06

Mark