当前位置:网站首页>A small code editor can also run programs -- a summary of sublime Text3 running programs in various languages
A small code editor can also run programs -- a summary of sublime Text3 running programs in various languages
2022-06-28 06:55:00 【nanke_ yh】
sublime text3 How can I run code ? I believe many friends have such questions , I may have thought so before today . I know I met a question and answer today , It asks :sublime text3 function python What is the reason that the program has no result . This aroused my curiosity . I can only say that I know too little , I have no idea . So I quickly searched it , I found that this software is also very powerful . You can do almost anything .
This software was downloaded and installed from the front-end by myself some time ago , Mainly used to write html Web code . In general, you can double-click directly html File in the browser to see the effect . Failed to explore the power of this software .
So let's start with sublime text3 Summary of software related functions .
Catalog
2、sublime text3 function python Program
3、sublime text3 function C Program
4、sublime text3 function C++ Program
5、sublime text3 Publish and run static html Program
1、 Introduce
sublime text 3 Not only is it a very powerful code editor , It's also a HTML And prose advanced text editor , Support multiple computer languages , Such as txt,html,js,java,c++,c,python etc. , And its volume is small , Interface simple , Support users to complete, such as code thumbnails ,Python Plug in for , Code snippets and other operations , And customize key binding menus and toolbars , It works very well . At the same time, the software has many functions , The main functions include : Spelling check , Bookmarks , complete Python API , Goto function , Instant project switching , Multiple choice , Multiple windows, etc , It can provide users with a better code editing environment . in addition ,sublime text 3 Or a cross platform editor , Can support at the same time Windows、Linux、Mac OS X Wait for multiple operating systems , Users need not worry that the operating system of their computer does not support running .
2、sublime text3 function python Program
Because the software itself supports python Language , So test directly :
1)、 Open software , Then create a new file to input the test code , Save as py File can ;
print("python hello world")2)、 And then click sublime text3 Menu bar 【 Tools 】 Options , Click... In the pop-up options 【 Compiling system 】, You can see that auto is checked , You can also manually select... From the secondary menu 【Python】 Compiled language ;

3)、 Click again sublime text3 menu bar 【 Tools 】 Option to compile , The running result will appear at the bottom .

3、sublime text3 function C Program
You can see from the picture above sublime text3 The compilation system under the toolbar does not directly compile C/C++ The function of language . Then we need to build a new one by ourselves .
1)、 Click on 【 Tools 】->【 Compiling system 】->‘ New build build system ’, It will pop up new .sublime-build file ;
2)、 Enter the following code :
{
"cmd": ["gcc","${file}","-o", "${file_path}/${file_base_name}"],
"file_regex":"^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir":"${file_path}",
"selector": "source.c",
"encoding":"cp936",
"variants":
[
{
"name": "C_Run",
"cmd": ["cmd","/c", "gcc", "${file}", "-o", "${file_path}/${file_base_name}","&&", "cmd", "/c","${file_path}/${file_base_name}"]
},
{
"name":"C_RunInCommand",
"cmd": ["cmd","/c", "gcc", "${file}","-o","${file_path}/${file_base_name}", "&&","start", "cmd", "/c","${file_path}/${file_base_name} & pause"]
}
]
}
3)、 Save the file : Save the path to Sublime Test Path , It's usually AppData\Roaming\Sublime Text 3\Packages\User; Save name :C.sublime-build
Then, you will find that there are 【C】 The language :

3.1、 test
Step and python The code is basically the same , Test code :
#include <stdio.h>
#include <stdlib.h>
void main()
{
printf("C hello world!");
}An error is reported in the compiled result :

The reason for the error is that the computer here is not installed gcc Environmental Science , that To install a Well .mingw-get-setup.exe Download address : link :https://osdn.net/projects/mingw/downloads/68260/mingw-get-setup.exe/
Main steps : install mingw-> Configure environment variables -> Verify that the installation is successful

find mingw32-gcc-g++-bin, Click on Mark for Installation. Then click on the Installation Menu Apply changes Options , Then select... On the pop-up page Apply Start to install or update the selected components online .( Close the package manager after installation , If the installation fails for some reason , Before exiting the program, the program will give a prompt , choice review changes Options can be reinstalled )
After installation , Configure the environment , Test it again “gcc -v” that will do .
go back to sublime text3 above , Continue compiling c Program , At this point, it can run successfully :

