Reputation: 15097
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 ?
Upvotes: 133
Views: 128052
Reputation: 39
Install the "print" extension, then right-click and choose print.
The "printCode" extension is deprecated.
Upvotes: 0
Reputation: 15097
It is not yet available, but I found an issue report for VS Code for that feature.
It's currently in the backlog, so we can expect it soon.
Support to print the editor contents #5953
Edit: In the meantime, you can use this extension:
Upvotes: 80
Reputation: 18739
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.
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 Visual Studio Marketplace, 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.
Upvotes: 26
Reputation: 2556
PrintCode has been deprecated. We can now use Print extension which include a nice icon button on the file, which generates the code output with file name and line numbers, which are neat.
Upvotes: 2
Reputation: 1
I have modified the https://marketplace.visualstudio.com/items?itemName=pdconsec.vscode-print. 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 https://github.com/chrishdx/vsc-print
Upvotes: 0
Reputation: 129
You can use an Extension of VS Code: PrintCode
Upvotes: 0
Reputation: 561
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.
Upvotes: 46
Reputation: 93
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.
Upvotes: 7
Reputation: 119
Poor man's answer: Copy code to Notepad2 or Notepad++ and print from there. The colour coding will be different though
Upvotes: 5