Search code examples
regexperlsublimetext3syntax-highlighting

s///r; breaks syntax highlighter in Sublime


I have a Perl script and editor I'm using is Sublime.

After the below line of code, the syntax highlighter breaks.
my $new = ($old =~ s/cat/dog/r);

enter image description here

This is because of /r. But why?

How to tackle this problem or any alternatives?


Solution

  • This is a problem that exists in your version, v3.1.1 aka build 3176.

    Perl code in Sublime Text 3.1.1 is incorrectly highlighted

    This was fixed in v3.2 aka build 3200.

    Perl code in Sublime Text 3.2 is correctly highlighted

    Upgrading to the latest v3.x (v3.2.2) is covered under your current license, if you have one.

    However, I strongly recommend updating to the latest version of Sublime Text 4, which is Build 4143. I use the dev builds, which are slightly ahead of the public builds, and your code is highlighted correctly there as well:

    Perl code in Sublime Text Build 4150 is also correctly highlighted

    The code looks the same in Build 4143.

    If you're a licensed user of Sublime Text you'll need a new license for ST4, but there are so many new features and improvements over the old version that it's definitely worth it to support the developers.