4、sublime text3 function C++ Program
about c++ Program operation and c The procedure is a similar step , First, create a new one .sublime-build file ; Then check it out g++ Whether the environment exists , Then select the compiling language to compile directly .
1)、 newly build .sublime-build file
{
"encoding": "utf-8",
"working_dir": "$file_path",
"shell_cmd": "g++ -Wall -std=c++0x \"$file_name\" -o \"$file_base_name\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"selector": "source.cpp","variants":
[
{
"name": "Run",
"shell_cmd": "g++ -Wall -std=c++0x \"$file\" -o \"$file_base_name\" && \"${file_path}/${file_base_name}\""
},
{
"name": "RunInCmd",
"shell_cmd": "g++ -Wall -std=c++0x \"$file\" -o \"$file_base_name\" && start cmd /c \"\"${file_path}/${file_base_name}\" & pause \""
}
]
}
2)、 Because the front has been installed MinGW, So it also has g++ Environmental Science , Can pass “g++ -v” Test it ;
3)、 Code testing
#include<iostream>
using namespace std;
int main()
{
cout<<"C++ hello world!"<<endl;
return 0;
}4)、 Click on ‘ use ... compile ’ perhaps ctrl+shift+B Compile

Choose the second , test result :

Above for sublime text3 You will have a general understanding of the steps of running various language programs , Then you know how to use it to run programs in other languages .
5、sublime text3 Publish and run static html Program
1)、 open Sublime, Using shortcut keys 【Ctrl + Shift + P】 Or click “Preferences”=> “Package controll” Go to the plug-in installation panel .
2)、 Then enter the command “Install Package”, Click on a command that appears below .
3)、 Then just enter the plug-in name “sublimeserver” Then click on the first search result , The plug-in will be installed automatically , Just wait a while .
4)、 Then in the menu, click “Tools” It can be found below “SublimeServer” Start function , Click on “Strat SublimeServer” You can start the server .
5)、 After starting the server, you need to run html Static pages are in the server , You can't use “Open In Browser”, But use “View In SublimeServer”.
Be careful :
There may be a problem :
eg: File cart.html not in sublilme Project Folder!
This is because SublimeServer It is required that the code file must be added to Sublime Text In the project : project (Porject)—— Add folder to project (Add Folder to Project ), choice html The folder where the file is located .
6)、 Then the system default browser will be opened automatically to run the file .

边栏推荐
- Speech enhancement - spectrum mapping
- Causes of wechat applet compilation page blank bug
- Freeswitch uses origin to dialplan
- Server body 18: understanding and thinking of UDP reliable transmission (feeling from reading Yunfeng blog)
- 服务器正文18:UDP可靠传输的理解和思考(读云凤博客有感)
- Note that JPA uses a custom VO to receive jpql query results
- C语言教程大全
- Teach you how to use UCOS
- 【Rust翻译】从头实现Rust异步执行器
- @RequestParam
猜你喜欢

搭建你jmeter+jenkins+ant

Camx架构开UMD、KMD log以及dump图的方式

Techo day Tencent technology open day, June 28 online waiting for you!

FPM tool installation
![[digital statistics DP] counting problem](/img/8d/ac05c1a88543b76fca86cd744e9cb1.jpg)
[digital statistics DP] counting problem

Freeswitch uses origin to dialplan

Libuv framework echo server C source code explanation (TCP part)

Linux Mysql 实现root用户不用密码登录

编译配置in文件

推荐几款0代码、免费、现学现用的可视化工具
随机推荐
Reinforcement learning - grid world
三极管驱动无刷电机
编译配置in文件
[produced by Xinghai] operation and maintenance inspection collection
Linked list (I) - remove linked list elements
Promotion intégrale et ordre des octets de fin de taille
代码没写错,渲染页面不显示原因
我的MVVM开源项目《出行防疫App》已发布
Linux Mysql 实现root用户不用密码登录
AttributeError: 'callable_iterator' object has no attribute 'next'
整型提升和大小端字节序
职场IT老鸟的几点小习惯
Camx架构开UMD、KMD log以及dump图的方式
饿久了,大脑会进入“省电模式”!感官被削弱,还看不清东西丨爱丁堡大学...
普歌 -- getOrDefault()方法理解
Alert pop-up processing in Web Automation
JS regular expression system explanation (comprehensive summary)
Cmake tips
强化学习——格子世界
编译原理期末复习