Sublime Forum

\K pattern missing in Oniguruma


I find the inability to only keep a match without the prefix or suffix annoying.

For example:

>         axis equal
#^^^^^^^^^ meta.function-call.command.matlab
#         ^^^^ meta.function-call.command.matlab variable.function.command.matlab
#             ^ meta.function-call.command.matlab
#              ^^^^^ meta.function-call.command.matlab string.unquoted.matlab

The initial whitespace is included in the function-call.command meta scope. My pattern is annoyingly dependent on the non-whitespace token preceding axis. So I have to include a bunch of irrelevant whitespace in my matches and my tests. I’d like \K so I can get the token matching more accurate.



Why keep bothering with that old tmLanguage stuff which won’t ever be able to make use of full power of ST’s syntax engine?

This file format is supported to make transition from TextMate to Sublime Text more easily. It’s not very likely to see new features.

If you are interested in a fully powered Matlab syntax, you might want to help improving the pending PR at

It is probably already much more accurate and powerful than a tmLanguage can ever be.

That said, the way to remove whitespace from tokens was to properly assign scopes to capture groups.



For the life of me, I can’t remove the whitespace from the meta scope. I’m trying to devise some nested pattern contraption to fix it.

tmLanguage sucks but it’s what we have for now (outside of the Sublime ecosystem). I’m working on the Matlab one and there’s a lot that can be fixed for now.

Truth be told, I have lost faith in static grammars altogether and have joined the church of treesitter. A high-speed high-accuracy tokenization for source langs that can take into account context-sensitive syntax and easily provide “Intellisense” like information.



Sublime syntax definitions with branching are similarly powerful to treesitter. We also use the scoping to drive auto-complete, goto-definition, etc.



What is needed is the effort to lift all syntax definitions to make use of it.

1 Like


With scoping and branching, I can see it being similarly powerful. I see that you have LSP as well, talk about “best of both worlds”



I see that you have LSP as well, talk about “best of both worlds”

The LSP package for Sublime Text doesn’t yet support semantic highlighting though, which was added in the current LSP spec 3.16, because there is currently no API in ST to adjust foreground highlighting colors or to dynamically add scopes to tokens and re-trigger the syntax highlighting engine. I would say this is the only aspect where VS Code currently has a potential advantage regarding syntax highlighting in comparison to ST. But on the other hand I can understand that this probably isn’t the highest priority to add, if the syntax definition for a language is good enough anyway, and the delay from language servers may even result in a worsen UX possibly.