当前位置:网站首页>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 .
边栏推荐
- 编译原理期末复习
- Libuv framework echo server C source code explanation (TCP part)
- 代码没写错,渲染页面不显示原因
- Is it safe to open a stock trading account on your mobile phone?
- Exception handling (I) -- null pointer and array index out of bounds
- Tryout title code
- Introduction to Qualcomm platform WiFi -- Wi Fi display software
- FPGA - 7系列 FPGA SelectIO -07- 高级逻辑资源之ISERDESE2
- 最后的二十九天
- ROS rviz_ Satellite function package visualizes GNSS track and uses satellite map
猜你喜欢
Freeswitch uses origin to dialplan
From the beginning of redis learning to take-off, this article is all for you
《微信小程序-基础篇》带你了解小程序中的生命周期(一)
面经---测试工程师web端自动化---大厂面试题
eyebeam高级设置
Freeswitch使用originate转dialplan
Rn7302 three-phase electric quantity detection (based on STM32 single chip microcomputer)
职场IT老鸟的几点小习惯
[c #] [reprint]furion frame address and tutorial address
Eyebeam advanced settings
随机推荐
OpenGL API learning (2008) client server client server
Cmake tips
Call interface event API common event methods
Freeswitch uses origin to dialplan
调接口事件API常用事件方法
Linux Mysql 实现root用户不用密码登录
[rust translation] implement rust asynchronous actuator from scratch
「杰伦熊」暴跌96.6% 明星带货NFT为何遇冷?
Libuv framework echo server C source code explanation (TCP part)
From the beginning of redis learning to take-off, this article is all for you
AttributeError: 'callable_ iterator' object has no attribute 'next'
Trie string statistics
微信小程序编译页面空白bug的原因
Paper recommendation: efficientnetv2 - get smaller models and faster training speed through NAS, scaling and fused mbconv
Linked list (II) - Design linked list
Integer promotion and size side byte order
[c #] [reprint]furion frame address and tutorial address
炒股开户在手机上安全吗?
[rust daily] published on rust 1.43.0 on April 23, 2020
《微信小程序-基础篇》带你了解小程序中的生命周期(一)