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:

  1. 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

  1. Choose myCPP as default build system
    Tools -> Build System -> myCPP

  2. Set mode to build with
    Ctrl + Shift + B and choose MyCPP - Run

  3. Completed
    Every time you push Ctrl + B, the program will automatically be saved and build with new terminal, xterm in this case.