Sublime Forum

How to set up a field «file_regex» in the project settings?

#1

I am using GCC and one day I try to use plugin Highlight Build Errors, but I have a problem: incorrect setup of file_regex field in the project settings Sublime Text 3.
Error in my build output is (just for example):

--- compiling .\user-code/main.c... .\user-code/main.c: In function 'main': .\user-code/main.c:44:2: error: expected ')' before '{' token { ^ .\user-code/main.c:54:1: error: expected expression before '}' token } ^
For example in the sublime text documentation I found this: “file_regex”: “^ ]File "(…?)”, line ([0-9]*)", but it is not work. I did not understand the syntax of this field. Can anyone explain it to me?
So, what I shuld put to the file_regex field in the project settings for detecting errors like this?

0 Likes

#2

Something like this https://regex101.com/r/kW1fX9/1

(^[a-zA-Z._-]+)\(([0-9]+)\) : (error.*)

Example for the default C++ builder:

{
	"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\"",
	"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
	"working_dir": "${file_path}",
	"selector": "source.c, source.c++",

	"variants":
	[
		{
			"name": "Run",
			"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
		}
	]
}
1 Like