Setting up Sublime for competitive programming
This tutorial helps to set up a quick building for C plus plus program. The result is you just need to type Ctrl + B to build your C++ file.
All you need is follow these neat steps:
- Create your own build system
Tools -> Build System -> New Build System
Copy this script into it.
1{
2 "cmd": ["g++", "-std=c++1z", "$file", "-o", "${file_path}/${file_base_name}"],
3 "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
4 "working_dir": "${file_path}",
5 "selector": "source.c, source.c++, source.cxx, source.cpp",
6 "variants":
7 [
8 {
9 "name": "Run",
10 "cmd": ["bash", "-c", "g++ -std=c++1z '${file}' -o '${file_path}/${file_base_name}' && xterm -e bash -c '\"${file_path}/${file_base_name}\"; echo Press ENTER to continue; read'"]
11 }
12 ]
13}
Save it with name: myCPP
-
Choose myCPP as default build system
Tools -> Build System -> myCPP -
Set mode to build with
Ctrl + Shift + B and choose MyCPP - Run -
Completed
Every time you push Ctrl + B, the program will automatically be saved and build with new terminal,xterm
in this case.