How To Download and Setup Sublime Text for Competitive programming in C++

“Before getting in a war you need to have your tools setup right !” 

Hello coderz! Welcome to CodingBroz where you find all your solutions regarding programming.

Today, I am going to help you in setting up your weapon before getting into the warzone i.e. I will help you to Download and setup Sublime Text for Competitive programming in C++ !!!

How To Download and Setup Sublime Text for Competitive programming in C++

Why C++ ?

Maybe you would be clear in your selection of programming language as C++ or you still must be confused between C++ or any other language.

So, let me clear your confusions and doubt and I will help to make your mind clear for your selection of C++ as a weapon (language) for your war (Competitive Programming) 

First of all C++ is the most widely used Programming Language for competitive programming and why you should also choose C++ ! 

C++ is a very fast and best suited language for you if you are really interested in Competitive programming and it can also help during your job interviews.  

Now moving towards How you can download and setup Sublime text for competitive programming in C++

Also Read:

 What is Sublime Text ?

Sublime Text is an awesome Text editor used for writing code. It is a widely used code editor, especially for Competitive Programming with C++.  

It is very light weight as it is a text editor and not an IDE (Integrated Development Environment) which can be easily set up and used.

Why Sublime Text ?

Sublime Text is full of rich and very useful features, this is why it is widely used across the globe by many competitive programmers. Let’s see what are those features which make it very useful for competitive coding :

  • Track all the files and folders you are working with
  • Auto correction and formatting features
  • Create your own snippet
  • Last and the best feature is its Colorful dark theme which you are also going to love a lot and it will make coding more fun.

Operating system for Sublime Text

Sublime Text can be used on all the there Operating System :

  1. Windows
  2. macOS
  3. Linux

You can download Sublime Text for your operating system using its official website i.e. www.sublimetext.com

Now let’s see, How can you Download and Setup Sublime Text for Competitive programming in C++ !

Downloading Sublime Text

As I mentioned above Sublime Text is available for all operating system, Windows, macOS and Linux.

Go to its official website i.e. www.sublimetext.com and download Sublime Text according to your Operating System.

Installing Sublime Text in Windows

You can follow these steps and install Sublime Text on your Windows system

Step 1 – Click and run the downloaded .exe file . Click next

Step 2 – Now choose a destination location to install Sublime Text and click Next.

Step 3 –Verify the destination folder and click Install.

Step 4 – Now click Finish to complete the installation.

Now, Install mingW C++ compiler to run C++ program on Sublime Text. You can download it from here – MinGW 

Installing Sublime Text in Linux

Now, let’s see how you can install Sublime Text in the Linux Operating System. Follow these steps :

Step 1 : Use the terminal and install the packages for Sublime Text editor using this command –

sudo add-apt-repository ppa:webupd8team/Sublime-Text-3

Step 2 − Update the packages using the following command −

sudo apt-get update

Step 3 − Install the Sublime Text repository using the following command −

sudo apt-get install Sublime-Text

After the successful execution of above mentioned commands, you will find that Sublime Text editor is installed on the system.

If you are using Ubuntu Linux Distros, you can directly install Sublime Text using the Ubuntu Software Store. 

If your linux version has a pre-installed app store you can use that to download Sublime Text editor.

Installing Sublime Text in macOS

You can follow these given step to install Sublime Text on you mac

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.

First install homebrew which is a package manager and it will be used to download the gcc compiler in your mac system. 

Copy and Paste this code in your terminal :

/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”

Now, you can follow these steps to install the C++14 compiler 

Install gcc compiler using this code :

  Brew install gcc

Install gtimout in mac using this code :

brew install coreutils

You are good to go !!! 

Now, Lets see how you can setup Sublime text for competitive programming in C++

Setting Up Sublime Text For Competitive Programming In C++

Now let’s setup up Sublime Text for competitive programming !

Sublime Text setup for windows

  • Go to toolbar in the sublime text :    Tools > Build System > New Build System
  • Now, Paste this following code there and save it :
{
  "cmd" : ["g++-9 $file_name -o $file_base_name && gtimeout 4s ./$file_base_name<inputf.in>outputf.in"], 
  "selector" : "source.c",
  "shell": true,
  "working_dir" : "$file_path"
}

Now, We setup up the windows –

Use this key combination : Command + option + 3   OR   ⌘ + ⌥ + 3

Now, Write your C++ code in your first window and save it as 1.cpp 

Save the 2nd window as inputf.in and 3rd window as outputf.in

Sublime Text setup for Linux

  • Go to toolbar in the sublime text :    Tools > Build System > New Build System
  • Now, Paste this following code there and save it :
{
"cmd" : ["g++ -std=c++14 $file_name -o $file_base_name && timeout 4s ./$file_base_name<inputf.in>outputf.in"], 
"selector" : "source.c",
"shell": true,
"working_dir" : "$file_path"
}

Now, We setup up the windows –

Use this key combination : ALT + SHIFT + 3

Now, Write your C++ code in your first window and save it as 1.cpp 

Save the 2nd window as inputf.in and 3rd window as outputf.in

Sublime Text setup for Windows

  • Go to toolbar in the sublime text :    Tools > Build System > New Build System
  • Now, Paste this following code there and save it :
{
"cmd": ["g++.exe","-std=c++14", "${file}", "-o", "${file_base_name}.exe", "&&" , "${file_base_name}.exe<inputf.in>outputf.in"],
"selector":"source.cpp",
"shell":true,
"working_dir":"$file_path"
}

Now, We setup up the windows –

Use this key combination : ALT + SHIFT + 3

Now, Write your C++ code in your first window and save it as 1.cpp 

Save the 2nd window as inputf.in and 3rd window as outputf.in

Congratulations !!! Now you are ready with your Sublime Text editor to code in C++ and participate in a Competitive programming contest.

Broz Who Code

CodingBroz

1 thought on “How To Download and Setup Sublime Text for Competitive programming in C++”

Leave a Comment

Your email address will not be published. Required fields are marked *