Home > Article > Development Tools > How to execute a program using sublime
Sublime Text can implement program execution by installing the Exec plug-in: After installing the plug-in, configure the exec_cmd settings to specify the command used to execute the program. Select a line of code or file and press Ctrl Enter (Windows/Linux) or Cmd Enter (macOS) to execute the program.
How to execute programs in Sublime
Sublime Text is a popular code editor, although it is not Has the ability to execute programs, but this functionality can be achieved by installing plug-ins.
Install plug-in
Ctrl
Shift
P
(Windows/Linux) or Cmd
Shift
P
(macOS) Open the command panel. Install Package
. Exec
. Configuring the plugin
Once the plugin is installed, you need to configure it to specify the command used to execute the program. Open the Sublime Text settings file:
Ctrl
,
(Windows/Linux) or Cmd
,
(macOS) Open Settings. Exec
Settings. <code>"exec_cmd": "/bin/bash -c '{cmd}'",</code>
Replace {cmd}
with the command you want to execute. For example, to execute a Python program, replace it with:
<code>"exec_cmd": "/usr/bin/python3 '{cmd}'",</code>
Execute the program
After configuring the plugin, you can execute the program by:
Ctrl
Enter
(Windows/Linux) or Cmd
Enter
(macOS). Sublime Text will run the command specified in the plugin settings and display its output in a new tab.
Tip
exec_cmd
settings. exec_cmd
setting: <code>"exec_cmd": "/bin/bash -c '{cmd} < {input_file}'",</code>
The above is the detailed content of How to execute a program using sublime. For more information, please follow other related articles on the PHP Chinese website!