How do you print in Visual Studio Code?

Category: visual studio visualiaztion

Question

cogaritis on Fri, 12 Feb 2016 19:47:14


The question is simple.  How can you print from within Visual Studio Code?

Replies

Shafiq Abbas on Sat, 13 Feb 2016 12:10:37


Hi,

Console.WriteLine("Text to print");

Thanks, Please mark this answer if helpful.


nigelwright7557 on Sat, 13 Feb 2016 19:51:11


The question is simple.  How can you print from within Visual Studio Code?

Do you mean print to screen or print to a printer ?

k5map on Fri, 17 Jun 2016 18:49:05


I would like to know how to print the program I'm editing with VS Code to a printer

Wayne Molina on Fri, 16 Sep 2016 19:49:55


Apparently microsoft took a page from Sublime Text and decided that actually printing something out is a low priority, outdated use for a TEXT EDITOR.

In short, doesn't look like you can print to a printer at all with it.  But, as some "brilliant" person said on a similar topic for Sublime, just copy it into an editor that can print and print from that!

Hanko Panko on Fri, 09 Dec 2016 23:09:05


Simple answer: Visual Studio Code does not print :(


Hugo Couto on Fri, 24 Feb 2017 22:14:21


In this case I recommend use Notepad++. I have the portable version only to print my codes.

TheCosmicFilament on Tue, 15 Aug 2017 19:16:45


The question is simple.  How can you print from within Visual Studio Code?

If you use google drive, you can right click on the file in explorer and select Google Drive->View on the web and then print it.

John

garyk68 on Sun, 22 Oct 2017 14:24:32


Agreed, this is completely insane

Were the M$ devs smoking something or perhaps just had a common sense bypass?

Saved me the time searching anyway!

supermankelly on Mon, 30 Oct 2017 17:08:28


I need to do this as well. Copy paste won't work as I want to keep the same format, font, colours etc. 

Ken Gregory on Mon, 30 Oct 2017 18:28:38


Agreed, this is completely insane

Were the M$ devs smoking something or perhaps just had a common sense bypass?

I'm sure the money-hungry M$ corporation would happily refund the money you spent on this free product.

ivanarnold on Wed, 08 Nov 2017 20:11:24


So are you suggesting that since the program is free we should all just hold hands and drink the kool-aid when it lacks features that even the most basic text editor on the planet should include?

I like VS Code. A lot. But the lack of a printing functionality is just bone headed and dumb. Since they seem to be following in the footsteps of Sublime and Atom on this I am going to assume that some hipster "modern" web developer made the assumption that since most people use electronic devices no one would ever actually want a hard copy. I expect this from the Sublime and Atom crowd. I also expect the guys at Microsoft to be a little more old school and exercise some common sense.

For those reading this that are fortunate enough to use VS Code on Linux, most Linux distros include the 'lpr' utility by default, which prints to the default system printer. Typical usage is ```lpr <filename>``` or ```lpr filename -o page-ranges=2-6>```

This should work fine from the embedded terminal in VS Code. Might even work on one of those cutesy coffee shop laptops. Not sure if the Jobsians stripped lpr out of OSX.

Joe Cisneros on Wed, 03 Jan 2018 19:20:45


It's insane, but... In Windows, select all text (CTRL+A) and Copy&paste into Word, which retains the formatting.  "Landscape Orientation" and "Narrow Margins" looks best.

scuypers on Sat, 06 Jan 2018 15:33:17


I use an extension.

Its called "PrintCode"

When you have installed it you just have to type "PrintCode" in the command lane (F1) and you will be able to print it out.

R. Mayerik on Tue, 23 Jan 2018 13:43:42


I agree. Nearly all programs have a File -> Print option. I don't understand why I just simply can't print a file in VS Code (you can in Visual Studio 2017).

Microsoft, you missed the mark here!


Mazeppa1 on Wed, 04 Apr 2018 17:08:20


That prints the source. If you need to print the preview (e.g., for a Markdown document) what can you use?

Dan Randolph on Wed, 11 Apr 2018 16:30:55


If you have a different default browser from Chrome, you need to do this in your User Settings to set the printcode.browerPath: 
"printcode.browserPath": "/Program Files (x86)/Google/Chrome/Application/chrome.exe"

FatLarry on Wed, 18 Apr 2018 02:41:28


Did not work for me. The "print" function from PrintCode in Vcode merely opened an empty IE tab.

How the heck do you do that.

Anyway, opened in NP++ and printed perfectly. ---- bizarre font here change after cut/pasting from above. Could it be the PrintCode boys getting revenge?

.

demmith2 on Wed, 18 Apr 2018 17:24:29


Just plain dumb that a print feature is not in Visual Studio Code.

Sir Lorenzo on Sat, 05 May 2018 20:27:59


An extension makes sense to me so that those who don't need this functionality don't have to carry the memory footprint with them everywhere ... lean and mean coding editing machine!

Looknotime on Sat, 15 Sep 2018 15:33:20


I have install on my computer IDLE 3.7. If you open with it you have a print windows option under the File tab or short cut CTRL+P.

hhmaho on Sun, 14 Oct 2018 18:10:02


clone your file in a GitHub repository

open the file in Github and print (right-click)

xxsseert on Wed, 14 Nov 2018 12:03:13


Simple answer - Microsoft have decided not to include this functionality.  Strangely enough, the first thing I wanted to do after installing VSC was print out a few pages of code so that I could read them and spot where my errors were (I can't always spot them on screen, don't ask me why).  So, next time I switch the machine on, the first thing I will be doing is uninstalling VSC...

Edwin Teisman on Fri, 16 Nov 2018 11:43:10


The PrintCode extension mentioned in this thread works for me.
It works best of your default browser is Chome I think.

It is not perfect, for example, it can only print in portrait mode.
But it works well for me.

GaryBauer on Tue, 08 Jan 2019 18:20:20


File Print would be GREAT!

However, change File > Preferences > Color Theme > Light

Copy all, Paste into WORD and print to your printer of choice.

Prasad Nutalapati on Wed, 16 Jan 2019 17:22:26


I did get the same issue though. In my case, the default browser is Chrome on Mac. After seeing empty page, I hit the reload button on the browser. It popped up printer window in portrait mode.

COBaker on Wed, 06 Feb 2019 12:17:57


Wow what a good idea! Copy somebody elses dumb idea.  Reminds me of a movie line "Have IQ's dropped sharply..."  Or how about MS has the "dumbest smart people"... paraphrase

OK I like Sci Fi.  But then again i like to PRINT

Peter Wone on Tue, 02 Apr 2019 03:30:13


I got fed up with the fact that VS Code doesn't support printing and wrote my own printing extension.

Peter Wone on Tue, 02 Apr 2019 03:36:39


Microsoft would say not only is it open source it explicitly supports extensions, and if it actually matters and you aren't just bitching then there's nothing stopping you from addressing the problem yourself.

And they'd be right, so I did, and as a result printing does all the things I care about, like line numbers and syntax colouring and the ability to double space for pencil annotation in a code review.

Here it is. Given the way it works, it should be cross platform but I use Windows so I can't swear to that. Try it out and let me know whether there are any issues on Linux.


Pete


Peter Wone on Tue, 02 Apr 2019 03:41:19


Funny you should say this, I didn't like PrintCode so I wrote my own, and it does indeed have an option to render Markdown when printing it. I've linked to it further up in replies to earlier comments.

Pete


Peter Wone on Tue, 02 Apr 2019 03:48:45


That's caused by the embedded webserver taking too long to spin up the first time. I had a devil of a time solving this in my own printing extension. Basically you have to prime the pump by having the extension request a print job from itself and discard the result during initialisation.

kletkeman on Wed, 01 May 2019 14:30:36


Yeaaaaaaaah ... that's not an excuse for leaving out obvious features. Quality sarcasm though.

LloydShort on Wed, 12 Jun 2019 23:25:02


There are two ways to print from within visual studio code if you are using vb.net.

1. Create a text file and save it using the save dialog. Have notepad as part of the process so you can then print from notepad.

2. If you want rich text you must create a graphics document and print the graphics document. It is very complicated but I can provide the code if you wish for both methods. This is great for table alignment.

2. I'm trying to print a series of forms but having trouble.