Sublime Forum

Sublime text 2 syntax errors highlighting

#1

In Sublime text 2 when I make an error like forget a “;” or add an extra closing or opening tag there is no highlighting that tells me that I have made a misstake. And only after running the code will I know that a misstake was made. Is this normal for sublime text 2 or is it just me? If this is normal, is there any extension to fix this?

0 Likes

#2

ST2 does not include error highlighting by default. However, I strongly suggest you use SublimeLinter (available on github: https://github.com/kronuz/SublimeLinter/ or through package control: http://wbond.net/sublime_packages/package_control). SublimeLinter includes support for Javascript, Objective-J, Python, Ruby, PHP, Java, and Perl.

0 Likes

#3

Sublime Text 2 doen’t do any linting. If you want to do that, you may need a plugin.

With that said, syntax files can highlight stuff like that for you to some degree, but the author of the syntax file has to code in that functionality. Syntax files are essentially just big tables of regex that assign some scope based on defined rules. If you put in the right regex to find missing “;”, you can then assign the “invalid” scope to the line and show the issue. It just gets hard to do it this way because of all the other things it is also trying to highlight; it can be unreliable.

So I would see if the linting plugins available already support your language, or find a good linter and write a plugin to utilize it and highlight the issues, or make a request to the authors of the current lint plugins to add in the linter support (if available) for your language.

0 Likes

#4

Ty, but it seems like the error highlighting is not automaticly done. You have to press the keybinded buttons to find the errors if I am not misstaken.

0 Likes

#5

SublimeLinter can be set to on, off or on-save (Which can be set under Preferences > Package Settings > Sublime Linter > Default). “On” will lint as you type. “On save” will only lint when you save the file. No keybinding necessary.

0 Likes

#6

Just wanted to point out that I tracked an error when using SublimeLinter and dropbox on the Mac. If a file is on a dropbox folder, ST2 will immediately quit after opening that file. Removing SublimeLinter fixes the error.

I rely heavily on SublimeLinter. Can someone suggest an alternative that does real-time Ruby and PHP syntax checking?

0 Likes

#7

[quote=“kakubei”]Just wanted to point out that I tracked an error when using SublimeLinter and dropbox on the Mac. If a file is on a dropbox folder, ST2 will immediately quit after opening that file. Removing SublimeLinter fixes the error.

I rely heavily on SublimeLinter. Can someone suggest an alternative[/quote]

Perhaps you could report it as a bug (with details and a sample file) instead of giving up and looking for alternatives.

0 Likes