Skip to content

Instantly share code, notes, and snippets.

@zhenguoli
Forked from mikhdm/Visual C++.sublime-build
Last active September 27, 2017 11:24
Show Gist options
  • Save zhenguoli/c1c46ded56748e11a51ab2532712962e to your computer and use it in GitHub Desktop.
Save zhenguoli/c1c46ded56748e11a51ab2532712962e to your computer and use it in GitHub Desktop.
Visual C++ build system for sublime text to exec and compile .c and .cpp files from Subime Text editor.
{
"cmd": ["vcvars32.bat", "&", "cl", "/EHsc", "${file}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.cpp, source.c++",
// By default cl is not in your PATH, so add it to your path (preferably)
// or uncomment "path" and check that it has correct value
//"path": "path:/to/folder/where/cl.exe/located",
// this also will set path for vcvars32.bat
"shell": true, // Without this sublime has hard times to parse "&" in out command line
"variants":
[
{
"name": "Run",
"shell": true,
// "cmd": ["g++", "-Wall", "${file}", "-o", "${file_path}/${file_base_name}", "&&", "start", "${file_path}/${file_base_name}.exe"],
// NOTE: `start` COMMAND CAN'T RESOLVE FILENAME QUOTED BY QUOTES("").
// Run the executable in cmd.
"shell_cmd": "if exist \"${file_path}/${file_base_name}.exe\" ( start ${file_path}/${file_base_name}.exe ) else ( vcvars32.bat && cl /EHsc \"${file}\" && start ${file_path}/${file_base_name}.exe )",
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment