 So today we are finally adding syntax highlighting to the text editor. I know a lot of you asked for it so let's jump into it. So I'm going to start with a user interface node as always and inside this add text edit node. The text edit node is going to be full rect so you have it there on full screen and we can see here that we have a lot of options. In this case we want to have enabled syntax highlighting. Show line numbers and we're going to set a custom font because the default one is really ugly. Here in custom fonts I already pasted the Roboto Mono one which I like so new dynamic font and here on font the resource will load the regular one where is it here regular and the size I'm going to do it on 24 so for those of you who are a mobile can see it properly. Let's save this as main. Okay we have here the text so hello world if we do some typing like this is not changing any color so we have nothing set here. So let's start adding some keywords to add syntax highlighting. After you already enabled that you need to add a script so attach script. We're going to call it text edit you can go however you want and you can press control and click on the text edit to read the documentation and here you have all the options you have. You can read the documentation for anything you need in every class remember press control click on the name of it or just search help and type the name of your node. In this case we want to use one function which is add keyword color this function will take two inputs one is the string that you want to do for your keyword and the other one is the color. So in this case let's go for the word let's do with hello and for the color you need to do color and when you open and close it you have to set the values there if you're not sure about the values that you want to do you can press right click on the color word and pick color this will open a color picker and it will set the values for you so if we set here a green like this whenever you have the word hello in your text it's going to be of that color let's try it out see if it's working so hello and it changes to green but the rest it's not so that means that it's working properly one thing that you have to take into account is that keywords are case sensitive that means that hello is not the same as hello with lower case so always be sure to check that your keywords are properly there if you want to add two you can add those two variables but in general you want that for keywords so this is okay for now so now let's try to add something like this if we have something inside here we don't know exactly what's going to be inside those characters so it's not realistic to add all those as keyword colors for that we have another function which is add color region and what region does is you set a beginning an end and a color so let's start with the single and the double ones inside and the same for the end this means that it starts here and ends there and we have that there a bit confusing to see but for those are okay for color i'm gonna be picking a yellow so remember right click here pick color let's go for a yellow okay so everything inside this two is gonna be in yellow let's try it out paste the text it works so we see that everything inside this is going to be yellow and things outside of it are going to be as usual same as you have it on the got out editor and we are not gonna have anything with a single quote because we only have it on the double ones so what happened if you want to do a comment in your syntax highlighting in this case forward slash like in any other language so we can do the same with add color region i'm gonna copy and paste that in the start is going to be the double the end i don't want to set it and here the last the optional argument we're gonna set it to true that means that this will happen in all the line regardless of what happened after this so let's try it out i'm gonna paste this and what if we want this to be a comment super simple we do the forwards okay we don't want yellow of course so let's pick a color in this case right click pick color let's go for gray something like that we save we restart we paste again okay so we have comments now and everything even even if i add more slashes everything after that is gonna be just gray as in any comment what happens if you want to add a lot of keywords but you don't really want to write a keyword color all the time for that we can do an array and inside that array we can add all the keywords that you want and set a color to those now you can look through that array and set to each of those entries a color so for a you can set whatever you want here this is a new variable in animals now we can do something with each of those so add keyword color the string that we want here in the first argument is the new variable that we created in this case a because what this does is it will pick this one then it's gonna get the next one and then the next one until it ends so it's gonna be returning that value that string in this case dog is gonna go here to here so we're gonna have the value now we add the color let's speak something like red okay something like that and if we write any of those words we will see them in red so let's paste this and try there is a dog live with a cat and silly human okay i i'm writing like a robot but there you have it those words in that group are gonna be red so you can be creating groups like this however you want you set an array and you look through that array and set the color to each of those words if you try this tutorial and you are playing with it you will notice that there are some weird things happening for instance if i want to do something like test function and and i open and close it as in any other function you see that the color is set there but we never specified that we wanted color for those cases the same will happen if you write some numbers numbers are already in a color even if you don't specify that so how can we change those default ones to change those you have to select the text edit node and if you scroll down you notice that you will see here custom colors remember when we set the font here is custom colors and now you have all these different options that you can change for instance the color is the like the blinky thing that you use to type the the line selected the selection numbers in this case we have it then we have them here so if you want to change them you can either activate them and set them to white or to whatever color you have as the default one in your text editor or you can set the colors from here directly so let's see let's go for the number colors we want to do a pink and when we press play and we paste the code from before the numbers are pink now so that's everything you need to know to add syntax highlighting to your node it's really good and actually I believe that this was not implemented like this on the first tutorial that I did about making a custom text editor but you can do them really easily now so if you want to go ahead and try it out just play with those values change some colors you can create different groups different kind of regions or whatever you need and you have this syntax highlighting in your text editors or whatever you're working with thank you very much to all my patrons I really appreciate your support and I want to update you on the thing I said in the last episode that I was going to hire a developer to work on some gutted issues and I actually did so if you want to know more about it you can check out my patreon and if you want you can click like subscribe leave a comment share it on twitter facebook or whatever you are getting your gutted tutorials from and I really want to thank all of you because the support that I've been getting lately it's been insane so thank you very much