#dotnet

Changing T4 Template Background Colors in Visual Studio

·

·

3 min read

T4 is a templating engine inside of Visual Studio that lets you generate, well, text. Since T4 has no editor goodies in Visual Studio the Tangible T4 Editor is a good way to get some of the goodies back. But if you’re using the “dark” theme in Visual Studio the Tangible T4 Editor needs a color change.

Working with T4 templates can be a bit tedious. What’s T4 you ask? T4 is the Text Template Transformation Toolkit that ships with Visual Studio. T4 allows you generate text within Visual Studio. This can be code, sql, text files or whatever. <YodaVoice>Very powerful it can be.</YodaVoice> But dealing with T4 templates out of the box can be annoying since there is no IntelliSense, syntax highlighting or debugging. You might as well be using Notepad. One of the easiest ways to get some of those features back, for free, is to use the Tangible T4 Editor.

The free version of the Tangible T4 Editor brings you syntax highlighting and some IntelliSense. If you want all of the IntelliSense goodness then you have to buy the Pro version. 🙁 One of the biggest problems that I had right off the bat with the Tangible T4 editor was with the color scheme. See, I’m one of those cool developer types and I use the dark Visual Studio theme. So I install it and this happened:

Aggghhh! My eyes!

Can you work like this? Nope. It looks great in the “blue” them but like hell in the “dark”. So we need to fix this. Luckily Tangible has set a color in the options to fix it. Go to Tools > Options and this dialog comes up.

Select Environment > Fonts and Colors from the list and then select “tangilbe T4 Background” in the “Display items” list box. Then click the “Custom” button in the “Item background” section. This dialog will come up. (Yes, dialog over a dialog)

Color-a-rama.

You can choose any color you like but I settled on Red: 60 Green: 60 Blue: 60. It’s a nice dark grey and you get this:

Much better.

Now sanity has been restored and work can continue. I’m not sure why T4 has been treated like the red-headed stepchild of Visual Studio. It’s quirky but has some rich features that can be useful in appropriate situations. Until Microsoft takes T4 out of the corner we’re stuck trying to find third party alternatives so that we can use it effectively.

9 responses to “Changing T4 Template Background Colors in Visual Studio”

  1. Jack Corbett Avatar

    Evil developer with your black background. We DBA types are good with the white background.

  2. Richie Rump Avatar

    Yeah, yeah Jack. I know you have a copy of Sublime Text open right now…and the background is black.

  3. walter Avatar
    walter

    thanks Richie, was horrified when I saw the original tangible colour scheme against my dark background, this fixed it.

  4. Sean Lively (@IronSamVane) Avatar

    Setting the background color to 30,30,30 is an exact match for VS2015’s dark theme.

  5. Chris Avatar
    Chris

    Thank you!

  6. Gooey D Avatar
    Gooey D

    Perfect — this is exactly what I needed. And as @IronSamVane mentioned, setting the RGB colors to 30 is a 100% match for VS2015’s dark theme.

  7. excursioblogsrasd@web.de Avatar

    thx a lot! this fixed my problem as well.

  8. Steve Avatar
    Steve

    Selecting “Automatic” for the background works too

  9. Jesse Avatar
    Jesse

    Thanks a lot! Been looking this solution for ages.

Leave a Reply

Your email address will not be published. Required fields are marked *

Richie Rump

// about the author

Richie Rump is a Dataveloper.

Richie Rump is a principal software engineer and software architect with more than two decades spent at the intersection of application code and the data layer. He builds and operates data-intensive products, including database diagnostic tools, cloud-native serverless platforms, and full-stack applications, owning them from architecture and database design all the way through to production. Beyond the day job, he created StatisticsParser.com, co-founded a user group, and co-hosted the Away From The Keyboard podcast. On this site, he writes about performance, database internals, and the engineering practices behind reliable systems.