1

I want to setup build system so:

  • If build is successful, run my program
  • If not, it automatically jump to the first error (i.e. as if I pressed F4 once)

Simplest way I see it is to setup a callback with

"command": "next_result"

Which would navigate to first error in case build fails.

How could I do it?

I feel it should be something very evident, but cannot find anything in build reference.

n0p
  • 3,399
  • 2
  • 29
  • 50
roma
  • 1,512
  • 10
  • 20

1 Answers1

0

It depends on your programming language but cf this post to get the configuration for a C build (with gcc).

Then add a regex in file_regex:

"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$"

This should catch and highlight all the warnings/errors produced by gcc : Sublime Text will automatically jump to the next one when you press F4.

Have a look at the documentation for more details.

[EDIT] For custom commands, you can edit the User's Key Binding file. For syntax example, in the Default one you have:

{ "keys": ["f4"], "command": "next_result" }

where next_result is the callback called when you press F4

Community
  • 1
  • 1
n0p
  • 3,399
  • 2
  • 29
  • 50
  • I capture regex fine. I just don't want to press F4 extra time. Basically I want to setup a sublime callback on build fail. – roma Aug 04 '14 at 11:17
  • If you already have your function, then you just have to edit the key bindings: did you try it ? – n0p Aug 04 '14 at 11:38
  • Maybe I poorly specified the question. When I press Ctrl+Enter(my build key) I want to specify 2 callbacks - in case of success, program runs, in case of fail - sublime goes to first found error(as if I pressed F4). I just don't know any way to set a callback on build result. – roma Aug 04 '14 at 16:10
  • Ok, I took the liberty of editing your question then. I'm also new to Sublime but I think the function we call (like `next_result`) are python function store somewhere : I guess that you can write your own. Maybe have a look [there](https://sublime.wbond.net/) and see how plugins are implemented. – n0p Aug 04 '14 at 17:39