T4Editor VS2019 Extension: Syntax highlighting for T4 Templates

Several developers complain about the lack of a proper T4 editor experience, as everything is just shown as plain text. See my other T4 tutorials to see the regular T4 text files in the header image.

I created a Visual Studio extension called T4Editor that adds colors to different blocks in you code. You can easily spot the difference between output code, control blocks and class feature blocks. This increases coding productivity and readability of your T4 templates.

In the future, C# code inside these blocks will also be highlighted with the propper C# syntax colors, I’m still working on that.

Update: Now you can set custom colors! Navigate to Extensions – T4Editor – Adjust Colors and pick whatever colors you want.

Update 2: There is now code completion/minor custom intellisense for codeblocks!

Update 4: I have implemented brace matching and improved RegEx. Typing ‘var string = “#>” for example, will not act as a closing tag.

Click here to see the code. Feel free to give feedback or even contribute!