Setting Up Sublime Text For Competitive Programming (for C++, Python, and Java)

Aman Kumar
The Startup
Published in
4 min readMay 26, 2020

--

Photo by Chris Ried on Unsplash

Welcome guys! If you have been programming for some time, then you must have heard about Sublime Text, “A sophisticated text editor for code, markup, and prose”. It’s so popular because it is highly configurable, extremely lightweight, and has a sleek and beautiful design. Although it may seem a little complex to handle at first, but when you understand its working, you will literally appreciate how productive it makes you.

(See this article to understand why Sublime Text is so popular when it comes to productivity.)

Hoping that you already have created required build systems for your desired languages, let’s start.

Input — Output Window

We all know how irritating it is to repeatedly give test inputs to our running programs. During competitive programming, time matters a lot. There is package called Sublime Input which can help us here. It emulates the I/O console of online IDEs, and is very easy to set up.

  • Go to Preferences -> Package Control -> Install Package. Type “Sublime Input” and click on the search result that comes. Confirm through the steps shown below.
  • Go and read README.md for this package. Instructions for user input methods are given in that file. The method is to give a multi-line comment at the top of file.

For C/C++/Java : The format is same:

/*input
YOUR DESIRED INPUT
*/

For Python :

'''input
YOUR DESIRED INPUT
'''
  • Provide your desired input in the multi-line comment at the top of your program and run it using

a) Ctrl + Alt + B (or similar command on your keyboard) or

b) Go to Tools -> SublimeInput-Build

Your program will be executed and the output will be displayed in ST’s console.

Productive Coding Using Keyboard Shortcuts

This is very important when you need to edit your code. You can find various web-pages with the title “Best Keyboard Shortcuts in ST3” or something like that. But the truth is many of these probably won’t work on your keyboard layout. For example, my keyboard is of medium size, so it doesn’t have dedicated keys for Home, End, etc. To use these functionalities I have to press them along with Shift key. You must test your keyboard to check which shortcuts actually work. The complete list of keyboard shortcuts can be found using Preferences -> Key Bindings.

Some are literally very helpful in competitive programming. For example, Ctrl+d selects all the subsequent occurrences of the current word and then you can edit them simultaneously. This is particularly useful in loops.

Some other useful shortcuts which I frequently use are given below:

You must try these shortcuts on your system to see what exactly do they do. If you want to explore more, I found this amazing article on Medium which explores more than just basic Competitive Programming tools.

Thanks for reading. I hope you found this article useful and will recommend it to others who might need it. See you next time. Till then take care, stay safe, and code as much you want.

--

--