I have my text turning a different color when I type a certain thing in, but the problem is that it wont change back to black after I type it. And, after I type it, any key I press will retype what I typed before.
Heres my code:
Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
Dim Tag As String
Tag =
"<html>" If RichTextBox1.Text.Contains(Tag) Then Me.RichTextBox1.SelectedText = Tag With RichTextBox1.SelectAll()
.SelectionColor = Color.Blue
.DeselectAll()
.SelectionStart = Len(RichTextBox1.Text)
End WithRichTextBox1.ForeColor = Color.Black
End IfEnd Sub

Color text not returning to normal!
Karthik Krishnaswami
I've been doing some research on the matter and based on Visual Studio 2003 sample codes from other developers i've cooked up the following code:
Private bMatch As Boolean Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged 'Find the Word Currently under the Text Caret Dim iStart As Long Dim iEnd As Long Dim sKeyWord As String Dim iPos As Long With RichTextBox1iPos = .SelectionStart
If iPos Then If Mid(.Text, iPos, 1) = "<" Then bMatch = True If Mid(.Text, iPos, 1) = ">" Then bMatch = False If bMatch TheniStart = InStrRev(.Text,
"<", .SelectionStart)iEnd = InStr(iStart, .Text,
"<", CompareMethod.Text) If iEnd = 0 Then iEnd = Len(.Text) 'Check for a MatchsKeyWord = Trim(Mid$(.Text, iStart, iEnd - iStart + 1))
Me.Text = sKeyWord & " : " & Len(sKeyWord).SelectionStart = iStart - 1
.Select(.SelectionStart, Len(sKeyWord))
.SelectionColor = Color.Blue
.SelectionStart = iPos
Else.SelectionColor = Color.Black
End If End If End With End SubIt's still not perfect, since the code only works if you type in the tag at the end of the written text. If you were to start typing a tag in the middle of the sentence, the next character(s) will be overwritten and the color set back to black. I'm still working on that. In the meantime, maybe this bit of code will help with the selection issue. (^_^ )
OdieDenCO
It worked pretty good. but when ever im in the tag and delete a letter, if I type in it again the letters come out black.
The 1st highlighted part is problematic. when Im debugging, an error comes up after a while and says that the Start cannot be equal to zero.
and I dont believe I need the 2nd highlight because all it seems to do is change my Form title to what I type in the tag.
1 othe thing, the check box only work to turn off the color but not put back on. Other then thoes 2 it works great.
Mandirigma1
I've walked throught the code you mentioned within your previous post. It took me a while before i fully understood what the code did. I also noticed a few things which could be left out of the code or could be done with a different command. For instance, in his code he determined if the tag was upper cased or lower cased, like so:
' determine the tags case - upper or lower
If Mid(sText, iStart + 1, 6) = "script" ThenupperLower =
"lower"isScript =
True ElseIf Mid(sText, iStart + 1, 6) = "SCRIPT" ThenupperLower =
"upper"isScript =
True ElseIf Mid(sText, iStart + 1, 4) = "html" Or Mid(sText, iStart + 1, 4) = "head" Or Mid(sText, iStart + 1, 4) = "body" ThenupperLower =
"lower"isHtml =
True ElseIf Mid(sText, iStart + 1, 4) = "HTML" Or Mid(sText, iStart + 1, 4) = "HEAD" Or Mid(sText, iStart + 1, 4) = "BODY" ThenupperLower =
"upper"isHtml =
True ElseIf Mid(sText, iStart + 1, 5) = "/html" Or Mid(sText, iStart + 1, 5) = "/head" Or Mid(sText, iStart + 1, 5) = "/body" ThenupperLower =
"lower"isHtml =
True ElseIf Mid(sText, iStart + 1, 5) = "/HTML" Or Mid(sText, iStart + 1, 5) = "/HEAD" Or Mid(sText, iStart + 1, 5) = "/BODY" ThenupperLower =
"upper"isHtml =
True ElseIf Mid(sText, iStart + 1, 5) = "style" ThenupperLower =
"lower"isStyle =
True ElseIf Mid(sText, iStart + 1, 5) = "STYLE" ThenupperLower =
"upper"isStyle =
True ElseIf Mid(sText, iStart + 1, 4) = "meta" ThenupperLower =
"lower"isMeta =
True ElseIf Mid(sText, iStart + 1, 4) = "META" ThenupperLower =
"upper"isMeta =
True ElseIf Mid(sText, iStart + 1, 6) = "applet" ThenupperLower =
"lower"isJava =
True ElseIf Mid(sText, iStart + 1, 6) = "APPLET" ThenupperLower =
"upper"isJava =
True ElseIf Mid(sText, iStart + 1, 3) = "img" ThenupperLower =
"lower"isImg =
True ElseIf Mid(sText, iStart + 1, 3) = "IMG" ThenupperLower =
"upper"isImg =
True End IfIn this particular sample he checked if the tag was Upper or Lower cased by checking it twice. This will generate more code then needed and you will need to do the same for every other tag you wish to verify (like the "<!--" tag). Also, if the user would type in "<Html>" the code would not be recognised. That's why i prefer to "convert" the text to 1 format and then check if the tag is being recognised. This is what i did:
' determine which tag has been found If LCase(InStr(1, sText, "script", CompareMethod.Text)) ThenisScript =
True ElseIf LCase(InStr(1, sText, "html", CompareMethod.Text)) Or LCase(InStr(1, sText, "head", CompareMethod.Text)) Or LCase(InStr(1, sText, "body", CompareMethod.Text)) ThenisHtml =
True ElseIf LCase(InStr(1, sText, "/html", CompareMethod.Text)) Or LCase(InStr(1, sText, "/head", CompareMethod.Text)) Or LCase(InStr(1, sText, "/body", CompareMethod.Text)) ThenisHtml =
True ElseIf LCase(InStr(1, sText, "style", CompareMethod.Text)) ThenisStyle =
True ElseIf LCase(InStr(1, sText, "meta", CompareMethod.Text)) ThenisMeta =
True ElseIf LCase(InStr(1, sText, "applet", CompareMethod.Text)) ThenisJava =
True ElseIf LCase(InStr(1, sText, "img", CompareMethod.Text)) ThenisImg =
True End IfThat way, if you want to add a new tag, you can insert the tag just above the "End If" statement. For instance:
...
ElseIf LCase(InStr(1, sText, "applet", CompareMethod.Text)) Then
isJava =
True ElseIf LCase(InStr(1, sText, "img", CompareMethod.Text)) ThenisImg =
TrueElseIf LCase(InStr(1, sText, "!--", CompareMethod.Text)) Then
isComment =
TrueEnd If
I also removed the "Loop" statement since in the sample i've posted earlier i'm creating a selection via the "_TextChanged" procedure and providing the ColorHTML procedure with that particular selection. So, after implementing the code you posted in the previous message, my sample would look like this:
Private bMatch As Boolean Public Function ColorHTML(ByVal sText As String) On Error GoTo ColorErr Dim iEnd As Long Dim isScript As Boolean Dim isStyle As Boolean Dim isLink As Boolean Dim isMeta As Boolean Dim isJava As Boolean Dim isImg As Boolean Dim isHtml As Boolean Dim isComment As Boolean ' determine which tag has been found If LCase(InStr(1, sText, "script", CompareMethod.Text)) ThenisScript =
True ElseIf LCase(InStr(1, sText, "html", CompareMethod.Text)) Or LCase(InStr(1, sText, "head", CompareMethod.Text)) Or LCase(InStr(1, sText, "body", CompareMethod.Text)) ThenisHtml =
True ElseIf LCase(InStr(1, sText, "/html", CompareMethod.Text)) Or LCase(InStr(1, sText, "/head", CompareMethod.Text)) Or LCase(InStr(1, sText, "/body", CompareMethod.Text)) ThenisHtml =
True ElseIf LCase(InStr(1, sText, "style", CompareMethod.Text)) ThenisStyle =
True ElseIf LCase(InStr(1, sText, "meta", CompareMethod.Text)) ThenisMeta =
True ElseIf LCase(InStr(1, sText, "applet", CompareMethod.Text)) ThenisJava =
True ElseIf LCase(InStr(1, sText, "img", CompareMethod.Text)) ThenisImg =
True ElseIf LCase(InStr(1, sText, "!--", CompareMethod.Text)) ThenisComment =
True End If ' color the tags If isScript = True Then Return Color.Red ' finished coloring scriptisScript =
False ElseIf isMeta = True Then Return Color.Gray ' finished coloring metaisMeta =
False ElseIf isStyle = True Then Return Color.Violet ' finished coloring styleisStyle =
False ElseIf isJava = True Then Return Color.SaddleBrown ' finished coloring java paramsisJava =
False ElseIf isImg = True Then Return Color.Aqua ' finished coloring imgisImg =
False ElseIf isHtml = True Then Return Color.Blue ' finished coloring HTMLisHtml =
False ElseIf isComment = True Then Return Color.Green ' finished coloring HTMLisComment =
False Else ' its just plain old html Return Color.Blue End If Exit FunctionColorErr:
MsgBox(
"Error encountered at the last point of coloring" & vbCr & vbCr & "Error " & Err.Number & ": " & Err.Description, vbOKOnly + vbCritical, "Error " & Err.Number) Exit Function End Function Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged If CheckBox1.Checked = False ThenRichTextBox1.SelectAll()
RichTextBox1.SelectionColor = Color.Black
RichTextBox1.SelectionStart = Len(RichTextBox1.Text)
Else ' search for closing tags and color it End IfRichTextBox1.Focus()
End Sub Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged 'Find the Word Currently under the Text Caret Dim iStart As Long Dim iEnd As Long Dim sKeyWord As String Dim iPos As Long Dim isColor As Color If CheckBox1.Checked = True Then With RichTextBox1iPos = .SelectionStart
If iPos Then If Mid(.Text, iPos, 1) = "<" Then bMatch = True If bMatch TheniStart = InStrRev(.Text,
"<", .SelectionStart) If iEnd = 0 Then iEnd = Len(.Text) 'Check for a MatchsKeyWord = Trim(Mid$(.Text, iStart, iEnd - iStart + 1))
Me.Text = sKeyWord & " : " & Len(sKeyWord).SelectionStart = iStart - 1
.Select(.SelectionStart, Len(sKeyWord))
'*** Color Check.SelectionColor = ColorHTML(.SelectedText)
.SelectionStart = iPos
Else.SelectionColor = Color.Black
End If If Mid(.Text, iPos, 1) = ">" Then bMatch = False End If End With End If End SubThe only thing that's left is to initiate a loop (when marking the checkbox) which will check the entire text and provide the tags whith the appropriate color.
Andrea Williams
Yea that code works great and I see what you mean by not perfected but its almost there. I have also set a check box to turn off and on the colored tags (I got it working but if you typed in colored tags before you checked it off, they are still colored while the new ones are black). So I am still working on that.
Also, with this new code, is there anyway to implament other colors to other specific types of tags ie comment tags or java script tags ect.
It will be interesting to see what is uncovered!
TrickyToo
The problem is that if you use the "RichTextBox1.Text.Contains(Tag)" command, the application will always enter the IF statement. This is because once the "<HTML>" has been found, it will always be found, thus the text color will always be set to Blue.
Try the following code:
Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged Dim Tag As String, CloseTag As StringTag =
"<html>" If Len(RichTextBox1.Text) > Len(Tag) Then If Mid(RichTextBox1.Text, Len(RichTextBox1.Text) - Len(Tag), Len(Tag)) = Tag Then 'Replaced Me.RichTextBox1.SelectedText = Tag withCloseTag =
"</" & Mid(Tag, 2, Len(Tag) - 1) Me.RichTextBox1.Text = Me.RichTextBox1.Text & CloseTag Me.RichTextBox1.Select(RichTextBox1.TextLength - (Len(Tag) + Len(CloseTag)), (Len(Tag) + Len(CloseTag))) With RichTextBox1 '.SelectAll() Removed.SelectionColor = Color.Blue
.DeselectAll()
.SelectionStart = Len(RichTextBox1.Text)
End WithRichTextBox1.SelectionColor = Color.Black
End If End If End SubI've changed the "RichTextBox1.Text.Contains(Tag)" command into a "Mid()" command which only verifies if the previous 6 characters resemble the Tag value.
What i understood is that you would like to close the HTML tag once it's been found. However, while testing it, the application keeps on adding "<html><html>" after every character i type in once the Tag has been found. That's why i've assigend a "Close Tag" to a variable which will be populated with an "Close Tag" and added at the end of the RichTextBox so that the Tag will be closed after it's been found. After adding the "Close Tag", i would select both the Tag as well as the "Close Tag" and adjust the selectiontext to Blue. I've "removed" the SelectAll command, otherwise the entire text within the RichTextBox would probably be blue. (^_^ )
skycro
If you would like to reset the textcolor to black, you could do the following:
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = False Then
RichTextBox1.SelectAll()
RichTextBox1.SelectionColor = Color.Black
RichTextBox1.SelectionStart = Len(RichTextBox1.Text)
End If
End Sub
Yes, it is possible to implement other colors as well. However, will they be mentioned between the same tags ("<" & ">") If you, you might need to filter the text and search for specific commands like JavaScript, comments, etc, etc. It all depends on what you want to do with it. (^_^ )
Ravenna Li
Well, a guy over at xtremevbtalk.com suggested this...
Public Sub ColorHTML(ByVal sText As String, ByVal fOutput As Form1) On Error GoTo ColorErr Dim iStart As Long Dim iEnd As Long Dim isScript As Boolean Dim isStyle As Boolean Dim isLink As Boolean Dim isMeta As Boolean Dim isJava As Boolean Dim isImg As Boolean Dim isHtml As Boolean Dim upperLower As StringiStart = 1
iEnd = 0
fOutput.RichTextBox1.Enabled =
FalsefOutput.RichTextBox1.Visible =
FalseScreen.MousePointer = vbHourglass
Do While InStr(iEnd + 1, sText, "<")
' search for opening tag "<"iStart = InStr(iEnd + 1, sText,
"<") ' update the progressForm1.prgBar.Value = (iStart / Len(sText)) * 100
DoEvents()
' determine the tags case - upper or lower If Mid(sText, iStart + 1, 6) = "script" ThenupperLower =
"lower"isScript =
True ElseIf Mid(sText, iStart + 1, 6) = "SCRIPT" ThenupperLower =
"upper"isScript =
True ElseIf Mid(sText, iStart + 1, 4) = "html" Or Mid(sText, iStart + 1, 4) = "head" Or Mid(sText, iStart + 1, 4) = "body" ThenupperLower =
"lower"isHtml =
True ElseIf Mid(sText, iStart + 1, 4) = "HTML" Or Mid(sText, iStart + 1, 4) = "HEAD" Or Mid(sText, iStart + 1, 4) = "BODY" ThenupperLower =
"upper"isHtml =
True ElseIf Mid(sText, iStart + 1, 5) = "/html" Or Mid(sText, iStart + 1, 5) = "/head" Or Mid(sText, iStart + 1, 5) = "/body" ThenupperLower =
"lower"isHtml =
True ElseIf Mid(sText, iStart + 1, 5) = "/HTML" Or Mid(sText, iStart + 1, 5) = "/HEAD" Or Mid(sText, iStart + 1, 5) = "/BODY" ThenupperLower =
"upper"isHtml =
True ElseIf Mid(sText, iStart + 1, 5) = "style" ThenupperLower =
"lower"isStyle =
True ElseIf Mid(sText, iStart + 1, 5) = "STYLE" ThenupperLower =
"upper"isStyle =
True ElseIf Mid(sText, iStart + 1, 4) = "meta" ThenupperLower =
"lower"isMeta =
True ElseIf Mid(sText, iStart + 1, 4) = "META" ThenupperLower =
"upper"isMeta =
True ElseIf Mid(sText, iStart + 1, 6) = "applet" ThenupperLower =
"lower"isJava =
True ElseIf Mid(sText, iStart + 1, 6) = "APPLET" ThenupperLower =
"upper"isJava =
True ElseIf Mid(sText, iStart + 1, 3) = "img" ThenupperLower =
"lower"isImg =
True ElseIf Mid(sText, iStart + 1, 3) = "IMG" ThenupperLower =
"upper"isImg =
True End If ' search for closing tag ">" ' if theres a closing tag If InStr(iStart + 1, sText, ">") Then If isScript = True Then If upperLower = "upper" TheniEnd = InStr(iStart + 1, sText, UCase(
"</")) + 8 ElseiEnd = InStr(iStart + 1, sText,
"</") + 8 End If ElseIf isStyle = True Then If upperLower = "upper" TheniEnd = InStr(iStart + 1, sText, UCase(
"</")) + 7 ElseiEnd = InStr(iStart + 1, sText,
"</") + 7 End If ElseIf isJava = True Then If upperLower = "upper" TheniEnd = InStr(iStart + 1, sText, UCase(
"</")) + 8 ElseiEnd = InStr(iStart + 1, sText,
"</") + 8 End If ElseIf isMeta = True Or isImg = True Or isHtml = True TheniEnd = InStr(iStart + 1, sText,
">") ElseiEnd = InStr(iStart + 1, sText,
">") End If Else ' didn't find a closing tag If Not InStr(iStart + 1, sText, "<") Then ' if theres no opening tagScreen.MousePointer = vbDefault
' exit coloring Exit Sub End If End If ' color the tagsfOutput.RichTextBox1.SelectionStart = iStart - 1
fOutput.RichTextBox1.SelectionLength = (iEnd - iStart) + 1
If isScript = True ThenfOutput.RichTextBox1.SelectionColor = cScript
' finished coloring scriptisScript =
False ElseIf isMeta = True ThenfOutput.RichTextBox1.SelectionColor = cMeta
' finished coloring metaisMeta =
False ElseIf isStyle = True ThenfOutput.RichTextBox1.SelectionColor = cStyle
' finished coloring styleisStyle =
False ElseIf isJava = True ThenfOutput.RichTextBox1.SelectionColor = cJava
' finished coloring java paramsisJava =
False ElseIf isImg = True ThenfOutput.RichTextBox1.SelectionColor = cImg
' finished coloring imgisImg =
False ElseIf isHtml = True ThenfOutput.RichTextBox1.SelectionColor = cSpecial
' finished coloring HTMLisHtml =
False Else ' its just plain old htmlfOutput.RichTextBox1.SelectionColor = cHtml
End If LoopisColored =
TrueScreen.MousePointer = vbDefault
fOutput.RichTextBox1.Enabled =
TruefOutput.RichTextBox1.Visible =
TruefOutput.RichTextBox1.SelectionStart = 0
fOutput.prgBar.Value = 0
Exit SubColorErr:
MsgBox(
"Error encountered at the last point of coloring", vbOKOnly + vbCritical, "CodeCrawler")Screen.MousePointer = vbDefault
fOutput.RichTextBox1.SelStart = 0
fOutput.RichTextBox1.Enabled =
TruefOutput.RichTextBox1.Visible =
TruefOutput.prgBar.Value = 0
Exit SubEnd Sub
(got that from here: http://www.xtremevbtalk.com/showthread.php t=12896)
Maybe that will influence the code
Muruli
I've been thinking about ways to define which text need to get which color. I've created a Function which will check the .SelectedText and verifies which color it should get.
How about this:
Private bMatch As Boolean Function ColorCheck(ByVal myText As String) If Len(myText) > 3 Then If Mid(myText, 1, 4) = "<!--" Then Return Color.Green Else Return Color.Blue End If Else Return Color.Blue End If End Function Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged 'Find the Word Currently under the Text Caret Dim iStart As Long Dim iEnd As Long Dim sKeyWord As String Dim iPos As Long Dim isColor As Color If CheckBox1.Checked = True Then With RichTextBox1iPos = .SelectionStart
If iPos Then If Mid(.Text, iPos, 1) = "<" Then bMatch = True If Mid(.Text, iPos, 1) = ">" Then bMatch = False If bMatch TheniStart = InStrRev(.Text,
"<", .SelectionStart) 'iEnd = InStr(iStart, .Text, "<", CompareMethod.Text) If iEnd = 0 Then iEnd = Len(.Text) 'Check for a MatchsKeyWord = Trim(Mid$(.Text, iStart, iEnd - iStart + 1))
Me.Text = sKeyWord & " : " & Len(sKeyWord).SelectionStart = iStart - 1
.Select(.SelectionStart, Len(sKeyWord))
'*** Color Check.SelectionColor = ColorCheck(.SelectedText)
.SelectionStart = iPos
Else.SelectionColor = Color.Black
End If End If End With End If End Sub Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged If CheckBox1.Checked = False ThenRichTextBox1.SelectAll()
RichTextBox1.SelectionColor = Color.Black
RichTextBox1.SelectionStart = Len(RichTextBox1.Text)
Else End IfRichTextBox1.Focus()
End Subsacredspirita
All I need is the color blue between from "<" , to ">". "<!--" and "--//>" along with everything in between needs to be green. And about 5 more other words.
Yea I might need to filter...
PavaniPolu
A lot still needs to be done when it comes to this particular application. (^_^ ) It's true that when you go into a tag and type in a character, the text will be black. The reason behind it is that at that time the bMatch value is False, thus it will not check the tag. I haven't been looking into that yet.
The top priority was to get a grasp of the basic functionality of the application, which has been roughly build with my previous sample. Now what has to be done is to extend the code to incorperate a "Search" throughout the entire test to see if a tag has been found and what color needs to be assigned to. Phase 2 of the application. (^_^ ) Once a procedure has been build which "searches" through the entire text and colored the selections accordingly, you just have to perform a procedure Call once the ChecBox has been checked.
It's true that you don't need the 2nd Highlighted text. It's merely a command used for debugging. That way i can verify what text has been selected.
I must say that i haven't had an error with the first highlighted text, but i can imagine that it would pop up when you would select a tag and type into it, since i haven't checked it yet. (^_^ )
In other words... Let's get crackin'. Try to come up with a way to search through the text and find one tag.
Manic_Again
That seemed to work with the exception of the very first part of the opening tag "<" is still black. And when I try to add another tag with the original, the original goes back to black while the new one gets a color change.
I also added the comment tag in there and works but same concept applys.
Dim html As String, Closehtml As Stringhtml =
"<html>" If Len(RichTextBox1.Text) > Len(html) Then If Mid(RichTextBox1.Text, Len(RichTextBox1.Text) - Len(html), Len(html)) = html Then 'Replaced Me.RichTextBox1.SelectedText = Tag withClosehtml =
"</" & Mid(html, 2, Len(html) - 1) Me.RichTextBox1.Text = Me.RichTextBox1.Text & Closehtml Me.RichTextBox1.Select(RichTextBox1.TextLength - (Len(html) + Len(Closehtml)), (Len(html) + Len(Closehtml))) With RichTextBox1 '.SelectAll() Removed.SelectionColor = Color.Blue
.DeselectAll()
.SelectionStart = Len(RichTextBox1.Text)
End WithRichTextBox1.SelectionColor = Color.Black
End If End If Dim Comment As String, CloseComment As StringComment =
"<!--" If Len(RichTextBox1.Text) > Len(Comment) Then If Mid(RichTextBox1.Text, Len(RichTextBox1.Text) - Len(Comment), Len(Comment)) = Comment Then 'Replaced Me.RichTextBox1.SelectedText = Tag withCloseComment =
"--//>" '& Mid(Comment, 2, Len(Comment) - 1) Me.RichTextBox1.Text = Me.RichTextBox1.Text & CloseComment Me.RichTextBox1.Select(RichTextBox1.TextLength - (Len(Comment) + Len(CloseComment)), (Len(Comment) + Len(CloseComment))) With RichTextBox1 '.SelectAll() Removed.SelectionColor = Color.Green
.DeselectAll()
.SelectionStart = Len(RichTextBox1.Text)
End WithRichTextBox1.SelectionColor = Color.Black
End If End IfIs there a way to just tell it. when ever this key "<" is typed, then change color to blue along with everything else until this key ">" is typed