Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

How to print a file from VsCode?

Writer Andrew Mclaughlin

I want to send the file I'm currently editing to a printer, like I did in Notepad++ for example. I havn't found any hint on a print command. Is it not possible ?

2

7 Answers

It is not yet available, but I found an issue report for that feature.

It's currently in the backlog, so we can expect it soon.

Edit: In the meantime:

3

Now you can install addon for VS Code - search "PrintCode".

Note that the repository for this extension was last updated in February 2018 with numerous issues outstanding.

3

I found the PrintCode extension inspiring but unfinished and with a number of flaws. In particular it depends on a specific paper size to wrap and as a result does not respond well if you change paper size or orientation in the print dialog.

It's open source so I looked at the code and didn't like that either. No programmer ever likes another's coding style. So I pinched the idea of using a web-browser as platform driver for HTML printing -- my hat is off to the PrintCode author for that cunning insight -- and wrote my own.

In the process I fixed all the known bugs, added everything on my wishlist and a couple of things suggested by others. The biggest thing was figuring out the CSS required to respect print dialog paper size and orientation. This also sorts out the mysterious disappearing line numbers problem, although I'm not sure why. The next biggest thing was learning to probe for an unused port, a problem that also afflicts PrintCode causing the browser to open showing no content.

Major issues

  • PrintCode depends on a web service. You can't use it offline.
  • Many people want to be able to open a file, select a portion and print just the selection.
  • The print dialog supports changing paper size and orientation. This clashes with the way PrintCode works.
  • Some people like to run multiple VS Code windows.
  • When you print a markdown file, you probably don't want it printed like a text file when it can be rendered with fonts and proper headings and bullets etc.
  • Support is required for remote workspaces.

Because each instance of VS Code needs a different port for its embedded webserver, you can't just use a setting. Dynamic port allocation is necessary.

Remote workspaces weren't even a thing until two years after maintenance ceased on PrintCode.

If you want to survey your options, get onto , choose the Visual Studio Code tab and search for printing.

If you just want a link to my version, it's here .

If you like what you see but need something I haven't thought of, the marketplace page has a link to the repo on github. Create an issue and tell me what you need -- or write it yourself and submit a PR.

5

Now there is an extension available for printing from the VS Code Editor. It's called VS Code Printing Free. I've tried it for a couple of days and it works fine.

2

Poor man's answer: Copy code to Notepad2 or Notepad++ and print from there. The colour coding will be different though

You can use an Extension of VS Code: PrintCode

  1. Install extension PrintCode
  2. On Mac: command + shift + P
  3. choose command> PrintCode

I have modified the . If you change the values that I have marked in the picture in the extension settings a browser tab opens with the you can then print this also works on the Ipad. It works also with the code-server Version inside a Docker Container. I put the file on github

enter image description here

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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