DEV Community

Sohaib03
Sohaib03

Posted on

Run Python and C++ code directly from Sublime Text (Using Terminus and Origami)

Sublime Text 3 is my editor of choice, but it has bugged me for a long time that it doesn't come with an integrated terminal. That's why I switched to Visual Studio Code for a long time. But the background processes of Visual Studio Code drain my laptop's battery faster than any other text editors. Though it was better at linting and autocompletion , I like lighter text editors otherwise I would be using IDEs like Pycharm or Clion.

Install Terminus

That's where Terminus (A sublime text plugin) comes in. This plugin allows us to use a fully functional terminal inside Sublime Text. Lets install this plugin and see what is does. Open Command Pallet (Ctrl + Shift + P) and select "Package Control: Install Package". Search for "Terminus" and let it install. It might require a restart. So, restart Sublime Text and try to run it from Command Pallet(Ctrl + Shift + P) by searching "Terminus: Toggle Panel". This will open a terminal right below the active tab.

Install Origami

Now, for the second plugin, we install Origami. Origami is a powerful tool, which allows to open panes at various sides of Sublime Text. You can experiment with origami from the command pallet. We will use this plugin to run the terminal from a shortcut. Use Command Pallet(Ctrl + Shift + P) "Install Package" to install Origami.

Python and C++ integration

  1. Preferences -> Package Settings -> Terminus -> Key Bindings
  2. A new Sublime Text Window will pop up. The new window has two panes. We will work with the right pane (which might be empty in your case)
  3. Now paste the following code in that pane For Linux:
    For Windows:
  4. Now save the file.

Now your setup is complete. Press F6 to run a Python File and F8 to compile and run a C++ file. Additionally, 'Alt+`' will open a terminal in the active window.

Feel free to comment below for any help.

Top comments (0)