In the script editor, highlight string escapes separately from the rest of the string

As a Roblox developer, it is currently hard to distinguish between an actual character in a string and a sequence that’s being used to escape another character.

String escapes can be long and multiple characters, and I sometimes have to stop and rethink how long a string is because of the string escape. This is a relatively minor UX thing, but it would have a big impact on me personally because I end up writing code that involves a lot of string escapes (while testing my plugin, I end up running into them a lot) and being able to visually parse them quickly would be helpful.

This is also one of the things I miss the most from VSCode when I use Roblox’s editor.

If Roblox added highlighting separately for string escapes, it would make me more productive by helping me spend less time reading code, and more time writing it, because it would help my visually parse out how long a string actually is and what characters go where.

For posterity, these are the string escapes I mean:

  • All of the letter ones: \n, \t, \r, \v, \f, \b, \a, \z
  • Single character escapes: \\, \", \'
  • Decimal escapes: \ddd where ddd is a number between 0 and 255
  • Hex escapes: \xHH where HH is a hex number between 00 and FF
  • Unicode escapes: \u{XXX} where XXX is a hex number between 00 and 10FFFF

As much as I hate to throw the multi-line string escape (\ [newline]) to the wolves, I don’t think it makes sense to highlight it.

Also, please don’t highlight these inside of long strings. They’re literals, so escape sequences don’t work in them, and it would be very confusing.

10 Likes

Thank you for bringing this up @Dekkonot, we’ll look into this!

3 Likes

Being able to explicitly see string patterns caused by escapes would be a huge bonus to the editor. I currently have to open up Visual Studio Code to figure out my escapes to visually see what I’m doing because in Roblox, it’s just a regular string. Would be great to have this accessibility feature added!

Here’s an example of Studio:

Now Visual Studio Code:

Code:

local paragraph = "this is a paragraph of\ntext that allows me\nto utilize multiple lines!\nvery cool thank u"
print(paragraph)
3 Likes