当前位置:网站首页>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 .

边栏推荐
- Linked list (III) - reverse linked list
- CMAKE小知识
- fpm工具安装
- 【Rust翻译】从头实现Rust异步执行器
- VM332 WAService.js:2 Error: _vm.changeTabs is not a function报错
- Linked list (I) - remove linked list elements
- Wechat applets - basics takes you to understand the life cycle of applets (I)
- KMP string
- FPGA - 7系列 FPGA SelectIO -08- 高级逻辑资源之OSERDESE2
- Server body 18: understanding and thinking of UDP reliable transmission (feeling from reading Yunfeng blog)
猜你喜欢

Linked list (III) - reverse linked list

Wechat applets - basics takes you to understand the life cycle of applets (I)

Compilation principles final review

Pytorch RNN learning notes

Techo Day 腾讯技术开放日,6月28日线上等你!

Compile configuration in file

Introduction to browser tools: think sky browser, team work browser

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

微信小程序编译页面空白bug的原因

JDBC learning (I) -- implementing simple CRUD operations
随机推荐
4~20ma input /0~5v output i/v conversion circuit
KMP string
手把手教你用Ucos
OpenGL API learning (2008) client server client server
AttributeError: 'callable_iterator' object has no attribute 'next'
助力涨点 | YOLOv5结合Alpha-IoU
Puge -- understanding of getordefault() method
ROS rviz_ Satellite function package visualizes GNSS track and uses satellite map
FPGA - 7系列 FPGA SelectIO -08- 高级逻辑资源之OSERDESE2
Introduction to Qualcomm platform WiFi -- Wi Fi display software
D3D11_ Chili_ Tutorial (3): design a bindable/drawable system
JS of learning notes -- split(), replace(), join()
Some habits of it veterans in the workplace
CRC32概述以及实现和使用
FPGA - 7 Series FPGA selectio -07- iserdese2 of advanced logic resources
微信小程序分页功能,下拉刷新功能,直接干货拿来就用
YOLOv5增加小目标检测层
freeswitch使用mod_shout模块播放mp3
"Jay bear" plummeted by 96.6%. Why is NFT with star goods cold?
Interpretation of Blog