Skip to content
Advertisement

Run two python instances from one python file in sublime text

Suppose I have a python file which plot a simple sin(a*x) function. In sublime text, when I press command+B, the plot shows.

However, suppose I need to change the parameter a and compare the figure with the current one. A simple second press of command+B just close the current plot and generate a new one, which is not what I want cause I want to compare them side by side.

In PyCharm you have allow parallel run option, I wonder if sublime text can achieve this.

Advertisement

Answer

In Sublime Text you have the option to open multiple terminals in multiple tabs, allowing you to keep 2 versions of the same python file running simultaneously. Here is a GIF demonstrating that:

enter image description here

Here are the steps:

  1. Open the Command Pallette. It can be found in the Tools tab in the menu bar.

  2. Enter “Terminus tab” into the search box and select the only option that will be displayed. A new tab will be opened, and there you can navigate to where your python file is located.

  3. For the second terminal, repeat step 2.

  4. Now you can run the same python file indepentantly in the 2 teminal tabs.


To have the two terminal windows displayed below the python file, go to the “View” tab, then “Layout”, and select the “Rows: 2” option (the window will be split into 2 windows). Open a terminus tab in the bottom window. Then, go to the Command Palette and enter “Terminus toggle” and select the only option. Now you have two terminal windows at the bottom of your file. Here is a GIF to demonstrate:

enter image description here


To have the terminals to be displayed side-by-side horizontally and not vertically (like demonstrated above), select the “Grid: 4” instead of the “Columns: 2” option and open a terminus tab in the bottom two windows. Here is a GIF to demonstrate:

enter image description here

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement