Sublime Forum

Compiling code in Sublime - Errors

#1

I have Sublime and really want to use it as my primary editor, but emacs offers some functionality that I haven’t found out how to replicate in Sublime. I can compile code in Emacs and the compilation output appears in a buffer (window/frame) that I can view next to the code I’m writing. Two aspects of how that buffer handles errors are super important. 1) Syntax highlighting colors error messages red. 2) Clicking on an error automatically opens another buffer to the line of code that triggered the error (or switches to that buffer if one’s already open). This seems to me like something so important to developers working with compiled languages that it’s hard for me to believe that it hasn’t been implemented in a Sublime plugin. Has it?

0 Likes

#2

Except for the syntax highlighting part, build systems in sublime do this out of the box.

In particular, when you invoke a build (Tools > Build from the menu or via Ctrl+B Windows/Linux, ⌘+B on MacOS), the build results show up in the build panel, and double clicking on an error line will open the appropriate file and line as reported in the error message. You can also navigate between them with keyboard shortcuts if you like (F4 and Shift+F4).

For the syntax highlighting part, that is not currently done. That might be because there’s no good generic way to capture an entire error message in all situations; build systems use regular expressions that lets them extract the position of errors.

As such I’m not sure if it’s possible to apply your own syntax highlighting in this situation or not.

More info is available in the documentation for build systems.

1 Like

#3

Thanks for that helpful information. I don’t really need entire error messages highlighted, just enough (e.g. the word “error”) to see where they are. I’ll give this a try.

0 Likes

#4

It is possible to get syntax highlighting in a build system. You can add a syntax key to the .sublime-build file (either as part of a variant or to the top level) with a path to the syntax definition or use scope: followed by the base scope, i.e. "syntax": "scope:source.json"

this functionality has a tiny mention here: http://docs.sublimetext.info/en/latest/reference/build_systems/exec.html

1 Like

#5

I found this helpful, three-and-a-half years in the future; to update the link at the end, it is now: https://www.sublimetext.com/docs/3/build_systems.html

0 Likes