When we are participating in a programming contest, our aim is to be as quick and as efficient as possible. However, often the tools we use during contests are clunky, non-intuitive and impede our speed. The following post will help you set up Sublime Text in a way that leads to a good workflow - from reading the problem statement to submitting the solution.
Sublime can be used to instantly build and compile your program. This setup will save you lots of precious time during an ongoing contest. Now let’s get started. Step 1: Installing Sublime Text. Sublime Text is available for Mac, Linux and Windows. Follow the link below to install Sublime Text in your PC. Yup there's a way. Sublime Text is just a text editor like a more advanced form of Textedit on the mac. You can not compile code with it like you do in xcode. Aug 28 Aug 27 Aug 26 Aug 25 Aug 24 Aug 23 Aug 22 Aug 21 Aug 20 Aug 19 Aug 18 Aug 17 Aug 16 Aug 15 Aug 14 Aug 13 Aug 12 Aug 11 Aug 10 Aug 9 Aug 8 Aug 7 Aug 6 Aug 5 Aug 4. Step 1: Download the.dmg file of Sublime Text from the official website just like we did for windows. Step 2: run and install the file and then you are ready to go. Now, you need to install the Gcc compiler on your mac.
Setting up the Environment
1. Install MinGW Compiler
MinGW is a native Windows port of the GNU Compiler Collection (GCC). Install the latest MinGW compiler, after downloading from here.
Your path should preferably be C:MinGW
. Finally, add the bin
directory, C:MinGWbin
to the System PATH.
2. Install Sublime Text
Sublime Text is one of the most popular editors for development in general. It’s smooth and fast compared to other editors (being written in C++ helps that speed). Sublime also has tons of plugins you can find through Package Control. Download and install Sublime Text 3 from here.
3. Create a build system
Sublime Text provides build systems to allow users to run external programs. Create a new build system for Sublime Text for setting up C++ compilation.
Go to Tools > Build System > New Build System
. Paste the following code in the file and save it.
This can be used for piping input from the inputf.in
file, and output to the outputf.in
file. Note that this uses the -std=c++17
flag to enable the latest features of C++17. If you don't want this or want to use C++14, replace this with the -std=c++14
flag.
4. Setup window layout
Create three new files, file.cpp
, inputf.in
, and outputf.in
. Select View > Layout > Columns : 3
. This will create three columns in the workspace. Move the three files into the three columns. Select View > Groups > Max Columns : 2
.
The windows will look like above when you are done. Write a hello world program, and test its working. Use Ctrl+B
to build and execute the file.
5. Precompile headers
Now we can speed up compilation time by precompiling all the header files as mentioned here, i.e. by precompiling the bits/stdc++.h
header file. This can speed up compilation time by up to a factor of 12.
For this, first, navigate to the stdc++.h
file. This will be located at a directory similar to C:MinGWlibgccmingw326.3.0includec++mingw32bits
. Right click while pressing Shift to open a Powershell/cmd window there. Run the command g++ -std=c++17 stdc++.h
, to compile the header. Take care to use the same flags you used in your build system. Check to make sure that the stdc++.h.gch
file was created in the directory.
Finally, we can take advantage of the features of Sublime Text, namely snippets and completions.
Sublime Text features
Snippets
Snippets are smart templates that will insert text for you and adapt it to their context. Read up on the documentation of snippets at the official guide. You can create snippets like the following to quickly insert snippets of code into your file.
You can also create starter templates like these :
Sublime Text C++ Debug
Completions
Sublime Text suggests completions that aggregate code or content while writing by catching everything that you have written, like variable names. Read up on the documentation of completions at the official guide. You can create completions like the following to quickly enter common phrases into your file.
C Compiler For Mac
This provides an experience close to code completion, with the advantage that you can customize it to phrases you frequently type.
You can create snippet or completion files by putting the corresponding code in a .sublime-snippet
or .sublime-completions
file.
So that's the basics out of the way, you can now begin coding. You can also explore various other features present in Sublime text, especially its plugin functionality and the most common plugins. You can also install themes to change the look and feel of the windows. There are other features that you may want to use so I’ve provided some further reading.
Build 4113
C++ Compiler For Sublime Text
- Improved performance when editing large files
- Improved OpenGL rendering performance
- Improved handling of deleted files
- Various syntax highlighting improvements
- subl can now be used to edit stdin, eg: echo test | subl | cat
- Syntax and indentation detection is now done when editing stdin
- Added syntax_detection_size_limit setting for controlling when syntax detection is skipped
- Theme: Improved scroll puck visibility
- Theme: Fixed adaptive theme not respecting themed_title_bar setting with light color schemes
- Middle clicking in the Open Files section of then sidebar will close the clicked on file
- Preserve Case now works with unicode characters
- Added reveal_menu setting for disabling revealing the menu when alt is pressed on Linux and Windows
- Safe Mode key binding can be disabled by creating a file named .Disable Safe Mode Shortcut in the data directory
- Fixed Ruby syntax highlighting in the Monokai color scheme
- Fixed a scenario where folders weren't being watched for changes
- Fixed underlines being drawn behind line highlight
- Fixed an infinite loop that could occur during syntax highlighting
- Fixed the append command's scroll_to_end parameter sometimes not working
- Fixed Goto Symbol sometimes being scrolled incorrectly
- Fixed multi-select file limit applying to sidebar
- Fixed auto-complete related hang in some large files
- Linux: Fixed print sometimes not working
- Linux: Fixed wrong order of yes/no buttons in GTK dialogs
- Linux: Fixed letters sometimes being cut off
- Windows: Always make a new window when launching main executable on Windows
- Windows: Fixed window icon not scaling properly on Windows
- Windows: Fixed globs not being expanded in some cases on Windows
- Mac: Fixed auto theme not changing with OS auto theme on macOS