Reputation: 41
For example, I have a project with 2 .cpp files and 2 .h files and also main.cpp .
I want to make Sublime compile main.cpp when I press control-B even if the editor if focused in one of the other .cpp or .h files.
I am not too familiar with JSON so I don't know how to modify the build file.
This is the default build file. The problem with this file is that it compiles the file the editor is focused on.
{
"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}\""
}
]
}
Upvotes: 2
Views: 542
Reputation: 41
Never mind. The solution was simple. In both lines of
"shell_cmd":
change
${file}
to the file name you want to always compile. For example:
"shell_cmd": "g++ \"main.cpp\" -o \"${file_path}/${file_base_name}\"",
Upvotes: 1